14 * Description: Class for doing asynchronous service. |
14 * Description: Class for doing asynchronous service. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <centralrepository.h> |
|
20 |
19 |
21 #include "epos_comasuplprotocolmanager1.h" |
20 #include "epos_comasuplprotocolmanager1.h" |
22 #include "epos_csuplcommunicationmanager.h" |
21 #include "epos_csuplcommunicationmanager.h" |
23 #include "epos_csuplsettingsinternal.h" |
22 #include "epos_csuplsettingsinternal.h" |
24 |
23 #include "epos_csuplsettingparams.h" |
25 #include "epos_omasuplconstants.h" |
24 #include "epos_omasuplconstants.h" |
26 #include "epos_comasuplconnrequestor.h" |
25 #include "epos_comasuplconnrequestor.h" |
27 #include "epos_momasuplconnobserver.h" |
26 #include "epos_momasuplconnobserver.h" |
28 #include "epos_comasupltrace.h" |
27 #include "epos_comasupltrace.h" |
29 #include "epos_comasuplfallbackhandler.h" |
28 #include "epos_comasuplfallbackhandler.h" |
30 #include "epos_csuplsettingsinternalcrkeys.h" |
|
31 |
|
32 |
29 |
33 #include "epos_comasupldialogtimer.h" |
30 #include "epos_comasupldialogtimer.h" |
34 _LIT(KTraceFileName,"SUPL_OMA_SESSION::epos_comasuplconnrequestor.cpp"); |
31 _LIT(KTraceFileName,"SUPL_OMA_SESSION::epos_comasuplconnrequestor.cpp"); |
35 |
32 |
|
33 const TInt KStringLength = 100; |
36 |
34 |
37 |
35 |
38 // ============================ MEMBER FUNCTIONS =============================== |
36 // ============================ MEMBER FUNCTIONS =============================== |
39 |
37 |
40 // ----------------------------------------------------------------------------- |
38 // ----------------------------------------------------------------------------- |
41 // COMASuplConnRequestor::COMASuplConnRequestor |
39 // COMASuplConnRequestor::COMASuplConnRequestor |
42 // C++ constructor can NOT contain any code, that might leave. |
40 // C++ constructor can NOT contain any code, that might leave. |
43 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
44 // |
42 // |
45 COMASuplConnRequestor::COMASuplConnRequestor(CSuplCommunicationManager& aCommMgr, |
43 COMASuplConnRequestor::COMASuplConnRequestor( |
46 COMASUPLProtocolManager1& aProtoMgr, |
44 CSuplCommunicationManager& aCommMgr, |
47 TUint aPort, |
45 COMASUPLProtocolManager1& aProtoMgr, TUint aPort, |
48 MOMASuplConnObserver& aObserver): |
46 MOMASuplConnObserver& aObserver) : |
49 CActive( EPriorityStandard ), |
47 CActive(EPriorityStandard), iCommMgr(aCommMgr), iProtocolManager( |
50 iCommMgr(aCommMgr), |
48 aProtoMgr),iConnection(NULL), iPort(aPort), iObserver(aObserver), iIapDialogShown( |
51 iProtocolManager(aProtoMgr), |
49 EFalse), iIapDlgTimerExpired(EFalse), |
52 iPort(aPort), |
50 iIsTimeoutDialogTimerStarted(EFalse) |
53 iObserver( aObserver),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse) |
51 { |
54 { |
52 |
55 |
53 } |
56 } |
|
57 |
54 |
58 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
59 // COMASuplConnRequestor::ConstructL |
56 // COMASuplConnRequestor::ConstructL |
60 // Symbian 2nd phase constructor can leave. |
57 // Symbian 2nd phase constructor can leave. |
61 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
70 iTrace = COMASuplTrace::NewL(); |
67 iTrace = COMASuplTrace::NewL(); |
71 iIsHSLPGenerated = EFalse; |
68 iIsHSLPGenerated = EFalse; |
72 iHslpAddrFromImsiUsed = EFalse; |
69 iHslpAddrFromImsiUsed = EFalse; |
73 |
70 |
74 iFallBackHandler = COMASuplFallBackHandler::NewL(*iSuplSettings); |
71 iFallBackHandler = COMASuplFallBackHandler::NewL(*iSuplSettings); |
75 iRepository = CRepository::NewL(KCRUidSuplSettings); |
72 |
76 iLastConnectionError = KErrNone; |
73 iLastConnectionError = KErrNone; |
77 |
74 |
78 iCurrentSLPId = KErrNotFound; |
75 iCurrentSLPId = KErrNotFound; |
79 |
76 |
|
77 iDialogTimer = COMASuplDialogTimer::NewL(*this); |
80 } |
78 } |
81 |
79 |
82 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
83 // COMASuplConnRequestor::NewL |
81 // COMASuplConnRequestor::NewL |
84 // Two-phased constructor. |
82 // Two-phased constructor. |
133 TBool isIapDialogShown = EFalse; |
134 TBool isIapDialogShown = EFalse; |
134 TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown); |
135 TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown); |
135 |
136 |
136 if(errorCode == KErrNone) |
137 if(errorCode == KErrNone) |
137 { |
138 { |
138 TBool ret = ConvertIAPNameToIdL(iapName,iIAPId); |
139 TBool ret = ConvertIAPNameToIdL(iapName,iIAPId); |
139 if(!ret) |
140 if(!ret) |
140 { |
141 { |
141 buffer.Copy(_L("No access point configured for ")); |
142 buffer.Copy(_L("No access point configured for ")); |
142 buffer.Append(iHostAddress); |
143 buffer.Append(iHostAddress); |
143 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
144 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
144 buffer.Copy(_L("Calling CreateConnection with no IAP")); |
145 if( isIapDialogShown ) |
145 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
146 { |
146 iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,-1); |
147 TInt err = iProtocolManager.LaunchSettingsUI(this,iHostAddress); |
147 OpenConnection(); |
148 if(err != KErrNone) |
148 |
149 { |
149 } |
150 buffer.Copy(_L("Error in launching UI : ")); |
150 else |
151 buffer.AppendNum(err); |
151 { |
152 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
152 buffer.Copy(_L("Connecting to ")); |
153 iHostAddress.Zero(); |
153 buffer.Append(iHostAddress); |
154 iObserver.OperationCompleteL(err); |
154 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
155 } |
155 iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId); |
156 else |
156 OpenConnection(); |
157 iIapDialogShown = ETrue; |
157 } |
158 } |
158 } |
159 |
159 else |
160 |
160 { |
161 } |
161 iHostAddress.Zero(); |
162 else |
162 iObserver.OperationCompleteL(errorCode); |
163 { |
163 } |
164 iIsTimeoutDialogTimerStarted = EFalse; |
|
165 iDialogTimer->Cancel(); |
|
166 buffer.Copy(_L("Connecting to ")); |
|
167 buffer.Append(iHostAddress); |
|
168 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
|
169 iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId); |
|
170 OpenConnection(); |
|
171 } |
|
172 } |
|
173 else |
|
174 { |
|
175 iHostAddress.Zero(); |
|
176 iObserver.OperationCompleteL(errorCode); |
|
177 } |
164 } |
178 } |
165 } |
179 } |
166 |
180 |
167 |
181 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
182 // COMASuplConnRequestor::OpenConnection |
169 // COMASuplConnRequestor::CreateConnection for OCC |
|
170 // ----------------------------------------------------------------------------- |
183 // ----------------------------------------------------------------------------- |
171 // |
184 // |
172 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly) |
185 void COMASuplConnRequestor::CreateConnectionL(TInt aDialogTimeOutDelay) |
173 { |
186 { |
174 TBuf<30> GeoTagServerName; |
187 iIsTimeoutDialogTimerStarted = ETrue; |
175 TBuf<128> buffer; |
188 |
176 iState = EConnecting; |
189 iDialogTimer->StartTimer(aDialogTimeOutDelay); |
177 |
|
178 iPrompt = aPrompt; |
|
179 iWlanOnly = aWlanOnly; |
|
180 iIsStaleLocIdPresent = ETrue; |
|
181 |
|
182 TInt err; |
|
183 err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName); |
|
184 User::LeaveIfError(err); |
|
185 buffer.Copy(_L("Connecting to")); |
|
186 buffer.Append(GeoTagServerName); |
|
187 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
|
188 iTls = ETrue; |
|
189 iPskTls = EFalse; |
|
190 iIAPId = 0; |
|
191 |
|
192 |
|
193 iConnection = iCommMgr.CreateConnectionL(GeoTagServerName,iTls,iPskTls,iPort,iIAPId); |
|
194 |
|
195 OpenConnection(); |
|
196 |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // COMASuplConnRequestor::OpenConnection |
|
201 // ----------------------------------------------------------------------------- |
|
202 |
|
203 void COMASuplConnRequestor::CreateConnectionL(TInt /*aDialogTimeOutDelay*/) |
|
204 { |
|
205 CreateConnectionL(); |
190 CreateConnectionL(); |
206 } |
191 } |
207 // ----------------------------------------------------------------------------- |
192 // ----------------------------------------------------------------------------- |
208 // COMASuplConnRequestor::OpenConnection |
193 // COMASuplConnRequestor::OpenConnection |
209 // ----------------------------------------------------------------------------- |
194 // ----------------------------------------------------------------------------- |
505 } |
472 } |
506 CleanupStack::PopAndDestroy(2);//delete tableView and commDb |
473 CleanupStack::PopAndDestroy(2);//delete tableView and commDb |
507 return result; |
474 return result; |
508 } |
475 } |
509 |
476 |
510 |
477 // ----------------------------------------------------------------------------- |
|
478 // COMASuplConnRequestor::SettingsUICompleted |
|
479 // |
|
480 // ----------------------------------------------------------------------------- |
|
481 |
|
482 void COMASuplConnRequestor::SettingsUICompletedL(TInt aError) |
|
483 { |
|
484 TBuf<128> buffer(_L("COMASuplConnRequestor:SettingsUICompleted Error: ")); |
|
485 buffer.AppendNum(aError); |
|
486 iTrace->Trace(buffer,KTraceFileName, __LINE__); |
|
487 |
|
488 if (iIsTimeoutDialogTimerStarted) |
|
489 { |
|
490 iTrace->Trace(_L("COMASuplSession::SettingsUICompleted, stopping timer "), KTraceFileName, __LINE__); |
|
491 iIsTimeoutDialogTimerStarted = EFalse; |
|
492 iDialogTimer->StopTimer(); |
|
493 } |
|
494 if (iIapDlgTimerExpired) |
|
495 { |
|
496 iIapDlgTimerExpired = EFalse; |
|
497 iIapDialogShown = EFalse; |
|
498 iProtocolManager.LaunchSuplDialogTimeoutUI(this); |
|
499 iObserver.OperationCompleteL(KErrNone); |
|
500 return; |
|
501 } |
|
502 if(aError == KErrNone) |
|
503 { |
|
504 TInt err = KErrGeneral; |
|
505 iTrace->Trace( |
|
506 _L("COMASuplConnRequestor::SettingsUICompletedL KErrNone"), |
|
507 KTraceFileName, __LINE__); |
|
508 TBuf<100> IapName, buffer; |
|
509 CServerParams* params = CServerParams::NewL(); |
|
510 |
|
511 err = iSuplSettings->GetSlpInfoAddress(iHostAddress, params); |
|
512 iTrace->Trace(_L("iSuplSettings->GetSlpInfoAddress returned : "), |
|
513 KTraceFileName, __LINE__); |
|
514 buffer.AppendNum(err); |
|
515 iTrace->Trace(buffer, KTraceFileName, __LINE__); |
|
516 |
|
517 // Fix for ou1cimx#475026 and ou1cimx#471138 |
|
518 // When there are no access points defined for any SUPL server, the user is asked to |
|
519 // select the access point only once and same access point is used for the following servers. |
|
520 if (err == KErrNone) |
|
521 { |
|
522 HBufC* aServerAddress = HBufC::NewL(KStringLength); |
|
523 HBufC* aIapName = HBufC::NewL(KStringLength); |
|
524 TInt64 aSlpId; |
|
525 TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable; |
|
526 |
|
527 err = params->Get(aSlpId, aServerAddress->Des(), aIapName->Des(), |
|
528 aServerEnabled, aSimChangeRemove, aUsageInHomeNw, |
|
529 aEditable); |
|
530 |
|
531 iTrace->Trace(_L("params->Get() returned: "), KTraceFileName, |
|
532 __LINE__); |
|
533 buffer.Zero(); |
|
534 buffer.AppendNum(err); |
|
535 iTrace->Trace(buffer, KTraceFileName, __LINE__); |
|
536 IapName.Copy(*aIapName); |
|
537 IapName.LowerCase(); |
|
538 |
|
539 //converting the iap name to id. |
|
540 ConvertIAPNameToIdL(IapName, iIAPId); |
|
541 //updating the list of SLP with the chosen access point |
|
542 iFallBackHandler->UpdateSLPListWithAccessPoint(IapName); |
|
543 |
|
544 delete aServerAddress; |
|
545 delete aIapName; |
|
546 delete params; |
|
547 |
|
548 // if the getting the list parameters is success opening the connection with the chosen access point |
|
549 if (err == KErrNone) |
|
550 { |
|
551 buffer.Copy(_L("Connecting to ")); |
|
552 buffer.Append(iHostAddress); |
|
553 buffer.Append(_L(" using IAP ")); |
|
554 buffer.Append(IapName); |
|
555 iTrace->Trace(buffer, KTraceFileName, __LINE__); |
|
556 iConnection = iCommMgr.CreateConnectionL(iHostAddress, iTls, |
|
557 iPskTls, iPort, iIAPId); |
|
558 OpenConnection(); |
|
559 } |
|
560 else |
|
561 { |
|
562 iObserver.OperationCompleteL(err); |
|
563 } |
|
564 } |
|
565 else |
|
566 { |
|
567 delete params; |
|
568 iObserver.OperationCompleteL(err); |
|
569 } |
|
570 } |
|
571 else |
|
572 { |
|
573 iObserver.OperationCompleteL(aError); |
|
574 } |
|
575 |
|
576 } |
511 |
577 |
512 // ----------------------------------------------------------------------------- |
578 // ----------------------------------------------------------------------------- |
513 // COMASuplConnRequestor::SaveAccessPoint |
579 // COMASuplConnRequestor::SaveAccessPoint |
514 // |
580 // |
515 // ----------------------------------------------------------------------------- |
581 // ----------------------------------------------------------------------------- |