devicesrv_plat/tspclientmapper_api/inc/tspclientmapper.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  This API is used for creating mappings between remote
       
    15 *                 control clients.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef TSPCLIENTMAPPER_H
       
    21 #define TSPCLIENTMAPPER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <e32std.h>
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30 * The tsp client mapper component is used to create mappings between remote
       
    31 * control clients. The tsp client mapper is used in such cases where a client
       
    32 * could not be correctly mapped by it's default information. For example if a
       
    33 * remote control event is listened by the active audio client but the actual
       
    34 * remote control client is in a different process than the one that is
       
    35 * listening the remote control events. In this case a mapping has to be created
       
    36 * between the active audio process and the remote control client. This mapping
       
    37 * is created simply by setting the process identifier of the remote control
       
    38 * client of the active audio to this api.
       
    39 * Mapping types define the different states for the tsp clients. The states are
       
    40 * defined in TTspClientMappingType. After one state is completed the mapping
       
    41 * should be removed or set to another state. In the following an example
       
    42 * where a value is set when a player is registered.
       
    43 * @code
       
    44 * CTspClientMapper* mapper = CTspClientMapper::NewLC();
       
    45 * RThread client;
       
    46 * RMessage2& message = aMessage;
       
    47 * // Message from the client
       
    48 * RProcess process;
       
    49 * client.Process( process );
       
    50 * TProcessId processId = proceess.Id();
       
    51 * mapper->SetTspTargetClient( processId,
       
    52 *                             CTspClientMapper::ERegisteredClients );
       
    53 * CleanupStack::PopAndDestroy( mapper );
       
    54 * @endcode
       
    55 * 
       
    56 * An example of changing the state of the remote control client:
       
    57 *
       
    58 * @code
       
    59 * CTspClientMapper* mapper = CTspClientMapper::NewLC();
       
    60 * RThread client;
       
    61 * RMessage2& message = aMessage;
       
    62 * // Message from the client
       
    63 * RProcess process;
       
    64 * client.Process( process );
       
    65 * TProcessId processId = proceess.Id();
       
    66 * mapper->SetTspTargetClientToOtherType( processId,
       
    67 *                                        CTspClientMapper::EPlayingClients );
       
    68 * CleanupStack::PopAndDestroy( mapper );
       
    69 * @endcode
       
    70 *
       
    71 * An example of removing a tsp mapping client:
       
    72 *
       
    73 * @code
       
    74 * CTspClientMapper* mapper = CTspClientMapper::NewLC();
       
    75 * RThread client;
       
    76 * RMessage2& message = aMessage;
       
    77 * // Message from the client
       
    78 * RProcess process;
       
    79 * client.Process( process );
       
    80 * TProcessId processId = proceess.Id();
       
    81 * mapper->RemoveTspTargetClient( processId,
       
    82 *                                CTspClientMapper::EPlayingClients );
       
    83 * CleanupStack::PopAndDestroy( mapper );
       
    84 * @endcode
       
    85 * 
       
    86 * @since S60 5.0
       
    87 */
       
    88 
       
    89 class CTspClientMapper : public CBase
       
    90   {
       
    91 public:
       
    92     
       
    93     friend class CRemConTspController;
       
    94     
       
    95     /**
       
    96     * Enumerations for tsp mapping types.
       
    97     *
       
    98     * EPlayingClients is used when the client is in playing state.
       
    99     * ERegisteredClients is used when the client is in registered state.
       
   100     * EStoppedClients is used when the client is in stopped state.
       
   101     */
       
   102     enum TTspClientMappingType
       
   103         {
       
   104         EPlayingClients = 0,
       
   105         ERegisteredClients,
       
   106         EStoppedClients
       
   107         };
       
   108     
       
   109     /**
       
   110     * Symbian two phased constructor.
       
   111     */
       
   112     IMPORT_C static CTspClientMapper* NewL();
       
   113     
       
   114     /**
       
   115     * Symbian two phased constructor. Puts the instance to cleanup stack.
       
   116     */
       
   117     IMPORT_C static CTspClientMapper* NewLC();
       
   118     
       
   119 public: 
       
   120 
       
   121     /**
       
   122     * This function is used to set a target client for TSP. This way Target
       
   123     * Selector Plugin creates a mapping to the correct client.
       
   124     *
       
   125     * @param    aMappingType @see TspClientMappingType
       
   126     * @param    aProcessId is the process identifier of the client. If the
       
   127     *           process id is already in the array the process id that needs
       
   128     *           to be set is moved to the first place in the array.
       
   129     */
       
   130     virtual void SetTspTargetClient( 
       
   131         TTspClientMappingType aMappingType,
       
   132         TProcessId aProcessId ) = 0;
       
   133     
       
   134     /**
       
   135     * This function is used to set a TSP target client for another type then it
       
   136     * was originally set for. This way targets don't have to be removed from
       
   137     * one type and then added to another.
       
   138     *
       
   139     * @param    aMappingType is the type this client has to be set for
       
   140     * @param    aProcessId is the process identifier of the client
       
   141     * @return   KErrNotSupported if invalid mapping type. KErrNotFound if this
       
   142     *           ProcessId is not found from any of the arrays.
       
   143     */
       
   144     virtual TInt SetTspTargetClientToOtherType( 
       
   145         TTspClientMappingType aMappingType,
       
   146         TProcessId aProcessId ) = 0;
       
   147     
       
   148     /**
       
   149     * This function is used to remove a target client from TSP. This way Target
       
   150     * Selector Plugin creates a mapping to the correct client. The process id's
       
   151     * that are set to the tsp client mapper must be removed from the array
       
   152     * after the state is finished with this function. The mappings aren't
       
   153     * destroyed automatically in the destructor.
       
   154     *
       
   155     * @param    aMappingType @see TspClientMappingType
       
   156     * @param    aProcessId is the process identifier of the client
       
   157     * @return   KErrNotSupported if invalid mapping type, KErrNotFound if
       
   158     *           process id is not found in the array.
       
   159     */
       
   160     virtual TInt RemoveTspTargetClient(  
       
   161         TTspClientMappingType aMappingType,
       
   162         TProcessId aProcessId ) = 0;
       
   163     
       
   164     
       
   165     
       
   166 private:
       
   167     
       
   168     /**
       
   169     * This function is used to get the audio clients that are currently
       
   170     * playing audio. The function is used by TSP.
       
   171     *
       
   172     * @param    aMappingType @see TspClientMappingType
       
   173     * @param    aPidArray is given as a reference. The playing audio clients
       
   174     *           are added to this array.
       
   175     * @return   aPidArray is returned with the asked process identifiers.
       
   176     *           KErrNotSupported if invalid mapping type.
       
   177     */
       
   178     virtual TInt GetTspTargetClients(  
       
   179         TTspClientMappingType aMappingType,
       
   180         RArray<TProcessId>& aPidArray ) = 0;
       
   181 
       
   182 protected:    
       
   183     
       
   184     /**
       
   185     * Default Constructor 
       
   186     */
       
   187     CTspClientMapper();
       
   188     
       
   189     };
       
   190 
       
   191 #endif // TSPCLIENTMAPPER_H
       
   192 
       
   193 // End of File