mediator/inc/Client/MediatorCommandResponderBody.h
changeset 0 4e1aa6a622a0
child 10 1fc153c72b60
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 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:  An implementation class for responding to Mediator Service commands.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MEDIATORCOMMANDRESPONDERBODY_H
       
    19 #define MEDIATORCOMMANDRESPONDERBODY_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "MediatorServerClient.h"
       
    25 #include "MediatorCommandResponder.h"
       
    26 #include "MediatorServiceDefs.h"
       
    27 
       
    28 // NAMESPACE
       
    29 using namespace MediatorService;
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class RMediatorServerSession;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  A class used to respond to Mediator Service commands.
       
    40 *
       
    41 *  @lib MediatorClient.lib
       
    42 *  @since S60 3.1
       
    43 */
       
    44 NONSHARABLE_CLASS(CMediatorCommandResponderBody) : public CActive
       
    45 	{
       
    46     public:  // Constructors and destructor
       
    47         
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         *
       
    51         * @param aObserver  mediator command observer
       
    52         * @return a new CMediatorCommandResponderBody instance
       
    53         */       
       
    54         static CMediatorCommandResponderBody* NewL(
       
    55             MMediatorCommandObserver* aObserver );
       
    56         
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         virtual ~CMediatorCommandResponderBody();
       
    61 
       
    62     public: // Command registration
       
    63 
       
    64         /**
       
    65         * Register a command category. After registering the category 
       
    66         * all commands from the category may be initiated.
       
    67         * 
       
    68         * @since S60 3.1  
       
    69         * @param aDomain    The identifier of the domain      
       
    70         * @param aCategory  The identifier of the category.
       
    71         * @param aCommands  The list of commands to be registered.
       
    72         * @return TInt      an error value.
       
    73         */
       
    74         TInt RegisterCommand( TUid aDomain,
       
    75                               TUid aCategory, 
       
    76                               const RCommandList& aCommands );
       
    77 
       
    78         /**
       
    79         * Register a command. After registering the command it may be
       
    80         * initiated.
       
    81         * 
       
    82         * @since S60 3.1   
       
    83         * @param aDomain    The identifier of the domain      
       
    84         * @param aCategory  The identifier of the category.
       
    85         * @param aCommandId The identifier of the category.
       
    86         * @param aVersion   The version of the command
       
    87         * @param aCaps      Capabilities required for initiating the command.
       
    88         * @param aTimeout   The timeout value for waiting a response for the 
       
    89         *                   command. This is given in milliseconds (ms).
       
    90         * @return TInt      an error value.
       
    91         */
       
    92         TInt RegisterCommand( TUid aDomain, 
       
    93                               TUid aCategory, 
       
    94                               TInt aCommandId, 
       
    95                               TVersion aVersion,
       
    96                               TCapabilitySet aCaps, 
       
    97                               TInt aTimeOut );
       
    98 
       
    99         /**
       
   100         * Unregister a command category.
       
   101         *
       
   102         * @since S60 3.1
       
   103         * @param aDomain    The identifier of the domain         
       
   104         * @param aCategory  The identifier of the category.
       
   105         * @param aCommands  List of commands to be unregistered.
       
   106         * @return TInt      an error value.
       
   107         */
       
   108         TInt UnregisterCommand( TUid aDomain, 
       
   109                                 TUid aCategory,
       
   110                                 const RCommandList& aCommands );
       
   111 
       
   112         /**
       
   113         * Unregister a command.
       
   114         *
       
   115         * @since S60 3.1  
       
   116         * @param aDomain    The identifier of the domain       
       
   117         * @param aCategory  The identifier of the category.
       
   118         * @param aCommandId The identifier of the category.
       
   119         * @return TInt      an error value.
       
   120         */
       
   121         TInt UnregisterCommand( TUid aDomain, 
       
   122                                 TUid aCategory, 
       
   123                                 TInt aCommandId );
       
   124 
       
   125 
       
   126     public: // Command responding
       
   127 
       
   128         /**
       
   129         * Issue a response to a command.
       
   130         * 
       
   131         * @since S60 3.1  
       
   132         * @param aDomain    The identifier of the domain       
       
   133         * @param aCategory  The identifier of the category.
       
   134         * @param aCommandId The identifier of the command.
       
   135         * @param aStatus    Result status of the command.
       
   136         * @param aData      The parameters of the response.        
       
   137         * @return TInt      an error value.
       
   138         */
       
   139         TInt IssueResponse( TUid aDomain,
       
   140                             TUid aCategory, 
       
   141                             TInt aCommandId,
       
   142                             TInt aStatus, 
       
   143                             const TDesC8& aData );
       
   144         
       
   145     private: // From CActive
       
   146     
       
   147         /**
       
   148         * From CActive::RunL
       
   149         */
       
   150         void RunL();
       
   151         
       
   152         /**
       
   153         * From CActive::DoCancel()
       
   154         */
       
   155         void DoCancel();
       
   156     
       
   157     private: // new functions
       
   158         
       
   159         /**
       
   160         * Start to receive commands asynchronously
       
   161         *
       
   162         * @since S60 3.1
       
   163         * @return None.
       
   164         */
       
   165         void StartCommandReceiving();
       
   166         
       
   167         /**
       
   168         * Re-init return data buffer
       
   169         *
       
   170         * @since S60 3.1
       
   171         * @param aSize size of the buffer
       
   172         * @return None.
       
   173         */
       
   174         void ResetDataBufferL( TInt aSize );
       
   175         
       
   176     private:
       
   177     
       
   178         /**
       
   179         * C++ default constructor.
       
   180         *
       
   181         * @param mediator command observer
       
   182         */
       
   183         CMediatorCommandResponderBody( MMediatorCommandObserver* aObserver );
       
   184 
       
   185         /**
       
   186         * By default Symbian 2nd phase constructor is private.
       
   187         */
       
   188         void ConstructL();
       
   189 
       
   190     private: // Data
       
   191 
       
   192         // A session class to mediator server
       
   193         RMediatorServer     iMediatorServer;
       
   194         
       
   195         // Observer for event callbacks (not owned)
       
   196         MMediatorCommandObserver*   iObserver;
       
   197         
       
   198         // Domain/Category cata for incoming event
       
   199         TMediatorCategory           iCategory;
       
   200         TMediatorCategoryRetBuffer  iCategoryBuffer;
       
   201         
       
   202         // Command Id data
       
   203         MediatorService::TCommand   iCommand;
       
   204         TCommandRetBuffer           iCommandBuffer;
       
   205         
       
   206         // Command data to be received
       
   207         HBufC8*                     iCommandData; 
       
   208         // Pointer to command data.
       
   209         TPtr8                       iCommandDataPtr;
       
   210         
       
   211         // Stores information whether destructor has been called, checked in RunL
       
   212         TBool* iDestroyed;
       
   213         
       
   214 	};
       
   215 
       
   216 #endif      // MEDIATORCOMMANDRESPONDERBODY_H
       
   217             
       
   218 // End of File