mediator/inc/Server/MediatorServerCommandHandler.h
changeset 0 4e1aa6a622a0
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:  Manages commands registered to Mediator.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MEDIATORSERVERCOMMANDHANDLER_H
       
    19 #define MEDIATORSERVERCOMMANDHANDLER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "MediatorCommon.h"
       
    24 #include "MediatorServerObjectHandler.h"
       
    25 #include "MediatorServiceDefs.h"
       
    26 #include "MediatorCommandTimer.h"
       
    27 
       
    28 
       
    29 // NAMESPACE
       
    30 using namespace MediatorService;
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CMediatorServerObjectHandler;
       
    34 class CDomain;
       
    35 class CCategory;
       
    36 class CItem;
       
    37 class CCommand;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Command handler class for Mediator Server.
       
    44 *
       
    45 *  @lib MediatorServer
       
    46 *  @since S60 3.1
       
    47 */
       
    48 class CMediatorServerCommandHandler : public CBase, public MMediatorTimerCallback
       
    49     {
       
    50     public:  // Constructors and destructor
       
    51         
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         *
       
    55         * @param aObjectHandler object handler
       
    56         * @return A new CMediatorServerCommandHander instance
       
    57         */
       
    58         static CMediatorServerCommandHandler* NewL(  
       
    59                     CMediatorServerObjectHandler& aObjectHandler );
       
    60         
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         virtual ~CMediatorServerCommandHandler();
       
    65 
       
    66     public: // New functions
       
    67         
       
    68         /**
       
    69         * Register list of new commands.
       
    70         *
       
    71         * Checks that no existing commands are registered
       
    72         * @since S60 3.1
       
    73         * @param aCategory  information for the category
       
    74         * @param aCommands  list of commands to be registered
       
    75         * @param aSecureId  secure Id of the client
       
    76         * @param aObserver  observer instance for incoming commands
       
    77         * @return none.
       
    78         */
       
    79         void RegisterCommandListL( TMediatorCategory aCategory, 
       
    80                                    const RCommandList& aCommands,
       
    81                                    TSecureId aSecureId,
       
    82                                    MMediatorCommandObserver* aObserver );
       
    83                                  
       
    84          
       
    85         /**
       
    86         * Unregisters command(s)
       
    87         * @since S60 3.1
       
    88         * @param aCategory  information for the category
       
    89         * @param aCommands  list of commands to be unregistered
       
    90         * @param aSecureId  secure Id of the client
       
    91         * @return none.
       
    92         */
       
    93         void UnregisterCommandListL( TMediatorCategory aCategory, 
       
    94                                      const RCommandList& aCommands,
       
    95                                      TSecureId aSecureId  );   
       
    96        
       
    97         
       
    98         /**
       
    99         * Issue command
       
   100         * @since S60 3.1
       
   101         * @param aCategory  Information for the category
       
   102         * @param aCommand   Command information
       
   103         * @param aData      Command parameter data
       
   104         * @param aCaps      Capabilities of the client
       
   105         * @param aObserver  Command response observer
       
   106         * @return none.
       
   107         */
       
   108 
       
   109         void IssueCommandL( TMediatorCategory aCategory, 
       
   110                             MediatorService::TCommand aCommand,
       
   111                             const TDesC8& aData,
       
   112                             TCapabilitySet aCaps,
       
   113                             MMediatorCommandResponseObserver* aObserver );  
       
   114         
       
   115         /**
       
   116         * Issue response
       
   117         * @since S60 3.1
       
   118         * @param aCategory  Information for the category
       
   119         * @param aCommand   Command information
       
   120         * @param aData      Command parameter data
       
   121         * @param aStatus    Status of the response
       
   122         * @return error code    KErrNone                    response was issued
       
   123         *                       KMediatorErrCommandNotFound command was not found
       
   124         */
       
   125 
       
   126         TInt IssueResponse( TMediatorCategory aCategory, 
       
   127                             MediatorService::TCommand aCommand,
       
   128                             const TDesC8& aData,
       
   129                             TInt aStatus );  
       
   130 
       
   131         
       
   132         /**
       
   133         * Issue response
       
   134         * @since S60 3.1
       
   135         * @param aCategory  Information for the category
       
   136         * @param aCommand   Command information
       
   137         * @param aData      Command parameter data
       
   138         * @param aStatus    Status of the response
       
   139         * @return none.
       
   140         * @leave KMediatorErrCommandNotFound    command was not found
       
   141         */
       
   142 
       
   143         void IssueResponseL( TMediatorCategory aCategory, 
       
   144                              MediatorService::TCommand aCommand,
       
   145                              const TDesC8& aData,
       
   146                              TInt aStatus );                              
       
   147         
       
   148         /**
       
   149         * Cancel command
       
   150         * @since S60 3.1
       
   151         * @param aCategory  Information for the category
       
   152         * @param aCommand   Command information
       
   153         * @return none.
       
   154         */
       
   155 
       
   156         void CancelCommand( TMediatorCategory aCategory, 
       
   157                             MediatorService::TCommand aCommand );
       
   158                             
       
   159         
       
   160         /**
       
   161         * Cancels all the pending commands that are either 
       
   162         * registered or initiated by the client
       
   163         *
       
   164         * @since S60 3.1
       
   165         * @param aObserver          command observer
       
   166         * @param aResponseObserver  command response observer (initiator)
       
   167         * @return none.
       
   168         */
       
   169                 
       
   170         void CancelCommands( MMediatorCommandObserver* aObserver, MMediatorCommandResponseObserver* aResponseObserver );
       
   171                                                         
       
   172         /**
       
   173         * Returns count of pending commands
       
   174         *
       
   175         * @since S60 3.1
       
   176         * @return count of pending commands
       
   177         */
       
   178         
       
   179         TInt CommandPendingCount() { return iCommandPendingList.Count(); }
       
   180         
       
   181     public: // From timer
       
   182     
       
   183         /**
       
   184         * Timer callback implementation
       
   185         *
       
   186         * @since S60 3.1
       
   187         * @param aDomain    domain of the command
       
   188         * @param aCategory  category of the command
       
   189         * @param aCommandId id of the command
       
   190         * @return None.
       
   191         */      
       
   192         void TimerCallBack( TUid aDomain, 
       
   193                             TUid aCategory, 
       
   194                             TInt aCommandId );                            
       
   195         
       
   196     private:
       
   197 
       
   198         /**
       
   199         * C++ default constructor.
       
   200         * 
       
   201         * @param aObjectHandler object handler
       
   202         */
       
   203         CMediatorServerCommandHandler(  
       
   204                     CMediatorServerObjectHandler& aObjectHandler );
       
   205 
       
   206         /**
       
   207         * By default Symbian 2nd phase constructor is private.
       
   208         */
       
   209         void ConstructL();
       
   210         
       
   211     private:    // Data
       
   212         
       
   213         // Handle to object handler
       
   214         CMediatorServerObjectHandler& iObjectHandler;
       
   215         
       
   216         // List of pending commands
       
   217         RPointerArray<CCommand>  iCommandPendingList;
       
   218         
       
   219     };
       
   220 
       
   221 #endif      // MEDIATORSERVERCOMMANDHANDLER_H  
       
   222             
       
   223 // End of File