📄 class_c_web_client_engine.html
字号:
<tr><td valign="top"></td><td valign="top"><em>aTransaction,:</em> </td><td>Transaction, where the event occured. </td></tr> <tr><td valign="top"></td><td valign="top"><em>aEvent,:</em> </td><td>Occured event. </td></tr> </table></dl><p>Definition at line <a class="el" href="_web_client_engine_8cpp-source.html#l00311">311</a> of file <a class="el" href="_web_client_engine_8cpp-source.html">WebClientEngine.cpp</a>.<p>References <a class="el" href="class_m_web_client_observer.html#50e49839449e3e1580d570d67eb956e8">MWebClientObserver::ClientBodyReceived()</a>, <a class="el" href="class_m_web_client_observer.html#ba45586e3b6414e9a001aa362b83f6d3">MWebClientObserver::ClientEvent()</a>, <a class="el" href="_web_client_engine_8cpp-source.html#l00132">DumpRespHeadersL()</a>, <a class="el" href="_web_client_engine_8h-source.html#l00234">iApplicationUi</a>, <a class="el" href="_web_client_engine_8h-source.html#l00231">iObserver</a>, <a class="el" href="_web_client_engine_8h-source.html#l00233">iRunning</a>, and <a class="el" href="_web_client_app_u_i_8cpp-source.html#l00212">CWebClientAppUi::RemoveWaitDialogL()</a>.<div class="fragment"><pre class="fragment"><a name="l00313"></a>00313 {<a name="l00314"></a>00314 <a name="l00315"></a>00315 <span class="keywordflow">switch</span> ( aEvent.iStatus ) <a name="l00316"></a>00316 {<a name="l00317"></a>00317 <span class="keywordflow">case</span> THTTPEvent::EGotResponseHeaders:<a name="l00318"></a>00318 {<a name="l00319"></a>00319 <span class="comment">// HTTP response headers have been received. Use</span><a name="l00320"></a>00320 <span class="comment">// aTransaction.Response() to get the response. However, it's not</span><a name="l00321"></a>00321 <span class="comment">// necessary to do anything with the response when this event occurs.</span><a name="l00322"></a>00322 <a name="l00323"></a>00323 <span class="comment">// Get HTTP status code from header (e.g. 200)</span><a name="l00324"></a>00324 RHTTPResponse resp = aTransaction.Response();<a name="l00325"></a>00325 TInt status = resp.StatusCode();<a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="comment">// Get status text (e.g. "OK")</span><a name="l00328"></a>00328 TBuf<KMaxStatusTextLength> statusText;<a name="l00329"></a>00329 statusText.Copy( resp.StatusText().DesC() );<a name="l00330"></a>00330 <a name="l00331"></a>00331 <span class="comment">// Load a string from the resource file and add status and status text</span><a name="l00332"></a>00332 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_HEADER_RECEIVED,<a name="l00333"></a>00333 statusText, status );<a name="l00334"></a>00334 <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="l00335"></a>00335 CleanupStack::PopAndDestroy( textResource );<a name="l00336"></a>00336 <a name="l00337"></a>00337 <span class="comment">// Display header field names and value</span><a name="l00338"></a>00338 <a class="code" href="class_c_web_client_engine.html#f0720cc791fe8b50eff81b4af13e9f89">DumpRespHeadersL</a>( aTransaction );<a name="l00339"></a>00339 <a name="l00340"></a>00340 }<a name="l00341"></a>00341 <span class="keywordflow">break</span>;<a name="l00342"></a>00342 <a name="l00343"></a>00343 <span class="keywordflow">case</span> THTTPEvent::EGotResponseBodyData:<a name="l00344"></a>00344 {<a name="l00345"></a>00345 <span class="comment">// Part (or all) of response's body data received. Use </span><a name="l00346"></a>00346 <span class="comment">// aTransaction.Response().Body()->GetNextDataPart() to get the actual</span><a name="l00347"></a>00347 <span class="comment">// body data.</span><a name="l00348"></a>00348 <a name="l00349"></a>00349 <span class="comment">// Get the body data supplier</span><a name="l00350"></a>00350 MHTTPDataSupplier* body = aTransaction.Response().Body();<a name="l00351"></a>00351 TPtrC8 dataChunk;<a name="l00352"></a>00352 <a name="l00353"></a>00353 <span class="comment">// GetNextDataPart() returns ETrue, if the received part is the last </span><a name="l00354"></a>00354 <span class="comment">// one.</span><a name="l00355"></a>00355 TBool isLast = body->GetNextDataPart( dataChunk );<a name="l00356"></a>00356 <a class="code" href="class_c_web_client_engine.html#5598d19cc10719afd28055422087a200">iObserver</a>.<a class="code" href="class_m_web_client_observer.html#50e49839449e3e1580d570d67eb956e8">ClientBodyReceived</a>( dataChunk );<a name="l00357"></a>00357 <a name="l00358"></a>00358 <span class="comment">// Load a string from the resource file and add data length to string</span><a name="l00359"></a>00359 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_BODY_PART_RECEIVED,<a name="l00360"></a>00360 dataChunk.Length() );<a name="l00361"></a>00361 <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="l00362"></a>00362 CleanupStack::PopAndDestroy( textResource );<a name="l00363"></a>00363 <a name="l00364"></a>00364 <span class="comment">// NOTE: isLast may not be ETrue even if last data part received.</span><a name="l00365"></a>00365 <span class="comment">// (e.g. multipart response without content length field)</span><a name="l00366"></a>00366 <span class="comment">// Use EResponseComplete to reliably determine when body is completely</span><a name="l00367"></a>00367 <span class="comment">// received.</span><a name="l00368"></a>00368 <span class="keywordflow">if</span> (isLast)<a name="l00369"></a>00369 {<a name="l00370"></a>00370 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_BODY_RECEIVED );<a name="l00371"></a>00371 <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="l00372"></a>00372 CleanupStack::PopAndDestroy( textResource );<a name="l00373"></a>00373 }<a name="l00374"></a>00374 <a name="l00375"></a>00375 <span class="comment">// Always remember to release the body data.</span><a name="l00376"></a>00376 body->ReleaseData();<a name="l00377"></a>00377 }<a name="l00378"></a>00378 <span class="keywordflow">break</span>;<a name="l00379"></a>00379 <a name="l00380"></a>00380 <span class="keywordflow">case</span> THTTPEvent::EResponseComplete:<a name="l00381"></a>00381 {<a name="l00382"></a>00382 <span class="comment">// Indicates that header & body of response is completely received.</span><a name="l00383"></a>00383 <span class="comment">// No further action here needed.</span><a name="l00384"></a>00384 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_TRANSACTION_COMPLETE );<a name="l00385"></a>00385 <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="l00386"></a>00386 CleanupStack::PopAndDestroy( textResource );<a name="l00387"></a>00387 }<a name="l00388"></a>00388 <span class="keywordflow">break</span>;<a name="l00389"></a>00389 <a name="l00390"></a>00390 <span class="keywordflow">case</span> THTTPEvent::ESucceeded:<a name="l00391"></a>00391 {<a name="l00392"></a>00392 <span class="comment">// Indicates that transaction succeeded. </span><a name="l00393"></a>00393 HBufC* textResource = StringLoader::LoadLC( R_WEBCLIENT_TRANSACTION_SUCCEED );<a name="l00394"></a>00394 <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="l00395"></a>00395 CleanupStack::PopAndDestroy( textResource );<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 }</pre></div><p> </td> </tr></table><a class="anchor" name="4f19969440d49e831aaec230508b0a3c"></a><!-- doxytag: member="CWebClientEngine::MHFRunError" ref="4f19969440d49e831aaec230508b0a3c" args="(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">TInt CWebClientEngine::MHFRunError </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">TInt </td> <td class="mdname" nowrap> <em>aError</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>RHTTPTransaction </td> <td class="mdname" nowrap> <em>aTransaction</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>const THTTPEvent & </td> <td class="mdname" nowrap> <em>aEvent</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"><code> [private]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p><a class="el" href="class_c_web_client_engine.html#4f19969440d49e831aaec230508b0a3c">MHFRunError()</a> Called by framework when *leave* occurs in handling of transaction event. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>aError,:</em> </td><td>The leave code that occured. </td></tr> <tr><td valign="top"></td><td
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -