devicesrv_plat/haptics_plugin_api/inc/hwrmhapticspluginservice.h
changeset 0 4e1aa6a622a0
child 9 b0e374890c7b
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Haptics plugin API service definition header file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef HWRMHAPTICSPLUGINSERVICE_H
       
    21 #define HWRMHAPTICSPLUGINSERVICE_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <ecom/ecom.h>
       
    26 #include <badesca.h>
       
    27 #include <hwrmlogicalactuators.h>
       
    28 
       
    29 /**
       
    30  * ECOM Plugin interface UID
       
    31  */
       
    32 const TUid KCHWRMHapticsPluginServiceInterfaceUid = { 0x2001CBE4 };
       
    33     
       
    34 /**
       
    35  *  Callback interface for the HWRMHaptics plugins.
       
    36  *  Used to return data and/or error codes from an asynchronous plugin calls.
       
    37  *
       
    38  * @since S60 5.1
       
    39  */
       
    40 class MHWRMHapticsPluginCallback
       
    41     {
       
    42 public:
       
    43     
       
    44     /**
       
    45      * Method to indicate the state of the plugin to haptics subsystem.
       
    46      * The value is directly forwarded to the user of the haptics 
       
    47      * subsystem, if it has requested notification of actuator status
       
    48      * changes.
       
    49      *
       
    50      * Plugin implementation should not assume that this information is
       
    51      * always passed to the user or that it would affect its implementation.
       
    52      * I.e. the plugin should be able to handle commands also when 
       
    53      * it is in disabled state, since the user may still request command 
       
    54      * processing from the plugin.
       
    55      * 
       
    56      * Note: When the plugin is instantiated, the initial state of the plugin
       
    57      * should always be informed through this callback method. The user of
       
    58      * haptics subsystem may use this information e.g. as a notification 
       
    59      * when to start playing haptics effect.
       
    60      *
       
    61      * @param aActuator Logical actuator type, whose state is informed by
       
    62      * this call.
       
    63      * @param aEnabled Whether or not the plugin is currently enabled.
       
    64      * If ETrue, the plugin is enabled and ready to be used. If EFalse,
       
    65      * plugin is currently disabled and cannot perform commands passed 
       
    66      * to it.
       
    67      */
       
    68     virtual void PluginEnabled( THWRMLogicalActuators aActuator, 
       
    69                                 TBool aEnabled ) = 0;
       
    70 
       
    71     /**
       
    72      * Method to return data in response to a message from a HWRMHaptics plugin.
       
    73      * Related ProcessCommandL call must return before this method can
       
    74      * be called.
       
    75      *
       
    76      * @param aCommandId Command ID for which the response comes
       
    77      * @param aTransId   Unique transcation identifier of the original command.
       
    78      * @param aData      Data returned from call. 
       
    79      *                   Data package contents are defined by command.
       
    80      */
       
    81     virtual void ProcessResponseL( TInt aCommandId,
       
    82                                    TUint8 aTransId, 
       
    83                                    const TDesC8& aData ) = 0;
       
    84     };
       
    85 
       
    86 
       
    87 /**
       
    88  * Plugin interface class to be implemented by adaptation.
       
    89  * Responsible for invoking the adaptation implementation of
       
    90  * each command and cancelling the command.
       
    91  *
       
    92  * @since S60 5.1
       
    93  */
       
    94 class CHWRMHapticsPluginService : public CBase
       
    95     {
       
    96 public:
       
    97     
       
    98     /**
       
    99      * Instantiation method.
       
   100      * Uses ECom to find correct instance.
       
   101      *
       
   102      * @param aImplementationUid Determines the plugin to be instantiated.
       
   103      * @param aResponseCallback Pointer to plugin callback handler.
       
   104      */
       
   105     IMPORT_C static 
       
   106     CHWRMHapticsPluginService* CHWRMHapticsPluginService::NewL( 
       
   107             TUid aImplementationUid, 
       
   108             MHWRMHapticsPluginCallback* aResponseCallback );
       
   109 
       
   110     /**
       
   111      * Destructor
       
   112      */
       
   113     IMPORT_C virtual ~CHWRMHapticsPluginService();
       
   114 
       
   115 public:
       
   116 
       
   117     /**
       
   118      * Method to invoke a particular command in the plugin. 
       
   119      * Response to method is returned via separate ProcessResponseL
       
   120      * callback. Call to ProcessResponseL is done after the call to
       
   121      * ProcessCommandL returns. Plugin must be able to handle another
       
   122      * ProcessCommandL before ProcessResponseL is called for previous
       
   123      * call(s) (i.e. multiple clients are attempting to access resource
       
   124      * simultaneously). If ProcessCommandL leaves, no corresponding
       
   125      * ProcessResponseL is expected. 
       
   126      *
       
   127      * @param aCommandId Command ID
       
   128      * @param aTransId   Transaction ID. Unique Id allocated by the 
       
   129      *                   issuer of this command that is used to
       
   130      *                   distinguish which response relates
       
   131      *                   to which command. Also used in CancelCommandL 
       
   132      *                   to distinguish which command is cancelled.
       
   133      * @param aData      Data associated with command.
       
   134      *                   Data package contents are defined by command.
       
   135      *                   Some commands require no data and pass
       
   136      *                   empty buffer as aData;
       
   137      */
       
   138     virtual void ProcessCommandL( TInt aCommandId,
       
   139                                   TUint8 aTransId,
       
   140                                   TDesC8& aData ) = 0;
       
   141 
       
   142     /**
       
   143      * Method to cancel a particular command. The corresponding
       
   144      * ProcessResponseL will not be called for cancelled commands,
       
   145      * whether cancel was successful or not. 
       
   146      *
       
   147      * @param aTransId   Transaction ID
       
   148      * @param aCommandId Command ID to optionally double check with the 
       
   149      *                   transaction ID
       
   150      */
       
   151     virtual void CancelCommandL( TUint8 aTransId, 
       
   152                                  TInt aCommandId) = 0;
       
   153     
       
   154 protected:
       
   155    
       
   156     /**
       
   157      * Destructor identifier to be used with ECom framework.
       
   158      */
       
   159     TUid iDestructorIDKey;
       
   160 
       
   161     /**
       
   162      * Callback pointer to be used with responses to commands.
       
   163      * Not owned.
       
   164      */
       
   165     MHWRMHapticsPluginCallback* iResponseCallback;
       
   166                                       
       
   167     };
       
   168 
       
   169 #endif      // HWRMHAPTICSPLUGINSERVICE_H   
       
   170             
       
   171 // End of File