Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/cmtpexampledprequestprocessor_8cpp_source.html
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 6 43e37759235e
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>TB9.2 Example Applications: examples/RemoteConn/MtpDataProviderExample/src/cmtpexampledprequestprocessor.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2 -->
<h1>examples/RemoteConn/MtpDataProviderExample/src/cmtpexampledprequestprocessor.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of &quot;Eclipse Public License v1.0&quot;</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL &quot;http://www.eclipse.org/legal/epl-v10.html&quot;.</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description:</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;mtp/mtpprotocolconstants.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;mtp/tmtptyperequest.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;mtp/mmtpdataproviderframework.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;mtp/tmtptypeevent.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;mtp/mmtpconnection.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;mtp/mmtpobjectmgr.h&gt;</span>
<a name="l00022"></a>00022  
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;cmtpexampledprequestprocessor.h&quot;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 
<a name="l00034"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#aeec08e4c2bc425fc9284645a98850d9a">00034</a> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#aeec08e4c2bc425fc9284645a98850d9a">CMTPExampleDpRequestProcessor::CMTPExampleDpRequestProcessor</a>(
<a name="l00035"></a>00035                                                                                         MMTPDataProviderFramework&amp; aFramework,                                                                                  
<a name="l00036"></a>00036                                                                                         MMTPConnection&amp; aConnection,
<a name="l00037"></a>00037                                                                                         TInt aElementCount,
<a name="l00038"></a>00038                                                                                         <span class="keyword">const</span> TMTPRequestElementInfo* aElements)
<a name="l00039"></a>00039         :iFramework(aFramework),
<a name="l00040"></a>00040         iConnection(aConnection),
<a name="l00041"></a>00041         iElementCount(aElementCount),
<a name="l00042"></a>00042         iElements(aElements)
<a name="l00043"></a>00043         {
<a name="l00044"></a>00044         
<a name="l00045"></a>00045         }
<a name="l00046"></a>00046 
<a name="l00050"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a683cf05e8b6aa42d6646b893b3680597">00050</a> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a683cf05e8b6aa42d6646b893b3680597">CMTPExampleDpRequestProcessor::~CMTPExampleDpRequestProcessor</a>()
<a name="l00051"></a>00051         {
<a name="l00052"></a>00052         }
<a name="l00056"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#acf6a9caa24bebc0a9936ad1e10c48c90">00056</a>  <span class="keywordtype">void</span> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#acf6a9caa24bebc0a9936ad1e10c48c90">CMTPExampleDpRequestProcessor::Release</a>()
<a name="l00057"></a>00057      {
<a name="l00058"></a>00058      <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00059"></a>00059     }
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 
<a name="l00068"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a23bd6f51aef2507ff9b1466c5744cd47">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a23bd6f51aef2507ff9b1466c5744cd47">CMTPExampleDpRequestProcessor::SendResponseL</a>(TMTPResponseCode aResponseCode, TInt aParameterCount, TUint32* aParams)
<a name="l00069"></a>00069         {   
<a name="l00070"></a>00070         iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode);
<a name="l00071"></a>00071                     
<a name="l00072"></a>00072     iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, iSessionId);
<a name="l00073"></a>00073         
<a name="l00074"></a>00074         iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, iTransactionCode);
<a name="l00075"></a>00075    
<a name="l00076"></a>00076     TInt i = 0; 
<a name="l00077"></a>00077         <span class="keywordflow">for</span>(i = 0; i &lt; aParameterCount; i++)
<a name="l00078"></a>00078                 {
<a name="l00079"></a>00079                 iResponse.SetUint32(TMTPTypeResponse::EResponseParameter1 + i, aParams[i]);
<a name="l00080"></a>00080                 }
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         i += TMTPTypeResponse::EResponseParameter1;
<a name="l00083"></a>00083         <span class="keywordflow">while</span>(i &lt;= TMTPTypeResponse::EResponseParameter5)
<a name="l00084"></a>00084             {
<a name="l00085"></a>00085             iResponse.SetUint32(i, KMTPNotSpecified32);
<a name="l00086"></a>00086             i++;
<a name="l00087"></a>00087             }
<a name="l00088"></a>00088         iFramework.SendResponseL(iResponse, *iRequest, iConnection);
<a name="l00089"></a>00089         }
<a name="l00094"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a1d115a581c794e3fd51279897f5d93c6">00094</a>  <span class="keyword">const</span> TMTPTypeRequest&amp; <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a1d115a581c794e3fd51279897f5d93c6">CMTPExampleDpRequestProcessor::Request</a>()<span class="keyword"> const</span>
<a name="l00095"></a>00095 <span class="keyword">     </span>{ 
<a name="l00096"></a>00096      <span class="keywordflow">return</span> *iRequest;
<a name="l00097"></a>00097      }
<a name="l00098"></a>00098      
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 
<a name="l00104"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a99d04bc3cd40550b4c67d3164b68ee7c">00104</a> <span class="keywordtype">void</span> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a99d04bc3cd40550b4c67d3164b68ee7c">CMTPExampleDpRequestProcessor::CompleteRequestL</a>()
<a name="l00105"></a>00105     {
<a name="l00106"></a>00106         iFramework.TransactionCompleteL(*iRequest, iConnection);
<a name="l00107"></a>00107         }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 
<a name="l00116"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a4b10e786885316ab9cc41d0b139469ff">00116</a> TBool <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a4b10e786885316ab9cc41d0b139469ff">CMTPExampleDpRequestProcessor::HandleRequestL</a>(<span class="keyword">const</span> TMTPTypeRequest&amp; aRequest, TMTPTransactionPhase aPhase)
<a name="l00117"></a>00117         {
<a name="l00118"></a>00118         iRequest = &amp;aRequest;
<a name="l00119"></a>00119         TBool result = EFalse;
<a name="l00120"></a>00120         <span class="keywordflow">switch</span>(aPhase)
<a name="l00121"></a>00121                 {
<a name="l00122"></a>00122                 <span class="keywordflow">case</span> ERequestPhase:             
<a name="l00123"></a>00123                     ExtractSessionTransactionId();
<a name="l00124"></a>00124                     ServiceL(); 
<a name="l00125"></a>00125                         <span class="keywordflow">break</span>;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127                 <span class="keywordflow">case</span> EResponsePhase:
<a name="l00128"></a>00128                         result = <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a8805aaa8addc025229322dbe92ddefc5">DoHandleResponsePhaseL</a>();      
<a name="l00129"></a>00129                         <span class="keywordflow">break</span>;
<a name="l00130"></a>00130                         
<a name="l00131"></a>00131                 <span class="keywordflow">case</span> ECompletingPhase:
<a name="l00132"></a>00132                         result = <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a499d04d039da527a915bdbc58b3231b7">DoHandleCompletingPhaseL</a>();
<a name="l00133"></a>00133                         <span class="keywordflow">break</span>;
<a name="l00134"></a>00134                 }
<a name="l00135"></a>00135         <span class="keywordflow">return</span> result;  
<a name="l00136"></a>00136         }
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 
<a name="l00143"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#abe6425e6f991aec33e8fff1b8933e0db">00143</a> MMTPConnection&amp; <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#abe6425e6f991aec33e8fff1b8933e0db">CMTPExampleDpRequestProcessor::Connection</a>()<span class="keyword"> const</span>
<a name="l00144"></a>00144 <span class="keyword">     </span>{
<a name="l00145"></a>00145      <span class="keywordflow">return</span> iConnection;
<a name="l00146"></a>00146      }
<a name="l00147"></a>00147 
<a name="l00152"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a11dd2dba67a1c2d87cf26c97c7458af9">00152</a> TUint32 <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a11dd2dba67a1c2d87cf26c97c7458af9">CMTPExampleDpRequestProcessor::SessionId</a>()
<a name="l00153"></a>00153     {
<a name="l00154"></a>00154     <span class="keywordflow">return</span> iSessionId;
<a name="l00155"></a>00155     }
<a name="l00156"></a>00156         
<a name="l00161"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a8805aaa8addc025229322dbe92ddefc5">00161</a> TBool <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a8805aaa8addc025229322dbe92ddefc5">CMTPExampleDpRequestProcessor::DoHandleResponsePhaseL</a>()
<a name="l00162"></a>00162         {
<a name="l00163"></a>00163         TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : EMTPRespCodeOK);
<a name="l00164"></a>00164         <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a23bd6f51aef2507ff9b1466c5744cd47">SendResponseL</a>(responseCode);
<a name="l00165"></a>00165         <span class="keywordflow">return</span> EFalse;
<a name="l00166"></a>00166         }
<a name="l00167"></a>00167 
<a name="l00172"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a499d04d039da527a915bdbc58b3231b7">00172</a> TBool <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a499d04d039da527a915bdbc58b3231b7">CMTPExampleDpRequestProcessor::DoHandleCompletingPhaseL</a>()
<a name="l00173"></a>00173         {
<a name="l00174"></a>00174         <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a99d04bc3cd40550b4c67d3164b68ee7c">CompleteRequestL</a>();
<a name="l00175"></a>00175         <span class="keywordflow">return</span> ETrue;   
<a name="l00176"></a>00176         }
<a name="l00177"></a>00177 
<a name="l00181"></a>00181 <span class="keywordtype">void</span> CMTPExampleDpRequestProcessor::ExtractSessionTransactionId()
<a name="l00182"></a>00182         {    
<a name="l00183"></a>00183         iSessionId = iRequest-&gt;Uint32(TMTPTypeRequest::ERequestSessionID);    
<a name="l00184"></a>00184         iTransactionCode = iRequest-&gt;Uint32(TMTPTypeRequest::ERequestTransactionID);            
<a name="l00185"></a>00185         }
<a name="l00186"></a>00186 
<a name="l00187"></a>00187 
<a name="l00194"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#ae4b93e6afe48992ee85cbc944fffb6b6">00194</a> TBool <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a1e0ed8c9f87cd095914b518d6fa18f51">CMTPExampleDpRequestProcessor::Match</a>(<span class="keyword">const</span> TMTPTypeEvent&amp; aEvent, MMTPConnection&amp; aConnection)<span class="keyword"> const</span>
<a name="l00195"></a>00195 <span class="keyword">    </span>{
<a name="l00196"></a>00196 
<a name="l00197"></a>00197     TUint32 eventSessionId = aEvent.Uint32(TMTPTypeEvent::EEventSessionID);
<a name="l00198"></a>00198     TUint32 eventTransactionCode = aEvent.Uint32(TMTPTypeEvent::EEventTransactionID);
<a name="l00199"></a>00199     
<a name="l00200"></a>00200     TBool result = EFalse;
<a name="l00201"></a>00201     <span class="keywordflow">if</span>(iSessionId == eventSessionId &amp;&amp; 
<a name="l00202"></a>00202         iTransactionCode == eventTransactionCode &amp;&amp;
<a name="l00203"></a>00203         &amp;iConnection == &amp;aConnection)
<a name="l00204"></a>00204         {
<a name="l00205"></a>00205         result = ETrue;
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207     <span class="keywordflow">return</span> result;  
<a name="l00208"></a>00208     }
<a name="l00209"></a>00209  
<a name="l00216"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a1e0ed8c9f87cd095914b518d6fa18f51">00216</a> TBool <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a1e0ed8c9f87cd095914b518d6fa18f51">CMTPExampleDpRequestProcessor::Match</a>(<span class="keyword">const</span> TMTPTypeRequest&amp; aRequest, MMTPConnection&amp; aConnection)<span class="keyword"> const</span>
<a name="l00217"></a>00217 <span class="keyword">    </span>{
<a name="l00218"></a>00218     TBool result = ((&amp;aRequest == iRequest) &amp;&amp; (&amp;iConnection == &amp;aConnection));
<a name="l00219"></a>00219     <span class="keywordflow">return</span> result;      
<a name="l00220"></a>00220     }
<a name="l00221"></a>00221  
<a name="l00226"></a><a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a515f5fdd80df202e02b5116dc7d10666">00226</a> <span class="keywordtype">void</span> <a class="code" href="class_c_m_t_p_example_dp_request_processor.html#a515f5fdd80df202e02b5116dc7d10666">CMTPExampleDpRequestProcessor::HandleEventL</a>(<span class="keyword">const</span> TMTPTypeEvent&amp; aEvent)
<a name="l00227"></a>00227       {
<a name="l00228"></a>00228       TUint16 eventCode = aEvent.Uint16(TMTPTypeEvent::EEventCode);
<a name="l00229"></a>00229       iCancelled = (eventCode == EMTPEventCodeCancelTransaction);
<a name="l00230"></a>00230       }
<a name="l00231"></a>00231 
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 
<a name="l00234"></a>00234 
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>