📄 _web_client_engine_8cpp-source.html
字号:
<a name="l00396"></a>00396 <span class="keywordflow">if</span> ( <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a> )<a name="l00397"></a>00397 <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a>-><a class="code" href="class_c_web_client_app_ui.html#53a2a56d9127e44f97de4d5ed7e6c132">RemoveWaitDialogL</a>();<a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="comment">// Transaction can be closed now. It's not needed anymore.</span><a name="l00400"></a>00400 aTransaction.Close();<a name="l00401"></a>00401 <a class="code" href="class_c_web_client_engine.html#d19da1539625146ffaa8979ee6ced8c3">iRunning</a> = EFalse;<a name="l00402"></a>00402 }<a name="l00403"></a>00403 <span class="keywordflow">break</span>;<a name="l00404"></a>00404 <a name="l00405"></a>00405 <span class="keywordflow">case</span> THTTPEvent::EFailed:<a name="l00406"></a>00406 {<a name="l00407"></a>00407 <span class="comment">// Transaction completed with failure. </span><a name="l00408"></a>00408 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_TRANSACTION_FAILED );<a name="l00409"></a>00409 <a class="code" href="class_c_web_client_engine.html#5598d19cc10719afd28055422087a200">iObserver</a>.<a class="code" href="class_m_web_client_observer.html#ba45586e3b6414e9a001aa362b83f6d3">ClientEvent</a>( *textResource );<a name="l00410"></a>00410 CleanupStack::PopAndDestroy( textResource );<a name="l00411"></a>00411 <span class="keywordflow">if</span> ( <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a> )<a name="l00412"></a>00412 <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a>-><a class="code" href="class_c_web_client_app_ui.html#53a2a56d9127e44f97de4d5ed7e6c132">RemoveWaitDialogL</a>();<a name="l00413"></a>00413 aTransaction.Close();<a name="l00414"></a>00414 <a class="code" href="class_c_web_client_engine.html#d19da1539625146ffaa8979ee6ced8c3">iRunning</a> = EFalse;<a name="l00415"></a>00415 }<a name="l00416"></a>00416 <span class="keywordflow">break</span>;<a name="l00417"></a>00417 <a name="l00418"></a>00418 <span class="keywordflow">default</span>:<a name="l00419"></a>00419 <span class="comment">// There are more events in THTTPEvent, but they are not usually </span><a name="l00420"></a>00420 <span class="comment">// needed. However, event status smaller than zero should be handled </span><a name="l00421"></a>00421 <span class="comment">// correctly since it's error.</span><a name="l00422"></a>00422 {<a name="l00423"></a>00423 HBufC* textResource;<a name="l00424"></a>00424 <span class="keywordflow">if</span> ( aEvent.iStatus < 0 )<a name="l00425"></a>00425 {<a name="l00426"></a>00426 <span class="comment">// Load a string from the resource file and add status to string</span><a name="l00427"></a>00427 textResource = StringLoader::LoadLC( R_WEBCLIENT_TRANSACTION_ERROR,<a name="l00428"></a>00428 aEvent.iStatus );<a name="l00429"></a>00429 <span class="keywordflow">if</span> ( <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a> )<a name="l00430"></a>00430 <a class="code" href="class_c_web_client_engine.html#6da7cfd219226594e04b0bf1b29cd50d">iApplicationUi</a>-><a class="code" href="class_c_web_client_app_ui.html#53a2a56d9127e44f97de4d5ed7e6c132">RemoveWaitDialogL</a>();<a name="l00431"></a>00431 <span class="comment">// Just close the transaction on errors</span><a name="l00432"></a>00432 aTransaction.Close();<a name="l00433"></a>00433 <a class="code" href="class_c_web_client_engine.html#d19da1539625146ffaa8979ee6ced8c3">iRunning</a> = EFalse;<a name="l00434"></a>00434 } <span class="keywordflow">else</span> {<a name="l00435"></a>00435 <span class="comment">// Other events are not errors (e.g. permanent and temporary redirections)</span><a name="l00436"></a>00436 textResource = StringLoader::LoadLC( R_WEBCLIENT_UNRECOGNISED_EVENT,<a name="l00437"></a>00437 aEvent.iStatus );<a name="l00438"></a>00438 }<a name="l00439"></a>00439 <a class="code" href="class_c_web_client_engine.html#5598d19cc10719afd28055422087a200">iObserver</a>.<a class="code" href="class_m_web_client_observer.html#ba45586e3b6414e9a001aa362b83f6d3">ClientEvent</a>( *textResource );<a name="l00440"></a>00440 CleanupStack::PopAndDestroy( textResource );<a name="l00441"></a>00441 }<a name="l00442"></a>00442 <span class="keywordflow">break</span>;<a name="l00443"></a>00443 }<a name="l00444"></a>00444 }<a name="l00445"></a>00445 <a name="l00446"></a>00446 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00447"></a>00447 <span class="comment">// CWebClientEngine::MHFRunError()</span><a name="l00448"></a>00448 <span class="comment">// Inherited from MHTTPTransactionCallback</span><a name="l00449"></a>00449 <span class="comment">// Called by framework when *leave* occurs in handling of transaction event.</span><a name="l00450"></a>00450 <span class="comment">// These errors must be handled, or otherwise HTTP-CORE 6 panic is thrown.</span><a name="l00451"></a>00451 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00452"></a>00452 <span class="comment">//</span><a name="l00453"></a><a class="code" href="class_c_web_client_engine.html#4f19969440d49e831aaec230508b0a3c">00453</a> TInt <a class="code" href="class_c_web_client_engine.html#4f19969440d49e831aaec230508b0a3c">CWebClientEngine::MHFRunError</a>( TInt aError, <a name="l00454"></a>00454 RHTTPTransaction <span class="comment">/*aTransaction*/</span>, <a name="l00455"></a>00455 <span class="keyword">const</span> THTTPEvent& <span class="comment">/*aEvent*/</span>)<a name="l00456"></a>00456 {<a name="l00457"></a>00457 <span class="comment">// Handle error and return KErrNone.</span><a name="l00458"></a>00458 TRAPD( err, <a class="code" href="class_c_web_client_engine.html#2f2fdeb2077849ca331b415db028feba">HandleRunErrorL</a>( aError ) );<a name="l00459"></a>00459 <span class="keywordflow">if</span>( err )<a name="l00460"></a>00460 Panic( EClientEngine );<a name="l00461"></a>00461 <span class="keywordflow">return</span> KErrNone;<a name="l00462"></a>00462 }<a name="l00463"></a>00463 <a name="l00464"></a>00464 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00465"></a>00465 <span class="comment">// CWebClientEngine::GetCredentialsL()</span><a name="l00466"></a>00466 <span class="comment">//</span><a name="l00467"></a>00467 <span class="comment">// Inherited from MHTTPAuthenticationCallback</span><a name="l00468"></a>00468 <span class="comment">// Called by framework when we requested authenticated page and framework </span><a name="l00469"></a>00469 <span class="comment">// needs to know username and password.</span><a name="l00470"></a>00470 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00471"></a><a class="code" href="class_c_web_client_engine.html#ffb00f6bfbe7b1f8512c8f8a948bc765">00471</a> TBool <a class="code" href="class_c_web_client_engine.html#ffb00f6bfbe7b1f8512c8f8a948bc765">CWebClientEngine::GetCredentialsL</a>( <span class="keyword">const</span> TUriC8& <span class="comment">/*aUri*/</span>,<a name="l00472"></a>00472 RString aRealm, <a name="l00473"></a>00473 RStringF <span class="comment">/*aAuthenticationType*/</span>,<a name="l00474"></a>00474 RString& aUsername, <a name="l00475"></a>00475 RString& aPassword) <a name="l00476"></a>00476 {<a name="l00477"></a>00477 <span class="comment">// aURI, aReal and aAuthenticationType are informational only. We only need </span><a name="l00478"></a>00478 <span class="comment">// to set aUsername and aPassword and return ETrue, if aUsername and </span><a name="l00479"></a>00479 <span class="comment">// aPassword are provided by user.</span><a name="l00480"></a>00480 <a name="l00481"></a>00481 <span class="comment">// Query user name and password</span><a name="l00482"></a>00482 TBuf<KMaxUserNameLength> userName;<a name="l00483"></a>00483 TBuf<KMaxPasswordLength> password;<a name="l00484"></a>00484 CAknMultiLineDataQueryDialog* dlg = <a name="l00485"></a>00485 CAknMultiLineDataQueryDialog::NewL( userName, password );<a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="keywordflow">if</span> ( !dlg->ExecuteLD( R_WEBCLIENT_DIALOG_USER_PASSWORD_QUERY ))<a name="l00488"></a>00488 <span class="keywordflow">return</span> EFalse; <span class="comment">// No credentials given; must return EFalse</span><a name="l00489"></a>00489 <a name="l00490"></a>00490 <span class="comment">// Set aUsername and aPassword</span><a name="l00491"></a>00491 TBuf8<KMaxUserNameLength> temp;<a name="l00492"></a>00492 temp.Copy( userName );<a name="l00493"></a>00493 TRAPD( err, aUsername = aRealm.Pool().OpenStringL( temp ));<a name="l00494"></a>00494 <span class="keywordflow">if</span> ( !err ) <a name="l00495"></a>00495 {<a name="l00496"></a>00496 temp.Copy( password );<a name="l00497"></a>00497 TRAP( err, aPassword = aRealm.Pool().OpenStringL( temp ));<a name="l00498"></a>00498 <span class="keywordflow">if</span> ( !err ) <span class="keywordflow">return</span> ETrue;<a name="l00499"></a>00499 }<a name="l00500"></a>00500 <a name="l00501"></a>00501 <span class="comment">// Return ETrue if user has given credentials (username and password), </span><a name="l00502"></a>00502 <span class="comment">// otherwise EFlase</span><a name="l00503"></a>00503 <span class="keywordflow">return</span> EFalse;<a name="l00504"></a>00504 }<a name="l00505"></a>00505 </pre></div><hr><table x-use-null-cells style="x-cell-content-align: top; width: 100%; border-spacing: 0px; border-spacing: 0px;" cellspacing=0 width=100%> <col style="width: 50%;"> <col style="width: 50%;"> <tr style="x-cell-content-align: top;" valign=top> <td style="width: 50%; padding-right: 10px; padding-left: 10px; border-right-style: None; border-left-style: None; border-top-style: None; border-bottom-style: None;" width=50%> <p style="font-family: Arial;"><small style="font-size: smaller;">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -