hwrmhaptics/tsrc/haptics_stif/inc/hapticsclienttest.h
changeset 76 cb32bcc88bad
equal deleted inserted replaced
73:d38941471f1c 76:cb32bcc88bad
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HAPTICSCLIENTTEST_H
       
    20 #define HAPTICSCLIENTTEST_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <hwrmhaptics.h>
       
    24 #include "hapticsclienttest_main.h"
       
    25 
       
    26 
       
    27 /**
       
    28  * Callback class for haptics status observation.
       
    29  */
       
    30 NONSHARABLE_CLASS( THapticsStatusCallback ) : public MHWRMHapticsObserver
       
    31     {
       
    32 public:
       
    33 
       
    34     /**
       
    35      * C++ constructor.
       
    36      */
       
    37     THapticsStatusCallback( CHapticsClientTest* aMTCallback );
       
    38     
       
    39     /**
       
    40      * Destructor.
       
    41      */
       
    42     ~THapticsStatusCallback();
       
    43     
       
    44     /**
       
    45      * Returns the last received status.
       
    46      *
       
    47      * @return Last status value.
       
    48      */
       
    49     MHWRMHapticsObserver::THWRMHapticsStatus Status();
       
    50     
       
    51     /**
       
    52      * Starts a new wait loop under the current active scheduler.
       
    53      * This method can be used in module tests to wait for the 
       
    54      * notification to be received. When the notification is 
       
    55      * received (i.e. callback is called by haptics), the waiting
       
    56      * is stopped and the execution continues whereever this method
       
    57      * was called.
       
    58      */
       
    59     void WaitForNotification();
       
    60 
       
    61 public: // from MHWRMHapticsObserver
       
    62 
       
    63     virtual void HapticsStatusChangedL( THWRMHapticsStatus aStatus );
       
    64     virtual void EffectCompletedL( TInt aError, TInt aEffectHandle );
       
    65 
       
    66 private:
       
    67     
       
    68     /**
       
    69      * Last received haptics status through status observation.
       
    70      */
       
    71     MHWRMHapticsObserver::THWRMHapticsStatus iHapticsStatus;
       
    72     
       
    73     /**
       
    74      * Callback which is notified, when a status has been received.
       
    75      */
       
    76     CHapticsClientTest* iMTCallback;
       
    77     };
       
    78 
       
    79 
       
    80 /**
       
    81  * Callback class for actuator status observation.
       
    82  */
       
    83 NONSHARABLE_CLASS( TActuatorStatusCallback ) : public MHWRMHapticsActuatorObserver
       
    84     {
       
    85 public:
       
    86 
       
    87     /**
       
    88      * C++ constructor.
       
    89      */
       
    90     TActuatorStatusCallback( CHapticsClientTest* aMTCallback );
       
    91     
       
    92     /**
       
    93      * Destructor.
       
    94      */
       
    95     ~TActuatorStatusCallback();
       
    96     
       
    97     /**
       
    98      * Returns the last received state.
       
    99      *
       
   100      * @return Last status value.
       
   101      */
       
   102     MHWRMHapticsActuatorObserver::THWRMActuatorEvents Status( THWRMLogicalActuators aActuator );
       
   103     
       
   104     /**
       
   105      * Starts a new wait loop under the current active scheduler.
       
   106      * This method can be used in module tests to wait for the 
       
   107      * notification to be received. When the notification is 
       
   108      * received (i.e. callback is called by haptics), the waiting
       
   109      * is stopped and the execution continues whereever this method
       
   110      * was called.
       
   111      */
       
   112     void WaitForNotification();
       
   113 
       
   114 public: // from MHWRMHapticsActuatorObserver
       
   115 
       
   116     virtual void ActuatorEventL( THWRMActuatorEvents aEvent,
       
   117                                  THWRMLogicalActuators aActuator );
       
   118 
       
   119 private:
       
   120     
       
   121     /**
       
   122      * Last received actuator status through state observation.
       
   123      */
       
   124     RArray<TInt> iActuatorStatus;
       
   125 
       
   126     /**
       
   127      * Callback which is notified, when a state has been received.
       
   128      */
       
   129     CHapticsClientTest* iMTCallback;
       
   130     };
       
   131 
       
   132 /**
       
   133  * Class for making async play-with-filehandle calls on behalf of the
       
   134  * CHapticsClientTest
       
   135  */ 
       
   136 NONSHARABLE_CLASS( MT_HapticsTestAsyncPlaySender ) : public CActive
       
   137     {
       
   138 public: 
       
   139 
       
   140     /**
       
   141      * Constructor
       
   142      *
       
   143      * @param aUi   Pointer to the test appl UI object.
       
   144      */
       
   145     MT_HapticsTestAsyncPlaySender( CHapticsClientTest* aMTCallback );
       
   146                                  
       
   147     /**
       
   148      * Destructor
       
   149      */
       
   150     virtual ~MT_HapticsTestAsyncPlaySender();
       
   151  
       
   152     /**
       
   153      * Method for fileHandle type playing of effects repeatedly in asynch mode
       
   154      * 
       
   155      * @param aHaptics Pointer to the haptics interface object.
       
   156      * @param aFileHandle Handle for the effect data buffer from which to
       
   157      *                    play the effects.
       
   158      * @param aEffectIndex Index of the effect that is being played.
       
   159      * @param aRepeat Number of repeats.
       
   160      * @param aEffectHandle Out-parameter to which the handle for the played
       
   161      *        effect is returned.
       
   162      */
       
   163     void PlayRepeat( CHWRMHaptics* aHaptics,
       
   164                      TInt  aFileHandle,
       
   165                      TInt aEffectIndex,
       
   166                      TUint8 aRepeat,
       
   167                      TInt& aEffectHandle,
       
   168                      TRequestStatus& aClientStatus );
       
   169 
       
   170     /**
       
   171      * Method for fileHandle type playing of effects in asynch mode
       
   172      * 
       
   173      * @param aHaptics Pointer to the haptics interface object.
       
   174      * @param aFileHandle Handle for the effect data buffer from which to
       
   175      *                    play the effects.
       
   176      * @param aEffectIndex Index of the effect that is being played.
       
   177      * @param aEffectHandle Out-parameter to which the handle for the played
       
   178      *        effect is returned.
       
   179      */
       
   180     void Play( CHWRMHaptics* aHaptics,
       
   181                TInt  aFileHandle,
       
   182                TInt aEffectIndex,
       
   183                TInt& aEffectHandle,
       
   184                TRequestStatus& aClientStatus );
       
   185  
       
   186 public:
       
   187 
       
   188     /**
       
   189      * From CActive
       
   190      */
       
   191     virtual void RunL();
       
   192     
       
   193     /**
       
   194      * From CActive
       
   195      */
       
   196     virtual void DoCancel();
       
   197 
       
   198     /**
       
   199      * From CActive
       
   200      */
       
   201     virtual TInt RunError( TInt aError ); 
       
   202  
       
   203 private:
       
   204 
       
   205     /**
       
   206      * Pointer to the CHapticsClientTest.
       
   207      * Not owned.
       
   208      */
       
   209     CHapticsClientTest* iMTCallback;
       
   210     
       
   211     TRequestStatus* iClientStatus;
       
   212     };
       
   213 
       
   214 
       
   215 #endif      //  HAPTICSCLIENTTEST_H