diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/cmtpexampledprequestprocessor_8cpp_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/cmtpexampledprequestprocessor_8cpp_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,182 @@ + + + + +TB9.2 Example Applications: examples/RemoteConn/MtpDataProviderExample/src/cmtpexampledprequestprocessor.cpp Source File + + + + + +

examples/RemoteConn/MtpDataProviderExample/src/cmtpexampledprequestprocessor.cpp

00001 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+00002 // All rights reserved.
+00003 // This component and the accompanying materials are made available
+00004 // under the terms of "Eclipse Public License v1.0"
+00005 // which accompanies this distribution, and is available
+00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
+00007 //
+00008 // Initial Contributors:
+00009 // Nokia Corporation - initial contribution.
+00010 //
+00011 // Contributors:
+00012 //
+00013 // Description:
+00014 //
+00015 
+00016 #include <mtp/mtpprotocolconstants.h>
+00017 #include <mtp/tmtptyperequest.h>
+00018 #include <mtp/mmtpdataproviderframework.h>
+00019 #include <mtp/tmtptypeevent.h>
+00020 #include <mtp/mmtpconnection.h>
+00021 #include <mtp/mmtpobjectmgr.h>
+00022  
+00023 #include "cmtpexampledprequestprocessor.h"
+00024 
+00025 
+00034 CMTPExampleDpRequestProcessor::CMTPExampleDpRequestProcessor(
+00035                                                                                         MMTPDataProviderFramework& aFramework,                                                                                  
+00036                                                                                         MMTPConnection& aConnection,
+00037                                                                                         TInt aElementCount,
+00038                                                                                         const TMTPRequestElementInfo* aElements)
+00039         :iFramework(aFramework),
+00040         iConnection(aConnection),
+00041         iElementCount(aElementCount),
+00042         iElements(aElements)
+00043         {
+00044         
+00045         }
+00046 
+00050 CMTPExampleDpRequestProcessor::~CMTPExampleDpRequestProcessor()
+00051         {
+00052         }
+00056  void CMTPExampleDpRequestProcessor::Release()
+00057      {
+00058      delete this;
+00059     }
+00060 
+00061 
+00068 void CMTPExampleDpRequestProcessor::SendResponseL(TMTPResponseCode aResponseCode, TInt aParameterCount, TUint32* aParams)
+00069         {   
+00070         iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode);
+00071                     
+00072     iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, iSessionId);
+00073         
+00074         iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, iTransactionCode);
+00075    
+00076     TInt i = 0; 
+00077         for(i = 0; i < aParameterCount; i++)
+00078                 {
+00079                 iResponse.SetUint32(TMTPTypeResponse::EResponseParameter1 + i, aParams[i]);
+00080                 }
+00081 
+00082         i += TMTPTypeResponse::EResponseParameter1;
+00083         while(i <= TMTPTypeResponse::EResponseParameter5)
+00084             {
+00085             iResponse.SetUint32(i, KMTPNotSpecified32);
+00086             i++;
+00087             }
+00088         iFramework.SendResponseL(iResponse, *iRequest, iConnection);
+00089         }
+00094  const TMTPTypeRequest& CMTPExampleDpRequestProcessor::Request() const
+00095      { 
+00096      return *iRequest;
+00097      }
+00098      
+00099 
+00100 
+00104 void CMTPExampleDpRequestProcessor::CompleteRequestL()
+00105     {
+00106         iFramework.TransactionCompleteL(*iRequest, iConnection);
+00107         }
+00108 
+00109 
+00116 TBool CMTPExampleDpRequestProcessor::HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase)
+00117         {
+00118         iRequest = &aRequest;
+00119         TBool result = EFalse;
+00120         switch(aPhase)
+00121                 {
+00122                 case ERequestPhase:             
+00123                     ExtractSessionTransactionId();
+00124                     ServiceL(); 
+00125                         break;
+00126 
+00127                 case EResponsePhase:
+00128                         result = DoHandleResponsePhaseL();      
+00129                         break;
+00130                         
+00131                 case ECompletingPhase:
+00132                         result = DoHandleCompletingPhaseL();
+00133                         break;
+00134                 }
+00135         return result;  
+00136         }
+00137 
+00138 
+00143 MMTPConnection& CMTPExampleDpRequestProcessor::Connection() const
+00144      {
+00145      return iConnection;
+00146      }
+00147 
+00152 TUint32 CMTPExampleDpRequestProcessor::SessionId()
+00153     {
+00154     return iSessionId;
+00155     }
+00156         
+00161 TBool CMTPExampleDpRequestProcessor::DoHandleResponsePhaseL()
+00162         {
+00163         TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : EMTPRespCodeOK);
+00164         SendResponseL(responseCode);
+00165         return EFalse;
+00166         }
+00167 
+00172 TBool CMTPExampleDpRequestProcessor::DoHandleCompletingPhaseL()
+00173         {
+00174         CompleteRequestL();
+00175         return ETrue;   
+00176         }
+00177 
+00181 void CMTPExampleDpRequestProcessor::ExtractSessionTransactionId()
+00182         {    
+00183         iSessionId = iRequest->Uint32(TMTPTypeRequest::ERequestSessionID);    
+00184         iTransactionCode = iRequest->Uint32(TMTPTypeRequest::ERequestTransactionID);            
+00185         }
+00186 
+00187 
+00194 TBool CMTPExampleDpRequestProcessor::Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const
+00195     {
+00196 
+00197     TUint32 eventSessionId = aEvent.Uint32(TMTPTypeEvent::EEventSessionID);
+00198     TUint32 eventTransactionCode = aEvent.Uint32(TMTPTypeEvent::EEventTransactionID);
+00199     
+00200     TBool result = EFalse;
+00201     if(iSessionId == eventSessionId && 
+00202         iTransactionCode == eventTransactionCode &&
+00203         &iConnection == &aConnection)
+00204         {
+00205         result = ETrue;
+00206         }
+00207     return result;  
+00208     }
+00209  
+00216 TBool CMTPExampleDpRequestProcessor::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
+00217     {
+00218     TBool result = ((&aRequest == iRequest) && (&iConnection == &aConnection));
+00219     return result;      
+00220     }
+00221  
+00226 void CMTPExampleDpRequestProcessor::HandleEventL(const TMTPTypeEvent& aEvent)
+00227       {
+00228       TUint16 eventCode = aEvent.Uint16(TMTPTypeEvent::EEventCode);
+00229       iCancelled = (eventCode == EMTPEventCodeCancelTransaction);
+00230       }
+00231 
+00232 
+00233 
+00234 
+
+
Generated by  + +doxygen 1.6.2
+ +