|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of HTTP Client Engine. |
|
15 */ |
|
16 |
|
17 //Symbian headers |
|
18 #include <http.h> |
|
19 #include <commdbconnpref.h> |
|
20 #include <connpref.h> |
|
21 #include <extendedconnpref.h> |
|
22 #include <commdb.h> |
|
23 #include <etel3rdparty.h> // voice call notification |
|
24 #include <mmtsy_names.h> // kmmtsymodulename |
|
25 #include "locationmanagerdebug.h" |
|
26 #include "clientengine.h" |
|
27 |
|
28 // Used user agent for requests |
|
29 _LIT8(KUserAgent, "SimpleClient 1.0"); |
|
30 |
|
31 // This client accepts all content types. |
|
32 _LIT8(KAccept, "*/*"); |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CClientEngine::NewL() |
|
36 // ---------------------------------------------------------------------------- |
|
37 CClientEngine* CClientEngine::NewL( MClientObserver& aObserver) |
|
38 { |
|
39 LOG("CClientEngine::NewL ,begin"); |
|
40 CClientEngine* self = CClientEngine::NewLC( aObserver); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CClientEngine::NewLC() |
|
47 // ---------------------------------------------------------------------------- |
|
48 CClientEngine* CClientEngine::NewLC(MClientObserver& aObserver) |
|
49 { |
|
50 LOG("CClientEngine::NewLC ,begin"); |
|
51 CClientEngine* self = new ( ELeave ) CClientEngine( aObserver); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CClientEngine::CClientEngine() |
|
59 // ---------------------------------------------------------------------------- |
|
60 CClientEngine::CClientEngine( MClientObserver& aObserver): |
|
61 CActive( CActive::EPriorityStandard ), |
|
62 iObserver( aObserver ), |
|
63 iConnectionSetupDone( EFalse ), |
|
64 iPrevProfileId( -1 ), |
|
65 iMobility(NULL), |
|
66 iTransactionOpen( EFalse ), |
|
67 iUri(NULL) |
|
68 { |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CClientEngine::~CClientEngine() |
|
73 // ---------------------------------------------------------------------------- |
|
74 CClientEngine::~CClientEngine() |
|
75 { |
|
76 LOG("CClientEngine::~CClientEngine ,begin"); |
|
77 Cancel(); |
|
78 |
|
79 if ( iTransactionOpen ) |
|
80 { |
|
81 iTransaction.Close(); |
|
82 iTransactionOpen = EFalse; |
|
83 } |
|
84 |
|
85 if ( iMobility ) |
|
86 { |
|
87 iMobility->Cancel(); |
|
88 } |
|
89 delete iMobility; |
|
90 if(iConnectionSetupDone) |
|
91 { |
|
92 iSession.Close(); |
|
93 iConnection.Close(); |
|
94 iSocketServ.Close(); |
|
95 } |
|
96 delete iUri; |
|
97 |
|
98 iCmManager.Close(); |
|
99 |
|
100 |
|
101 // DON'T cose RMobilePhone object |
|
102 |
|
103 LOG("CClientEngine::~CClientEngine ,end"); |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------------------------------- |
|
107 // CClientEngine::ConstructL() |
|
108 // ---------------------------------------------------------------------------- |
|
109 void CClientEngine::ConstructL() |
|
110 { |
|
111 LOG("CClientEngine::ConstructL ,begin"); |
|
112 CActiveScheduler::Add(this); |
|
113 iCmManager.OpenL(); |
|
114 LOG("CClientEngine::ConstructL ,end"); |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // CClientEngine::CloseConnection() |
|
119 // ---------------------------------------------------------------------------- |
|
120 void CClientEngine::CloseConnection() |
|
121 { |
|
122 LOG("CClientEngine::CloseConnection ,begin" ); |
|
123 if ( iTransactionOpen ) |
|
124 { |
|
125 iTransaction.Close(); |
|
126 iTransactionOpen = EFalse; |
|
127 } |
|
128 |
|
129 if ( iMobility ) |
|
130 { |
|
131 iMobility->Cancel(); |
|
132 delete iMobility; |
|
133 iMobility = NULL; |
|
134 } |
|
135 |
|
136 if(iConnectionSetupDone) |
|
137 { |
|
138 iSession.Close(); |
|
139 iConnection.Close(); |
|
140 iSocketServ.Close(); |
|
141 |
|
142 iConnectionSetupDone = EFalse; |
|
143 } |
|
144 LOG("CClientEngine::CloseConnection ,end"); |
|
145 } |
|
146 |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CClientEngine::IsVisitorNetwork() |
|
150 // ---------------------------------------------------------------------------- |
|
151 TBool CClientEngine::IsVisitorNetwork(const TMobileRoamingStatus& aRegNetworkStatus) const |
|
152 { |
|
153 LOG1("CClientEngine::IsVisitorNetwork. reg network status - %d", |
|
154 (TInt) aRegNetworkStatus); |
|
155 |
|
156 return (aRegNetworkStatus == EMobileNationalRoaming || |
|
157 aRegNetworkStatus== EMobileInternationalRoaming); |
|
158 |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // CClientEngine::IsWlanOnly() |
|
163 // ---------------------------------------------------------------------------- |
|
164 TBool CClientEngine::IsWlanOnly(const TMobileRoamingStatus& aRoamingStatus, |
|
165 const TCmGenConnSettings& aGenConnSettings) const |
|
166 { |
|
167 LOG1("CClientEngine::IsVisitorNetwork. reg network status - %d",(TInt) aRoamingStatus); |
|
168 TBool wlanOnlyFlag = EFalse; |
|
169 switch(aRoamingStatus) |
|
170 { |
|
171 case EMobileRegHomeNetwork: |
|
172 LOG("Home network"); |
|
173 wlanOnlyFlag = (aGenConnSettings.iCellularDataUsageHome == ECmCellularDataUsageDisabled); |
|
174 break; |
|
175 case EMobileNationalRoaming: |
|
176 case EMobileInternationalRoaming: |
|
177 LOG("Visitor network"); |
|
178 wlanOnlyFlag = (aGenConnSettings.iCellularDataUsageVisitor == ECmCellularDataUsageDisabled); |
|
179 break; |
|
180 default: |
|
181 break; |
|
182 } // end of switch |
|
183 LOG1("Wlan only flag - %d", wlanOnlyFlag ? 1 : 0); |
|
184 return wlanOnlyFlag; |
|
185 } |
|
186 |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CClientEngine::UeRegNetworkStatus() |
|
190 // ---------------------------------------------------------------------------- |
|
191 TMobileRoamingStatus CClientEngine::UeRegNetworkStatus() |
|
192 { |
|
193 LOG("CClientEngine::UeRegNetworkStatus() ,begin"); |
|
194 TMobileRoamingStatus roamingStatus = EMobileNotRegistered; |
|
195 if(iObserver.IsRegisteredAtHomeNetwork()) |
|
196 { |
|
197 // home network. |
|
198 roamingStatus = EMobileRegHomeNetwork; |
|
199 LOG("UE registered in home network"); |
|
200 } |
|
201 else |
|
202 { |
|
203 // roaming network |
|
204 TBool homeNwInfoAvailableFlag = EFalse; |
|
205 const RMobilePhone::TMobilePhoneNetworkInfoV1& homeNwInfo = |
|
206 iObserver.GetHomeNetworkInfo(homeNwInfoAvailableFlag); |
|
207 if(homeNwInfoAvailableFlag) |
|
208 { |
|
209 RMobilePhone::TMobilePhoneNetworkCountryCode countryCode = |
|
210 iObserver.GetCurrentRegisterNw().iCountryCode; |
|
211 if(countryCode.Compare(homeNwInfo.iCountryCode) == 0) |
|
212 { |
|
213 // national roaming.. |
|
214 LOG("UE is in nation roaming"); |
|
215 roamingStatus = EMobileNationalRoaming; |
|
216 } |
|
217 else |
|
218 { |
|
219 // international roaming. |
|
220 LOG("UE is in international roaming"); |
|
221 roamingStatus = EMobileInternationalRoaming; |
|
222 } |
|
223 } |
|
224 } |
|
225 if(roamingStatus == EMobileNotRegistered) |
|
226 { |
|
227 LOG("UE is not registered with the network. Offline mode."); |
|
228 } |
|
229 LOG("CClientEngine::UeRegNetworkStatus ,end"); |
|
230 return roamingStatus; |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CClientEngine::IsDataConnectionAskAlwaysL() |
|
235 // ---------------------------------------------------------------------------- |
|
236 TBool CClientEngine::IsDataConnectionAskAlwaysL() |
|
237 { |
|
238 LOG("CClientEngine::IsDataConnectionAskAlwaysL ,begin"); |
|
239 TMobileRoamingStatus roamingStatus = UeRegNetworkStatus(); |
|
240 |
|
241 TCmGenConnSettings genConnSettings; |
|
242 TBool retVal = EFalse; |
|
243 iCmManager.ReadGenConnSettingsL(genConnSettings); |
|
244 |
|
245 LOG1("wlan usage - %d", genConnSettings.iUsageOfWlan); |
|
246 LOG1("Home usage - %d", genConnSettings.iCellularDataUsageHome); |
|
247 LOG1("Visitor usage - %d", genConnSettings.iCellularDataUsageVisitor); |
|
248 |
|
249 if((IsWlanOnly(roamingStatus, genConnSettings) && genConnSettings.iUsageOfWlan == ECmUsageOfWlanManual) // wlan |
|
250 || (roamingStatus == EMobileRegHomeNetwork && // home |
|
251 genConnSettings.iCellularDataUsageHome == ECmCellularDataUsageConfirm) |
|
252 || (IsVisitorNetwork(roamingStatus) && // roaming |
|
253 genConnSettings.iCellularDataUsageVisitor == ECmCellularDataUsageConfirm) |
|
254 ) |
|
255 { |
|
256 retVal = ETrue; |
|
257 } |
|
258 LOG("CClientEngine::IsDataConnectionAskAlwaysL ,end"); |
|
259 return retVal; |
|
260 } |
|
261 |
|
262 // ---------------------------------------------------------------------------- |
|
263 // CClientEngine::SetupConnectionL() |
|
264 // ---------------------------------------------------------------------------- |
|
265 void CClientEngine::SetupConnectionL( const TConnectionOption aOption ) |
|
266 { |
|
267 LOG("CClientEngine::SetupConnectionL ,begin"); |
|
268 if ( aOption == ESilent && IsDataConnectionAskAlwaysL()) |
|
269 { |
|
270 LOG("Silent mode. connection setup is asked always."); |
|
271 if ( iConnectionSetupDone ) |
|
272 { |
|
273 LOG("Already connected. Close the connection\n"); |
|
274 CloseConnection(); |
|
275 } |
|
276 User::Leave(KErrNotSupported); |
|
277 } |
|
278 if ( iConnectionSetupDone ) |
|
279 { |
|
280 // Connection setup is done |
|
281 LOG("Already connected.\n"); |
|
282 User::Leave(KErrAlreadyExists); |
|
283 } |
|
284 |
|
285 |
|
286 LOG1("SetupConnectionL: connection option: %d\n", aOption ); |
|
287 |
|
288 // Open HTTP Session |
|
289 iSession.OpenL(); |
|
290 User::LeaveIfError(iSocketServ.Connect()); |
|
291 User::LeaveIfError(iConnection.Open(iSocketServ)); |
|
292 |
|
293 if ( aOption == ESilent ) |
|
294 { |
|
295 // Create overrides |
|
296 TConnPrefList prefList; |
|
297 TExtendedConnPref prefs; |
|
298 prefs.SetSnapPurpose( CMManager::ESnapPurposeInternet ); |
|
299 prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent ); |
|
300 prefList.AppendL( &prefs ); |
|
301 |
|
302 iConnection.Start(prefList, iStatus); |
|
303 } |
|
304 else |
|
305 { |
|
306 iConnection.Start( iStatus ); |
|
307 } |
|
308 |
|
309 |
|
310 SetActive(); |
|
311 LOG("CClientEngine::SetupConnectionL ,end"); |
|
312 } |
|
313 |
|
314 // ---------------------------------------------------------------------------- |
|
315 // CClientEngine::SetHeaderL() |
|
316 // ---------------------------------------------------------------------------- |
|
317 void CClientEngine::SetHeaderL( RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue ) |
|
318 { |
|
319 LOG("CClientEngine::SetHeaderL ,begin"); |
|
320 RStringF valStr = iSession.StringPool().OpenFStringL( aHdrValue ); |
|
321 CleanupClosePushL( valStr ); |
|
322 THTTPHdrVal val(valStr); |
|
323 aHeaders.SetFieldL( iSession.StringPool().StringF( aHdrField, RHTTPSession::GetTable()), val); |
|
324 CleanupStack::PopAndDestroy(); // valStr |
|
325 LOG("CClientEngine::SetHeaderL ,end"); |
|
326 } |
|
327 |
|
328 // ---------------------------------------------------------------------------- |
|
329 // CClientEngine::IssueHTTPGetL() |
|
330 // ---------------------------------------------------------------------------- |
|
331 void CClientEngine::IssueHTTPGetL( const TDesC8& aUri, const TConnectionOption aOption ) |
|
332 { |
|
333 LOG("CClientEngine::IssueHTTPGetL ,begin"); |
|
334 if ( IsActive() ) |
|
335 { |
|
336 // If there is some request in pending state |
|
337 // return with out further processing |
|
338 // Should we leave here !? |
|
339 LOG("Client engine is already active"); |
|
340 return; |
|
341 } |
|
342 |
|
343 delete iUri; |
|
344 iUri = NULL; |
|
345 |
|
346 iUri = aUri.AllocL(); |
|
347 |
|
348 // Create HTTP connection |
|
349 TRAPD( err, SetupConnectionL( aOption ) ); |
|
350 //If the Err is KErrNone, It will lead to RunL and |
|
351 //hence jump to the DoHTTPGetL() from there. |
|
352 |
|
353 if( err == KErrAlreadyExists ) |
|
354 { |
|
355 DoHTTPGetL(); |
|
356 } |
|
357 else if( err != KErrNone ) |
|
358 { |
|
359 LOG("Connection failure. Leaving."); |
|
360 iObserver.ClientEvent( EHttpConnectionFailure ); |
|
361 User::Leave(err); |
|
362 } |
|
363 iEngineState = EGet; |
|
364 LOG("CClientEngine::IssueHTTPGetL ,end"); |
|
365 } |
|
366 |
|
367 // ---------------------------------------------------------------------------- |
|
368 // CClientEngine::DoHTTPGetL() |
|
369 // ---------------------------------------------------------------------------- |
|
370 void CClientEngine::DoHTTPGetL() |
|
371 { |
|
372 LOG("CClientEngine::DoHTTPGetL ,begin"); |
|
373 // Parse string to URI (as defined in RFC2396) |
|
374 TUriParser8 uri; |
|
375 uri.Parse( *iUri ); |
|
376 |
|
377 // Get request method string for HTTP GET |
|
378 RStringF method = iSession.StringPool().StringF( HTTP::EGET,RHTTPSession::GetTable() ); |
|
379 |
|
380 // Open transaction with previous method and parsed uri. This class will |
|
381 // receive transaction events in MHFRunL and MHFRunError. |
|
382 iTransaction = iSession.OpenTransactionL( uri, *this, method ); |
|
383 iTransactionOpen = ETrue; |
|
384 |
|
385 // Set headers for request; user agent and accepted content type |
|
386 RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); |
|
387 SetHeaderL( hdr, HTTP::EUserAgent, KUserAgent ); |
|
388 SetHeaderL( hdr, HTTP::EAccept, KAccept ); |
|
389 |
|
390 // Submit the transaction. After this the framework will give transaction |
|
391 // events via MHFRunL and MHFRunError. |
|
392 iTransaction.SubmitL(); |
|
393 |
|
394 iObserver.ClientEvent( EHttpConnecting ); |
|
395 LOG("CClientEngine::DoHTTPGetL ,end"); |
|
396 } |
|
397 |
|
398 // ---------------------------------------------------------------------------- |
|
399 // CClientEngine::CancelTransaction() |
|
400 // ---------------------------------------------------------------------------- |
|
401 void CClientEngine::CancelTransaction() |
|
402 { |
|
403 LOG("CClientEngine::CancelTransaction ,begin"); |
|
404 iEngineState = EIdle; |
|
405 delete iUri; |
|
406 iUri = NULL; |
|
407 |
|
408 // Close() also cancels transaction (Cancel() can also be used but |
|
409 // resources allocated by transaction must be still freed with Close()) |
|
410 if( iTransactionOpen ) |
|
411 { |
|
412 iTransaction.Close(); |
|
413 iTransactionOpen = EFalse; |
|
414 |
|
415 iObserver.ClientEvent( EHttpTxCancelled ); |
|
416 } |
|
417 LOG("CClientEngine::CancelTransaction ,end"); |
|
418 } |
|
419 |
|
420 // ---------------------------------------------------------------------------- |
|
421 // CClientEngine::MHFRunL() |
|
422 // ---------------------------------------------------------------------------- |
|
423 void CClientEngine::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent ) |
|
424 { |
|
425 LOG("CClientEngine::MHFRunL ,begin"); |
|
426 switch ( aEvent.iStatus ) |
|
427 { |
|
428 case THTTPEvent::EGotResponseHeaders: |
|
429 { |
|
430 // HTTP response headers have been received. Use |
|
431 // aTransaction.Response() to get the response. However, it's not |
|
432 // necessary to do anything with the response when this event occurs. |
|
433 iObserver.ClientEvent( EHttpHdrReceived ); |
|
434 break; |
|
435 } |
|
436 case THTTPEvent::EGotResponseBodyData: |
|
437 { |
|
438 // Part (or all) of response's body data received. Use |
|
439 // aTransaction.Response().Body()->GetNextDataPart() to get the actual |
|
440 // body data. |
|
441 |
|
442 // Get the body data supplier |
|
443 MHTTPDataSupplier* body = aTransaction.Response().Body(); |
|
444 TPtrC8 dataChunk; |
|
445 |
|
446 // GetNextDataPart() returns ETrue, if the received part is the last |
|
447 // one. |
|
448 TBool isLast = body->GetNextDataPart(dataChunk); |
|
449 iObserver.ClientBodyReceived(dataChunk); |
|
450 |
|
451 iObserver.ClientEvent( EHttpBytesReceieved ); |
|
452 |
|
453 // NOTE: isLast may not be ETrue even if last data part received. |
|
454 // (e.g. multipart response without content length field) |
|
455 // Use EResponseComplete to reliably determine when body is completely |
|
456 // received. |
|
457 if( isLast ) |
|
458 { |
|
459 iObserver.ClientEvent( EHttpBodyReceieved ); |
|
460 } |
|
461 // Always remember to release the body data. |
|
462 body->ReleaseData(); |
|
463 break; |
|
464 } |
|
465 case THTTPEvent::EResponseComplete: |
|
466 { |
|
467 // Indicates that header & body of response is completely received. |
|
468 // No further action here needed. |
|
469 |
|
470 iObserver.ClientEvent( EHttpTxCompleted ); |
|
471 break; |
|
472 } |
|
473 case THTTPEvent::ESucceeded: |
|
474 { |
|
475 // Indicates that transaction succeeded. |
|
476 iObserver.ClientEvent( EHttpTxSuccess ); |
|
477 // Transaction can be closed now. It's not needed anymore. |
|
478 aTransaction.Close(); |
|
479 iTransactionOpen = EFalse; |
|
480 break; |
|
481 } |
|
482 case THTTPEvent::EFailed: |
|
483 { |
|
484 // Transaction completed with failure. |
|
485 iObserver.ClientEvent( EHttpTxFailed ); |
|
486 aTransaction.Close(); |
|
487 iTransactionOpen = EFalse; |
|
488 break; |
|
489 } |
|
490 default: |
|
491 // There are more events in THTTPEvent, but they are not usually |
|
492 // needed. However, event status smaller than zero should be handled |
|
493 // correctly since it's error. |
|
494 { |
|
495 if ( aEvent.iStatus < 0 ) |
|
496 { |
|
497 iObserver.ClientEvent( EHttpConnectionFailure ); |
|
498 // Close the transaction on errors |
|
499 aTransaction.Close(); |
|
500 iTransactionOpen = EFalse; |
|
501 } |
|
502 break; |
|
503 } |
|
504 } |
|
505 LOG("CClientEngine::MHFRunL ,end"); |
|
506 } |
|
507 |
|
508 // ---------------------------------------------------------------------------- |
|
509 // CClientEngine::MHFRunError() |
|
510 // ---------------------------------------------------------------------------- |
|
511 TInt CClientEngine::MHFRunError( TInt /*aError*/, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/ ) |
|
512 { |
|
513 LOG("CClientEngine::MHFRunError ,begin"); |
|
514 // Just notify about the error and return KErrNone. |
|
515 CloseConnection(); |
|
516 iObserver.ClientEvent(EHttpMhfRunError); |
|
517 return KErrNone; |
|
518 } |
|
519 |
|
520 // ---------------------------------------------------------------------------- |
|
521 // CClientEngine::PreferredCarrierAvailable() |
|
522 // ---------------------------------------------------------------------------- |
|
523 void CClientEngine::PreferredCarrierAvailable( TAccessPointInfo /*aOldAPInfo*/, |
|
524 TAccessPointInfo /*aNewAPInfo*/, |
|
525 TBool /*aIsUpgrade*/, |
|
526 TBool aIsSeamless ) |
|
527 { |
|
528 LOG("CClientEngine::PreferredCarrierAvailable ,begin"); |
|
529 if( !aIsSeamless && iMobility) |
|
530 { |
|
531 iMobility->MigrateToPreferredCarrier(); |
|
532 } |
|
533 LOG("CClientEngine::PreferredCarrierAvailable ,end"); |
|
534 } |
|
535 |
|
536 // ---------------------------------------------------------------------------- |
|
537 // CClientEngine::NewCarrierActive() |
|
538 // ---------------------------------------------------------------------------- |
|
539 void CClientEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, |
|
540 TBool aIsSeamless ) |
|
541 { |
|
542 LOG("CClientEngine::NewCarrierActive ,begin"); |
|
543 if( !aIsSeamless && iMobility) |
|
544 { |
|
545 iMobility->NewCarrierAccepted(); |
|
546 } |
|
547 LOG("CClientEngine::NewCarrierActive ,end"); |
|
548 } |
|
549 |
|
550 // ---------------------------------------------------------------------------- |
|
551 // CClientEngine::Error() |
|
552 // ---------------------------------------------------------------------------- |
|
553 void CClientEngine::Error(TInt /*aError*/) |
|
554 { |
|
555 LOG("CClientEngine::Error"); |
|
556 } |
|
557 |
|
558 // ---------------------------------------------------------------------------- |
|
559 // CClientEngine::DoCancel() |
|
560 // ---------------------------------------------------------------------------- |
|
561 void CClientEngine::DoCancel() |
|
562 { |
|
563 LOG("CClientEngine::DoCancel"); |
|
564 iConnection.Stop(); |
|
565 } |
|
566 |
|
567 // ---------------------------------------------------------------------------- |
|
568 // CClientEngine::DoCancel() |
|
569 // ---------------------------------------------------------------------------- |
|
570 TInt CClientEngine::RunError(TInt /*aError*/) |
|
571 { |
|
572 LOG("CClientEngine::RunError"); |
|
573 // Just notify about the error and return KErrNone. |
|
574 CloseConnection(); |
|
575 iObserver.ClientEvent( EHttpTxFailed ); |
|
576 return KErrNone; |
|
577 } |
|
578 // ---------------------------------------------------------------------------- |
|
579 // CClientEngine::RunL() |
|
580 // ---------------------------------------------------------------------------- |
|
581 void CClientEngine::RunL() |
|
582 { |
|
583 LOG1("CClientEngine::RunL: error is: %d\n", iStatus.Int() ); |
|
584 TInt statusCode = iStatus.Int(); |
|
585 if ( statusCode == KErrNone ) |
|
586 { |
|
587 // Connection done ok |
|
588 iConnectionSetupDone = ETrue; |
|
589 |
|
590 RStringPool strPool = iSession.StringPool(); |
|
591 |
|
592 // Remove first session properties just in case. |
|
593 RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); |
|
594 |
|
595 // Clear RConnection and Socket Server instances |
|
596 connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable())); |
|
597 connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable())); |
|
598 |
|
599 // Clear the proxy settings |
|
600 connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable())); |
|
601 connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable())); |
|
602 |
|
603 // RConnection and Socket Server |
|
604 connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, |
|
605 RHTTPSession::GetTable()), |
|
606 THTTPHdrVal (iSocketServ.Handle()) ); |
|
607 |
|
608 TInt connPtr1 = REINTERPRET_CAST(TInt, &iConnection); |
|
609 connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, |
|
610 RHTTPSession::GetTable() ), THTTPHdrVal (connPtr1) ); |
|
611 |
|
612 // Register for mobility API |
|
613 if(iMobility) |
|
614 { |
|
615 delete iMobility; |
|
616 iMobility = NULL ; |
|
617 } |
|
618 iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ); |
|
619 // Start selected HTTP action |
|
620 switch( iEngineState ) |
|
621 { |
|
622 case EIdle: |
|
623 { |
|
624 // |
|
625 CancelTransaction(); |
|
626 break; |
|
627 } |
|
628 case EGet: |
|
629 { |
|
630 DoHTTPGetL(); |
|
631 break; |
|
632 } |
|
633 }; |
|
634 } |
|
635 else |
|
636 { |
|
637 //handle error |
|
638 if ( statusCode == KErrPermissionDenied ) |
|
639 { |
|
640 iObserver.ClientEvent( EHttpAuthFailed ); |
|
641 } |
|
642 else |
|
643 { |
|
644 //Throw some general Transaction falure error! |
|
645 iObserver.ClientEvent( EHttpTxFailed ); |
|
646 } |
|
647 CloseConnection(); |
|
648 } |
|
649 LOG("CClientEngine::RunL ,end"); |
|
650 } |
|
651 |
|
652 // ---------------------------------------------------------------------------- |
|
653 // CClientEngine::SilentConnectionAllowed() |
|
654 // ---------------------------------------------------------------------------- |
|
655 TBool CClientEngine::SilentConnectionAllowed() |
|
656 { |
|
657 LOG("CClientEngine::SilentConnectionAllowed ,begin"); |
|
658 TBool retVal = EFalse; |
|
659 TRAPD(err, retVal = IsDataConnectionAskAlwaysL()); |
|
660 if(err == KErrNone) |
|
661 { |
|
662 // data connection is always ask... Silent connection is not allowed |
|
663 retVal = !retVal; |
|
664 } |
|
665 LOG1("CClientEngine::SilentConnectionAllowed ,end. Ret - %d", retVal); |
|
666 return retVal; |
|
667 } |
|
668 |
|
669 // End of file |
|
670 |