satengine/SatServer/Engine/inc/CSatClientServiceReq.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handles client requests.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSATCLIENTSERVICEREQ_H
       
    21 #define CSATCLIENTSERVICEREQ_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "MSatCommand.h"
       
    26 #include "SatSOpcodes.h"
       
    27 
       
    28 // FORWARD DECLARATION
       
    29 class MSatUtils;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 *  Handles the buffering of command and client request.
       
    35 *  Buffering is needed because client can make request without command and
       
    36 *  viceversa.
       
    37 *
       
    38 *  @lib SatEngine
       
    39 *  @since Series 60 3.0
       
    40 */
       
    41 class CSatClientServiceReq : public CBase
       
    42     {
       
    43     public:  // Constructors and destructor
       
    44 
       
    45         /**
       
    46         * Two-phased constructor.
       
    47         * @param aRequest Handled service request
       
    48         * @param aResponse Handled response request.
       
    49         * @param aCommand Command hander for request
       
    50         * @param aUtils Reference to SAT Utilities
       
    51         */
       
    52         static CSatClientServiceReq* NewL(
       
    53             TSatServerRequest aRequest,
       
    54             TSatServerRequest aResponse,
       
    55             MSatCommand* aCommand,
       
    56             MSatUtils& aUtils );
       
    57 
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         virtual ~CSatClientServiceReq();
       
    62 
       
    63     public: // New functions
       
    64 
       
    65         /**
       
    66         * Handles the command from SIM.
       
    67         * @param aCmdData Data to be sent to client.
       
    68         * @param aCmdRsp Clients response is written to this descriptor.
       
    69         * @param aRequest Request which the data is sent.
       
    70         * @return ETrue if command was recognised to be handled in this class ie aRequest is the same that
       
    71         * set in constructor.
       
    72         */
       
    73         virtual TBool HandleCommand(
       
    74             TDesC8* aCmdData,
       
    75             TDes8* aCmdRsp,
       
    76             TSatServerRequest aRequest );
       
    77 
       
    78         /**
       
    79         * Handles the request from client.
       
    80         * @param aRequest Service request from client.
       
    81         * @return ETrue if request was recognised to be handled in this class.
       
    82         */
       
    83         virtual TBool HandleRequest( const RMessage2& aRequest );
       
    84 
       
    85         /**
       
    86         * Checks is this service request handling this request
       
    87         * @param aRequest Checks own request to this request
       
    88         * @return TBool indicating is param aRequest this service
       
    89         * requests request
       
    90         */
       
    91         virtual TBool IsMyRequest( const TSatServerRequest aRequest );
       
    92 
       
    93         /**
       
    94         * Sets command handler for this service request handler
       
    95         * @param aCommand Command handler for this service request
       
    96         */
       
    97         virtual void SetCommandHandler( MSatCommand* aCommand );
       
    98 
       
    99         /**
       
   100         * Resets containing data.
       
   101         */
       
   102         virtual void Reset();
       
   103 
       
   104     protected:  // New functions
       
   105 
       
   106         /**
       
   107         * Writes the data to client address space and
       
   108         * completes the iRequest.
       
   109         */
       
   110         virtual void SendDataToClient();
       
   111 
       
   112     protected:
       
   113 
       
   114         /**
       
   115         * C++ default constructor.
       
   116         * @param aRequest Handled service request
       
   117         * @param aResponse Handled response request.
       
   118         * @param aCommand Command hander for request
       
   119         * @param aUtils Reference to SAT Utilities
       
   120         */
       
   121         CSatClientServiceReq( 
       
   122             TSatServerRequest aRequest,
       
   123             TSatServerRequest aResponse,
       
   124             MSatCommand* aCommand,
       
   125             MSatUtils& aUtils );
       
   126 
       
   127     private:  // Data
       
   128 
       
   129         // Identifies the client request, which is handled in HandleRequest
       
   130         const TSatServerRequest iHandledRequest;
       
   131 
       
   132         // Identifies the client response, which is handled in HandleRequest
       
   133         const TSatServerRequest iHandledResponse;
       
   134 
       
   135         // Command from SIM
       
   136         MSatCommand* iResponseObserver;
       
   137 
       
   138         // Indicates if the command from SIM is not yet sent to client
       
   139         TBool iCmdPending;
       
   140 
       
   141         // Service request from client
       
   142         RMessage2 iRequest;
       
   143 
       
   144         // Indicates that request is waiting command from SIM.
       
   145         TBool iRequestPending;
       
   146 
       
   147         // Data from SIM.
       
   148         TDesC8* iCmdData;
       
   149 
       
   150         // Response from client..
       
   151         TDes8* iCmdRsp;
       
   152 
       
   153         // Utilities class
       
   154         MSatUtils& iUtils;
       
   155     };
       
   156 
       
   157 #endif      // CSATCLIENTSERVICEREQ_H
       
   158 
       
   159 // End of File