examples/RemoteConn/MtpDataProviderExample/inc/cmtpexampledprequestprocessor.h

00001 /*
00002 Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description: 
00028 */
00029 
00030 
00031 #ifndef __CMTPEXAMPLEDPREQUESTPROCESSOR_H__
00032 #define __CMTPEXAMPLEDPREQUESTPROCESSOR_H__
00033 
00034 #include <e32base.h>
00035 #include <mtp/mtpdataproviderapitypes.h>
00036 #include <mtp/mtpprotocolconstants.h>
00037 #include <mtp/tmtptyperesponse.h>
00038 #include <mtp/tmtptypenull.h>
00039 
00040 
00041 class TMTPTypeRequest;
00042 class CMTPDataProviderPlugin;
00043 class MMTPDataProviderFramework;
00044 class TMTPTypeEvent;
00045 
00046 struct TMTPRequestElementInfo; 
00047 
00053 class MMTPExampleDpRequestProcessor
00054         {
00055 public: 
00056         /*
00057         Process a request from the initiator
00058         @param aRequest The request to be processed
00059         @param aPhase   The transaction phase of the request
00060         @return ETrue to signal that the processor object can be deleted, EFalse to keep the processor object
00061         */
00062         virtual TBool HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase) = 0;
00063         
00064         /*
00065         Process an event from the initiator
00066         @param aEvent   The event to be processed
00067         */
00068         virtual void HandleEventL(const TMTPTypeEvent& aEvent) = 0;
00069         
00070         /*
00071     Check if the processor matches the request on the connection
00072     @param aRequest The request to be checked
00073     @param aConnection The connection from which the request comes
00074     @return ETrue to indicate the processor can handle the request, otherwise, EFalse
00075     */
00076     virtual TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const = 0;
00077         
00078         /*
00079         Check if the processor matches the event on the connection
00080         @param aEvent The event to be checked
00081         @param aConnection The connection from which the event comes
00082         @return ETrue to indicate the processor can handle the event, otherwise, EFalse
00083         */      
00084         virtual TBool Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const = 0;
00085         
00086         /*
00087         Get the request object which the processor is currently handling
00088         @return the request object which the processor is currently handling
00089         */
00090         virtual const TMTPTypeRequest& Request() const = 0;
00091         
00092         /*
00093         Get the connection object associated with the current request object
00094         @return the connection object associated with the current request object
00095         */
00096         virtual MMTPConnection& Connection() const = 0;
00097     /*
00098     Get the Session ID associated with the current request object
00099     @return Session ID associated with the current request object
00100     */  
00101         
00102         virtual TUint32 SessionId() = 0;
00103    /*
00104     delete the request processor object
00105     */
00106     virtual void Release() = 0;
00107 
00108         };
00109 
00113 typedef MMTPExampleDpRequestProcessor* (*TMTPRequestProcessorCreateFunc)(
00114                                                                                                                                 MMTPDataProviderFramework& aFramework, 
00115                                                                                                                                 MMTPConnection& aConnection);
00116 
00120 typedef struct 
00121         {
00122         TUint16                                                 iOperationCode;
00123         TMTPRequestProcessorCreateFunc  iCreateFunc;
00124         }TMTPRequestProcessorEntry;
00125 
00126 class CMTPExampleDpRequestProcessor : public MMTPExampleDpRequestProcessor
00127     {
00128 protected:  
00129     CMTPExampleDpRequestProcessor(
00130                         MMTPDataProviderFramework& aFramework,
00131                         MMTPConnection& aConnection,
00132                         TInt aElementCount,
00133                         const TMTPRequestElementInfo* aElements);
00134     virtual ~CMTPExampleDpRequestProcessor();   
00135 
00136 protected:  //utility methods   
00137     void SendResponseL(TMTPResponseCode aResponseCode, TInt aParameterCount = 0, TUint32* aParams = NULL);
00138     void CompleteRequestL();
00139         
00140 protected:  //  from MMTPRequestProcessor   
00141     virtual TBool HandleRequestL(const TMTPTypeRequest& aRequest, TMTPTransactionPhase aPhase);
00142     virtual void HandleEventL(const TMTPTypeEvent& aEvent);
00143     virtual void Release();
00144     virtual TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
00145     virtual TBool Match(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) const;  
00146     virtual const TMTPTypeRequest& Request() const;
00147     virtual MMTPConnection& Connection() const;
00148     virtual TUint32 SessionId();
00149 
00150 
00151 protected:  //new virtuals  
00152     virtual TBool DoHandleResponsePhaseL();
00153     virtual TBool DoHandleCompletingPhaseL();
00154     
00155     /*
00156     service a request at request phase
00157     */
00158     virtual void ServiceL() = 0;
00159 
00160 private:
00161     void ExtractSessionTransactionId();                 
00162     
00163 protected:
00164     MMTPDataProviderFramework&      iFramework;
00165     const TMTPTypeRequest*          iRequest;           //the pending request object.
00166     MMTPConnection&                 iConnection;        //the connection from which the request comes.
00167     TMTPTypeResponse                iResponse;          //the response object to send to the initiator.
00168     TBool                           iCancelled;         //indicates whether the data phase (send/receive) has been cancelled.
00169     TInt                            iElementCount;      //number of verification elements used for request checker.
00170     const TMTPRequestElementInfo*   iElements;          //pointer to an array of verification elements.
00171     TUint32                         iSessionId;         //session id for the pending request.
00172     TUint32                         iTransactionCode;   //transaction code for the pending request.
00173 
00174 private:
00175     TMTPResponseCode                iResponseCode;      // contains response from CheckRequestL call.
00176     };
00177 
00178 #endif // __CMTPEXAMPLEDPREQUESTPROCESSOR_H__
00179 

Generated by  doxygen 1.6.2