00001 "-//W3C//DTD HTML 4.0 Transitional//EN"> 00002 00003 00004 00005 "Content-Type" content="text/html;charset=iso-8859-1"> 00006csasyncrequesthandler.cpp Source File 00007 "style.css" rel="stylesheet" type="text/css"> 00008 00009 00010
"100%" height="1">"2" color="#000000" face="Arial, Helvetica, sans-serif">
00012 S60 5th Edition SDK Example Applications Guide |
class="fragment">"l00001">00001 class="comment">/* 00021 00002 * ============================================================================== 00022 00003 * Name : csasyncrequesthandler.cpp 00023 00004 * Part of : CSAsync 00024 00005 * Interface : 00025 00006 * Description : 00026 00007 * Version : 00027 00008 * 00028 00009 * Copyright (c) 2004-2006 Nokia Corporation. 00029 00010 * This material, including documentation and any related 00030 00011 * computer programs, is protected by copyright controlled by 00031 00012 * Nokia Corporation. 00032 00013 * ============================================================================== 00033 00014 */ 00034 "l00015">00015 00035 "l00016">00016 class="comment">// INCLUDE FILES 00036 "l00017">00017 class="preprocessor">#include <e32svr.h> 00037 "l00018">00018 00038 "l00019">00019 class="preprocessor">#include "CSAsync.pan" 00039 "l00020">00020 class="preprocessor">#include "CSAsyncRequestHandler.h" 00040 "l00021">00021 class="preprocessor">#include "ClientServerCommon.h" 00041 "l00022">00022 class="preprocessor">#include "AsyncTimeObserver.h" 00042 "l00023">00023 00043 "l00024">00024 class="comment">// ========================= MEMBER FUNCTIONS ================================== 00044 "l00025">00025 00045 "l00026">00026 class="comment">// ----------------------------------------------------------------------------- 00046 "l00027">00027 class="comment">// CCSAsyncRequestHandler::NewL() 00047 "l00028">00028 class="comment">// Two-phased constructor. 00048 "l00029">00029 class="comment">// ----------------------------------------------------------------------------- 00049 "l00030">class="code" href="class_c_c_s_async_request_handler.html#e27bf7140859a754f6f06c51dbbd1b12">00030 class="code" href="class_c_c_s_async_request_handler.html">CCSAsyncRequestHandler* class="code" href="class_c_c_s_async_request_handler.html#e27bf7140859a754f6f06c51dbbd1b12">CCSAsyncRequestHandler::NewL( 00050 "l00031">00031 class="code" href="class_m_async_time_observer.html">MAsyncTimeObserver& aObserver ) 00051 "l00032">00032 { 00052 "l00033">00033 class="code" href="class_c_c_s_async_request_handler.html">CCSAsyncRequestHandler* class="keyword">self = class="code" href="class_c_c_s_async_request_handler.html#aea906e05bc2fa2a15b3152501b0f12e">NewLC( aObserver ); 00053 "l00034">00034 CleanupStack::Pop( class="keyword">self ); 00054 "l00035">00035 class="keywordflow">return( self ) ; 00055 "l00036">00036 } 00056 "l00037">00037 00057 "l00038">00038 class="comment">// ----------------------------------------------------------------------------- 00058 "l00039">00039 class="comment">// CCSAsyncRequestHandler::NewLC() 00059 "l00040">00040 class="comment">// Two-phased constructor. 00060 "l00041">00041 class="comment">// ----------------------------------------------------------------------------- 00061 "l00042">class="code" href="class_c_c_s_async_request_handler.html#aea906e05bc2fa2a15b3152501b0f12e">00042 class="code" href="class_c_c_s_async_request_handler.html">CCSAsyncRequestHandler* class="code" href="class_c_c_s_async_request_handler.html#aea906e05bc2fa2a15b3152501b0f12e">CCSAsyncRequestHandler::NewLC( 00062 "l00043">00043 class="code" href="class_m_async_time_observer.html">MAsyncTimeObserver& aObserver ) 00063 "l00044">00044 { 00064 "l00045">00045 class="code" href="class_c_c_s_async_request_handler.html">CCSAsyncRequestHandler* class="keyword">self = 00065 "l00046">00046 class="keyword">new ( ELeave ) class="code" href="class_c_c_s_async_request_handler.html#7f4ba53fa1861a0a692566cdfa024cd4">CCSAsyncRequestHandler( aObserver ); 00066 "l00047">00047 CleanupStack::PushL( class="keyword">self ); 00067 "l00048">00048 class="keyword">self->ConstructL(); 00068 "l00049">00049 class="keywordflow">return class="keyword">self; 00069 "l00050">00050 } 00070 "l00051">00051 00071 "l00052">00052 class="comment">// ----------------------------------------------------------------------------- 00072 "l00053">00053 class="comment">// CCSAsyncRequestHandler::ConstructL() 00073 "l00054">00054 class="comment">// Symbian 2nd phase constructor can leave. 00074 "l00055">00055 class="comment">// ----------------------------------------------------------------------------- 00075 "l00056">00056 class="comment">// 00076 "l00057">class="code" href="class_c_c_s_async_request_handler.html#9ce34ba0b947863222da3c63d0481044">00057 class="keywordtype">void class="code" href="class_c_c_s_async_request_handler.html#9ce34ba0b947863222da3c63d0481044">CCSAsyncRequestHandler::ConstructL() 00077 "l00058">00058 { 00078 "l00059">00059 User::LeaveIfError( class="code" href="class_c_c_s_async_request_handler.html#d8033daa9b951c54149345b6871648bb">iSession.class="code" href="class_r_time_server_session.html#0a20867f2777f1db7349df290a5e6112">Connect() ); 00079 "l00060">00060 } 00080 "l00061">00061 00081 "l00062">00062 class="comment">// ----------------------------------------------------------------------------- 00082 "l00063">00063 class="comment">// CCSAsyncRequestHandler::CCSAsyncRequestHandler() 00083 "l00064">00064 class="comment">// C++ default constructor can NOT contain any code, that might leave. 00084 "l00065">00065 class="comment">// ----------------------------------------------------------------------------- 00085 "l00066">class="code" href="class_c_c_s_async_request_handler.html#7f4ba53fa1861a0a692566cdfa024cd4">00066 class="code" href="class_c_c_s_async_request_handler.html#7f4ba53fa1861a0a692566cdfa024cd4">CCSAsyncRequestHandler::CCSAsyncRequestHandler( class="code" href="class_m_async_time_observer.html">MAsyncTimeObserver& aObserver ) 00086 "l00067">00067 : CActive( EPriorityStandard ), class="code" href="class_c_c_s_async_request_handler.html#5598d19cc10719afd28055422087a200">iObserver( aObserver ) 00087 "l00068">00068 { 00088 "l00069">00069 CActiveScheduler::Add( class="keyword">this ); 00089 "l00070">00070 } 00090 "l00071">00071 00091 "l00072">00072 class="comment">// ----------------------------------------------------------------------------- 00092 "l00073">00073 class="comment">// CCSAsyncRequestHandler::~CCSAsyncRequestHandler() 00093 "l00074">00074 class="comment">// Destructor. 00094 "l00075">00075 class="comment">// ----------------------------------------------------------------------------- 00095 "l00076">00076 class="comment">// 00096 "l00077">class="code" href="class_c_c_s_async_request_handler.html#91aee909b7becabe937b696acc0c1590">00077 class="code" href="class_c_c_s_async_request_handler.html#91aee909b7becabe937b696acc0c1590">CCSAsyncRequestHandler::~CCSAsyncRequestHandler() 00097 "l00078">00078 { 00098 "l00079">00079 Cancel(); class="comment">// Causes call to DoCancel() 00099 "l00080">00080 class="code" href="class_c_c_s_async_request_handler.html#d8033daa9b951c54149345b6871648bb">iSession.Close(); 00100 "l00081">00081 } 00101 "l00082">00082 00102 "l00083">00083 class="comment">// ----------------------------------------------------------------------------- 00103 "l00084">00084 class="comment">// CCSAsyncRequestHandler::RequestTime() 00104 "l00085">00085 class="comment">// Sends a request to the server for an update to the time. 00105 "l00086">00086 class="comment">// ----------------------------------------------------------------------------- 00106 "l00087">00087 class="comment">// 00107 "l00088">class="code" href="class_c_c_s_async_request_handler.html#481d63e2f4e33b9cb8ed4680a965da25">00088 class="keywordtype">void class="code" href="class_c_c_s_async_request_handler.html#481d63e2f4e33b9cb8ed4680a965da25">CCSAsyncRequestHandler::RequestTime() 00108 "l00089">00089 { 00109 "l00090">00090 class="keywordflow">if ( !IsActive() ) 00110 "l00091">00091 { 00111 "l00092">00092 class="code" href="class_c_c_s_async_request_handler.html#d8033daa9b951c54149345b6871648bb">iSession.class="code" href="class_r_time_server_session.html#0e65b7c45b7af042183f1c5525cfcc1b">RequestTime( class="code" href="class_c_c_s_async_request_handler.html#ab88bd4e7e44b5e05aab3f182f76db1f">iTime, iStatus ); 00112 "l00093">00093 SetActive(); 00113 "l00094">00094 } 00114 "l00095">00095 } 00115 "l00096">00096 00116 "l00097">00097 class="comment">// ----------------------------------------------------------------------------- 00117 "l00098">00098 class="comment">// CCSAsyncRequestHandler::CancelRequest() 00118 "l00099">00099 class="comment">// Cancels an outstanding request. 00119 "l00100">00100 class="comment">// ----------------------------------------------------------------------------- 00120 "l00101">00101 class="comment">// 00121 "l00102">class="code" href="class_c_c_s_async_request_handler.html#63d7f6ab1c508b38c31d416e01f71a29">00102 class="keywordtype">void class="code" href="class_c_c_s_async_request_handler.html#63d7f6ab1c508b38c31d416e01f71a29">CCSAsyncRequestHandler::CancelRequest() 00122 "l00103">00103 { 00123 "l00104">00104 Cancel() ; class="comment">// Causes call to DoCancel() 00124 "l00105">00105 } 00125 "l00106">00106 00126 "l00107">00107 class="comment">// ----------------------------------------------------------------------------- 00127 "l00108">00108 class="comment">// CCSAsyncRequestHandler::RunL() 00128 "l00109">00109 class="comment">// Invoked to handle responses from the server. 00129 "l00110">00110 class="comment">// ----------------------------------------------------------------------------- 00130 "l00111">00111 class="comment">// 00131 "l00112">class="code" href="class_c_c_s_async_request_handler.html#98dcd20e4dd117488a6a90dadd4dfac5">00112 class="keywordtype">void class="code" href="class_c_c_s_async_request_handler.html#98dcd20e4dd117488a6a90dadd4dfac5">CCSAsyncRequestHandler::RunL() 00132 "l00113">00113 { 00133 "l00114">00114 class="keywordflow">switch ( iStatus.Int() ) 00134 "l00115">00115 { 00135 "l00116">00116 class="keywordflow">case ETimeServRequestTimeComplete: 00136 "l00117">00117 class="comment">// The server has completed the request, signalled the client 00137 "l00118">00118 class="comment">// thread and the clients active scheduler runs the active object. 00138 "l00119">00119 class="comment">// Now do something with it 00139 "l00120">00120 class="code" href="class_c_c_s_async_request_handler.html#5598d19cc10719afd28055422087a200">iObserver.class="code" href="class_m_async_time_observer.html#0f7e397559bb14d521856cfb636830df">HandleTimeUpdate(); 00140 "l00121">00121 class="code" href="class_c_c_s_async_request_handler.html#481d63e2f4e33b9cb8ed4680a965da25">RequestTime(); class="comment">// Add this line to make the clock keep ticking 00141 "l00122">00122 break ; 00142 "l00123">00123 00143 "l00124">00124 class="keywordflow">case KErrCancel: 00144 "l00125">00125 class="comment">// The request was canceled 00145 "l00126">00126 break ; 00146 "l00127">00127 00147 "l00128">00128 class="keywordflow">case KErrNotReady: 00148 "l00129">00129 class="comment">// We requested a new time before completing the previous request 00149 "l00130">00130 class="keywordflow">default: 00150 "l00131">00131 User::Panic( KCSAsyncClient, ECSAsyncBadState ); class="comment">// Unexpected error 00151 "l00132">00132 class="keywordflow">break; 00152 "l00133">00133 } 00153 "l00134">00134 } 00154 "l00135">00135 00155 "l00136">00136 class="comment">// ----------------------------------------------------------------------------- 00156 "l00137">00137 class="comment">// CCSAsyncRequestHandler::DoCancel() 00157 "l00138">00138 class="comment">// Cancels any outstanding operation. 00158 "l00139">00139 class="comment">// ----------------------------------------------------------------------------- 00159 "l00140">00140 class="comment">// 00160 "l00141">class="code" href="class_c_c_s_async_request_handler.html#79737b00f2b6a07492c7caf4220c6691">00141 class="keywordtype">void class="code" href="class_c_c_s_async_request_handler.html#79737b00f2b6a07492c7caf4220c6691">CCSAsyncRequestHandler::DoCancel() 00161 "l00142">00142 { 00162 "l00143">00143 class="code" href="class_c_c_s_async_request_handler.html#d8033daa9b951c54149345b6871648bb">iSession.class="code" href="class_r_time_server_session.html#52a5f2cddd36f215fea9c11e32ab88b8">CancelRequestTime(); 00163 "l00144">00144 } 00164 "l00145">00145 00165 "l00146">00146 class="comment">// ----------------------------------------------------------------------------- 00166 "l00147">00147 class="comment">// CCSAsyncRequestHandler::Time() const 00167 "l00148">00148 class="comment">// Gets a copy of the last time received from the server. 00168 "l00149">00149 class="comment">// ----------------------------------------------------------------------------- 00169 "l00150">00150 class="comment">// 00170 "l00151">class="code" href="class_c_c_s_async_request_handler.html#abd5ca40d94b3e8941d79e5362c038b2">00151 TTime class="code" href="class_c_c_s_async_request_handler.html#abd5ca40d94b3e8941d79e5362c038b2">CCSAsyncRequestHandler::Time()class="keyword"> const 00171 "l00152">00152 class="keyword"> { 00172 "l00153">00153 class="keywordflow">return class="code" href="class_c_c_s_async_request_handler.html#ab88bd4e7e44b5e05aab3f182f76db1f">iTime; 00173 "l00154">00154 } 00174 "l00155">00155 00175 "l00156">00156 class="comment">// End of File 00176
"width: 50%;
00191 padding-right: 10px;
00192 padding-left: 10px;
00193 border-right-style: None;
00194 border-left-style: None;
00195 border-top-style: None;
00196 border-bottom-style: None;"
00197 width=50%>
00198 "font-family: Arial;">"font-size: smaller;"> Nokia 2009 |
00199 "width: 50%;
00200 padding-right: 10px;
00201 padding-left: 10px;
00202 border-top-style: None;
00203 border-bottom-style: None;
00204 border-right-style: None;"
00205 width=50%>
00206 "text-align: right; margin-right: -4px;"
00207 align=right>"font-weight: bold;">"#Top"
00208 title="Back to top"> |