hwrmhaptics/hapticsclient/inc/hwrmhapticsimpl.h
changeset 0 4e1aa6a622a0
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:  Header file of haptics client implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_HWRMHAPTICSIMPL_H
       
    20 #define C_HWRMHAPTICSIMPL_H
       
    21 
       
    22 #include <hwrmhaptics.h>
       
    23 #include "hwrmhapticssession.h"
       
    24 
       
    25 class CHWRMHapticsIVTDataCache;
       
    26 class MHWRMHapticsPacketizer;
       
    27 class CHWRMHapticsStatusObserver;
       
    28 class CHWRMHapticsEffectDataGetter;
       
    29 
       
    30 /**
       
    31 *  Haptics client side implementation.
       
    32 *
       
    33 *  @lib hwrmhapticsclient.lib
       
    34 *  @since S60 5.1
       
    35 */
       
    36 NONSHARABLE_CLASS( CHWRMHapticsImpl ) : public CHWRMHaptics
       
    37     { 
       
    38 public:
       
    39     
       
    40     /**
       
    41      * C++ constructor.
       
    42      */
       
    43     CHWRMHapticsImpl();
       
    44 
       
    45     /**
       
    46      * Second phase construction.
       
    47      * 
       
    48      * @param aHapticsCallback @see CHWRMHaptics
       
    49      * @param aActuatorCallback @see CHWRMHaptics
       
    50      */
       
    51     void ConstructL( MHWRMHapticsObserver* aHapticsCallback, 
       
    52                      MHWRMHapticsActuatorObserver* aActuatorCallback );
       
    53                      
       
    54     /**
       
    55      * Second phase construction, asynchronous.
       
    56      * 
       
    57      * @param aHapticsCallback @see CHWRMHaptics
       
    58      * @param aActuatorCallback @see CHWRMHaptics
       
    59      * @param aStatus @see CHWRMHaptics
       
    60      */
       
    61     void ConstructL( MHWRMHapticsObserver* aHapticsCallback, 
       
    62                      MHWRMHapticsActuatorObserver* aActuatorCallback,
       
    63                      TRequestStatus& aStatus );
       
    64 
       
    65     /**
       
    66      * Destructor.
       
    67      */
       
    68     virtual ~CHWRMHapticsImpl();
       
    69 
       
    70 public: // Functions from base classes
       
    71 
       
    72     /**
       
    73      * From base class CHWRMHaptics.
       
    74      * @see CHWRMHaptics
       
    75      */
       
    76     virtual void OpenActuatorL( THWRMLogicalActuators aActuator );
       
    77 
       
    78     /**
       
    79      * From base class CHWRMHaptics.
       
    80      * @see CHWRMHaptics
       
    81      */
       
    82     virtual TInt SupportedActuators( TUint32& aActuators );
       
    83 
       
    84     /**
       
    85      * From base class CHWRMHaptics.
       
    86      * @see CHWRMHaptics
       
    87      */
       
    88     virtual void ReserveHapticsL();
       
    89 
       
    90     /**
       
    91      * From base class CHWRMHaptics.
       
    92      * @see CHWRMHaptics
       
    93      */
       
    94     virtual void ReserveHapticsL( TBool aForceNoCCoeEnv );
       
    95 
       
    96     /**
       
    97      * From base class CHWRMHaptics.
       
    98      * @see CHWRMHaptics
       
    99      */
       
   100     virtual void ReleaseHaptics();
       
   101 
       
   102     /**
       
   103      * From base class CHWRMHaptics.
       
   104      * @see CHWRMHaptics
       
   105      */
       
   106     virtual MHWRMHapticsObserver::THWRMHapticsStatus HapticsStatus() const;
       
   107 
       
   108     /**
       
   109      * From base class CHWRMHaptics.
       
   110      * @see CHWRMHaptics
       
   111      */
       
   112     virtual TInt SetDeviceProperty( TInt aDevicePropertyType, 
       
   113                                     TInt aDevicePropertyValue );
       
   114 
       
   115     /**
       
   116      * From base class CHWRMHaptics.
       
   117      * @see CHWRMHaptics
       
   118      */
       
   119     virtual TInt SetDeviceProperty( TInt aDevicePropertyType, 
       
   120                                     const TDesC8& aDevicePropertyValue );
       
   121 
       
   122     /**
       
   123      * From base class CHWRMHaptics.
       
   124      * @see CHWRMHaptics
       
   125      */
       
   126     virtual TInt GetDeviceProperty( TInt aDevicePropertyType, 
       
   127                                     TInt& aDevicePropertyValue );
       
   128 
       
   129     /**
       
   130      * From base class CHWRMHaptics.
       
   131      * @see CHWRMHaptics
       
   132      */
       
   133     virtual TInt GetDeviceProperty( TInt aDevicePropertyType, 
       
   134                                     TDes8& aDevicePropertyValue );
       
   135 
       
   136     /**
       
   137      * From base class CHWRMHaptics.
       
   138      * @see CHWRMHaptics
       
   139      */
       
   140     virtual TInt GetDeviceCapability( TInt aDeviceCapabilityType, 
       
   141                                       TInt& aDeviceCapabilityValue );
       
   142 
       
   143     /**
       
   144      * From base class CHWRMHaptics.
       
   145      * @see CHWRMHaptics
       
   146      */
       
   147     virtual TInt GetDeviceCapability( TInt aDeviceCapabilityType, 
       
   148                                       TDes8& aDeviceCapabilityValue );
       
   149 
       
   150     /**
       
   151      * From base class CHWRMHaptics.
       
   152      * @see CHWRMHaptics
       
   153      */
       
   154     virtual TInt GetEffectState( TInt aEffectHandle, TInt& aEffectState );
       
   155 
       
   156     /**
       
   157      * From base class CHWRMHaptics.
       
   158      * @see CHWRMHaptics
       
   159      */
       
   160     virtual TInt CreateStreamingEffect( TInt& aEffectHandle );
       
   161 
       
   162     /**
       
   163      * From base class CHWRMHaptics.
       
   164      * @see CHWRMHaptics
       
   165      */
       
   166     virtual TInt PlayStreamingSample( TInt aEffectHandle, 
       
   167                                       const TDesC8& aStreamingSample );
       
   168 
       
   169     /**
       
   170      * From base class CHWRMHaptics.
       
   171      * @see CHWRMHaptics
       
   172      */
       
   173     virtual void PlayStreamingSample( TInt aEffectHandle, 
       
   174                                       const TDesC8& aStreamingSample, 
       
   175                                       TRequestStatus& aStatus );
       
   176 
       
   177     /**
       
   178      * From base class CHWRMHaptics.
       
   179      * @see CHWRMHaptics
       
   180      */
       
   181     virtual TInt PlayStreamingSampleWithOffset( 
       
   182                                     TInt aEffectHandle, 
       
   183                                     const TDesC8& aStreamingSample, 
       
   184                                     TInt aOffsetTime );
       
   185 
       
   186     /**
       
   187      * From base class CHWRMHaptics.
       
   188      * @see CHWRMHaptics
       
   189      */
       
   190     virtual void PlayStreamingSampleWithOffset( 
       
   191                                     TInt aEffectHandle, 
       
   192                                     const TDesC8& aStreamingSample, 
       
   193                                     TInt aOffsetTime, 
       
   194                                     TRequestStatus& aStatus );
       
   195 
       
   196     /**
       
   197      * From base class CHWRMHaptics.
       
   198      * @see CHWRMHaptics
       
   199      */
       
   200     virtual TInt DestroyStreamingEffect( TInt aEffectHandle );
       
   201 
       
   202     /**
       
   203      * From base class CHWRMHaptics.
       
   204      * @see CHWRMHaptics
       
   205      */
       
   206     virtual TInt ModifyPlayingMagSweepEffect( 
       
   207         TInt aEffectHandle, 
       
   208         const THWRMHapticsMagSweepEffect& aEffect );
       
   209 
       
   210     /**
       
   211      * From base class CHWRMHaptics.
       
   212      * @see CHWRMHaptics
       
   213      */
       
   214     virtual void ModifyPlayingMagSweepEffect( 
       
   215         TInt aEffectHandle, 
       
   216         const THWRMHapticsMagSweepEffect& aEffect, 
       
   217         TRequestStatus& aStatus );
       
   218 
       
   219     /**
       
   220      * From base class CHWRMHaptics.
       
   221      * @see CHWRMHaptics
       
   222      */
       
   223     virtual TInt ModifyPlayingPeriodicEffect( 
       
   224         TInt aEffectHandle, 
       
   225         const THWRMHapticsPeriodicEffect& aEffect );
       
   226 
       
   227     /**
       
   228      * From base class CHWRMHaptics.
       
   229      * @see CHWRMHaptics
       
   230      */
       
   231     virtual void ModifyPlayingPeriodicEffect( 
       
   232         TInt aEffectHandle,
       
   233         const THWRMHapticsPeriodicEffect& aEffect, 
       
   234         TRequestStatus& aStatus );
       
   235     
       
   236     /**
       
   237      * From base class CHWRMHaptics.
       
   238      * @see CHWRMHaptics
       
   239      */
       
   240     virtual TInt LoadEffectData( const TDesC8& aData, TInt& aFileHandle );
       
   241 
       
   242     /**
       
   243      * From base class CHWRMHaptics.
       
   244      * @see CHWRMHaptics
       
   245      */
       
   246     virtual TInt DeleteEffectData( TInt aFileHandle );
       
   247 
       
   248     /**
       
   249      * From base class CHWRMHaptics.
       
   250      * @see CHWRMHaptics
       
   251      */
       
   252     virtual TInt DeleteAllEffectData();
       
   253 
       
   254     /**
       
   255      * From base class CHWRMHaptics.
       
   256      * @see CHWRMHaptics
       
   257      */
       
   258     virtual TInt PlayEffect( TInt aFileHandle, 
       
   259                              TInt aEffectIndex, 
       
   260                              TInt& aEffectHandle );
       
   261 
       
   262     /**
       
   263      * From base class CHWRMHaptics.
       
   264      * @see CHWRMHaptics
       
   265      */
       
   266     virtual void PlayEffect( TInt aFileHandle, 
       
   267                              TInt aEffectIndex, 
       
   268                              TInt& aEffectHandle, 
       
   269                              TRequestStatus& aStatus );
       
   270 
       
   271     /**
       
   272      * From base class CHWRMHaptics.
       
   273      * @see CHWRMHaptics
       
   274      */
       
   275     virtual TInt PlayEffectRepeat( TInt aFileHandle, 
       
   276                                    TInt aEffectIndex, 
       
   277                                    TUint8 aRepeat, 
       
   278                                    TInt& aEffectHandle );
       
   279 
       
   280     /**
       
   281      * From base class CHWRMHaptics.
       
   282      * @see CHWRMHaptics
       
   283      */
       
   284     virtual void PlayEffectRepeat( TInt aFileHandle, 
       
   285                                    TInt aEffectIndex, 
       
   286                                    TUint8 aRepeat, 
       
   287                                    TInt& aEffectHandle, 
       
   288                                    TRequestStatus& aStatus );
       
   289 
       
   290     /**
       
   291      * From base class CHWRMHaptics.
       
   292      * @see CHWRMHaptics
       
   293      */
       
   294     virtual TInt PlayEffect( const TDesC8& aData, 
       
   295                              TInt aEffectIndex, 
       
   296                              TInt& aEffectHandle );
       
   297 
       
   298     /**
       
   299      * From base class CHWRMHaptics.
       
   300      * @see CHWRMHaptics
       
   301      */
       
   302     virtual void PlayEffect( const TDesC8& aData,
       
   303                              TInt aEffectIndex, 
       
   304                              TInt& aEffectHandle, 
       
   305                              TRequestStatus& aStatus );
       
   306 
       
   307     /**
       
   308      * From base class CHWRMHaptics.
       
   309      * @see CHWRMHaptics
       
   310      */
       
   311     virtual TInt PlayEffectRepeat( const TDesC8& aData, 
       
   312                                    TInt aEffectIndex, 
       
   313                                    TUint8 aRepeat, 
       
   314                                    TInt& aEffectHandle );
       
   315 
       
   316     /**
       
   317      * From base class CHWRMHaptics.
       
   318      * @see CHWRMHaptics
       
   319      */
       
   320     virtual void PlayEffectRepeat( const TDesC8& aData, 
       
   321                                    TInt aEffectIndex, 
       
   322                                    TUint8 aRepeat, 
       
   323                                    TInt& aEffectHandle, 
       
   324                                    TRequestStatus& aStatus );
       
   325 
       
   326     /**
       
   327      * From base class CHWRMHaptics.
       
   328      * @see CHWRMHaptics
       
   329      */
       
   330     virtual TInt PlayMagSweepEffect( 
       
   331         const THWRMHapticsMagSweepEffect& aEffect, 
       
   332         TInt& aEffectHandle );
       
   333 
       
   334     /**
       
   335      * From base class CHWRMHaptics.
       
   336      * @see CHWRMHaptics
       
   337      */
       
   338     virtual void PlayMagSweepEffect( 
       
   339         const THWRMHapticsMagSweepEffect& aEffect,
       
   340         TInt& aEffectHandle, 
       
   341         TRequestStatus& aStatus );
       
   342 
       
   343     /**
       
   344      * From base class CHWRMHaptics.
       
   345      * @see CHWRMHaptics
       
   346      */
       
   347     virtual TInt PlayPeriodicEffect( 
       
   348         const THWRMHapticsPeriodicEffect& aEffect,
       
   349         TInt& aEffectHandle );
       
   350 
       
   351     /**
       
   352      * From base class CHWRMHaptics.
       
   353      * @see CHWRMHaptics
       
   354      */
       
   355     virtual void PlayPeriodicEffect( 
       
   356         const THWRMHapticsPeriodicEffect& aEffect,
       
   357         TInt& aEffectHandle,
       
   358         TRequestStatus& aStatus );
       
   359 
       
   360     /**
       
   361      * From base class CHWRMHaptics.
       
   362      * @see CHWRMHaptics
       
   363      */
       
   364     virtual TInt PausePlayingEffect( TInt aEffectHandle );
       
   365 
       
   366     /**
       
   367      * From base class CHWRMHaptics.
       
   368      * @see CHWRMHaptics
       
   369      */
       
   370     virtual TInt ResumePausedEffect( TInt aEffectHandle );
       
   371 
       
   372     /**
       
   373      * From base class CHWRMHaptics.
       
   374      * @see CHWRMHaptics
       
   375      */
       
   376     virtual TInt StopPlayingEffect( TInt aEffectHandle );
       
   377 
       
   378     /**
       
   379      * From base class CHWRMHaptics.
       
   380      * @see CHWRMHaptics
       
   381      */
       
   382     virtual TInt StopAllPlayingEffects();
       
   383 
       
   384     /**
       
   385      * From base class CHWRMHaptics.
       
   386      * @see CHWRMHaptics
       
   387      */
       
   388     virtual TInt GetEffectCount ( TInt aFileHandle, 
       
   389                                   TInt& aCount ) const;
       
   390 
       
   391     /**
       
   392      * From base class CHWRMHaptics.
       
   393      * @see CHWRMHaptics
       
   394      */
       
   395     virtual TInt GetEffectDuration ( TInt aFileHandle,
       
   396                                      TInt aEffectIndex,
       
   397                                      TInt& aEffectDuration ) const;
       
   398 
       
   399     /**
       
   400      * From base class CHWRMHaptics.
       
   401      * @see CHWRMHaptics
       
   402      */
       
   403     virtual TInt GetEffectIndexFromName ( 
       
   404         TInt aFileHandle,
       
   405         const TDesC8& aEffectName,
       
   406         TInt& aEffectIndex ) const;
       
   407 
       
   408     /**
       
   409      * From base class CHWRMHaptics.
       
   410      * @see CHWRMHaptics
       
   411      */
       
   412     virtual TInt GetEffectType( TInt aFileHandle,
       
   413                                 TInt aEffectIndex,
       
   414                                 TInt& aEffectType ) const;
       
   415 
       
   416     /**
       
   417      * From base class CHWRMHaptics.
       
   418      * @see CHWRMHaptics
       
   419      */
       
   420     virtual TInt GetEffectName( TInt aFileHandle,
       
   421                                 TInt aEffectIndex,
       
   422                                 TDes8& aEffectName ) const;
       
   423 
       
   424     /**
       
   425      * From base class CHWRMHaptics.
       
   426      * @see CHWRMHaptics
       
   427      */
       
   428     virtual TInt GetMagSweepEffectDefinition( 
       
   429         TInt aFileHandle,
       
   430         TInt aEffectIndex,
       
   431         THWRMHapticsMagSweepEffect& aEffect ) const;
       
   432 
       
   433     /**
       
   434      * From base class CHWRMHaptics.
       
   435      * @see CHWRMHaptics
       
   436      */
       
   437     virtual TInt GetPeriodicEffectDefinition( 
       
   438         TInt aFileHandle,
       
   439         TInt aEffectIndex,
       
   440         THWRMHapticsPeriodicEffect& aEffect ) const;
       
   441 
       
   442     /**
       
   443      * From base class CHWRMHaptics.
       
   444      * @see CHWRMHaptics
       
   445      */
       
   446     virtual TInt InfiniteRepeat() const;
       
   447 
       
   448     /**
       
   449      * From base class CHWRMHaptics.
       
   450      * @see CHWRMHaptics
       
   451      */
       
   452     virtual TInt InfiniteDuration() const;
       
   453 
       
   454     /**
       
   455      * From base class CHWRMHaptics.
       
   456      * @see CHWRMHaptics
       
   457      */
       
   458     virtual TInt MaxEffectNameLength() const;
       
   459 
       
   460     /**
       
   461      * From base class CHWRMHaptics.
       
   462      * @see CHWRMHaptics
       
   463      */
       
   464     virtual TInt MaxDeviceNameLength() const;
       
   465 
       
   466     /**
       
   467      * From base class CHWRMHaptics.
       
   468      * @see CHWRMHaptics
       
   469      */
       
   470     virtual TInt MaxCapabilityStringLength() const;
       
   471 
       
   472     /**
       
   473      * From base class CHWRMHaptics.
       
   474      * @see CHWRMHaptics
       
   475      */
       
   476     virtual TInt MaxPropertyStringLength() const;
       
   477 
       
   478     /**
       
   479      * From base class CHWRMHaptics.
       
   480      * @see CHWRMHaptics
       
   481      */
       
   482     virtual TInt MaxStreamingSampleSize() const;
       
   483 
       
   484     /**
       
   485      * From base class CHWRMHaptics.
       
   486      * @see CHWRMHaptics
       
   487      */
       
   488     virtual TInt DefaultDevicePriority() const;
       
   489 
       
   490 private:
       
   491 
       
   492     /**
       
   493      * Sends haptics reservation command to haptics server, if
       
   494      * not reserved already.
       
   495      *
       
   496      * @param aForceNoCCoeEnv @see ReserveHapticsL
       
   497      * 
       
   498      * @return KErrNone if successful, otherwise a System wide error code.
       
   499      */
       
   500     TInt DoReserveHaptics( TBool aForceNoCCoeEnv );
       
   501 
       
   502     /**
       
   503      * Sends haptics release command to haptics server, if
       
   504      * haptics is reserved.
       
   505      */
       
   506     void DoReleaseHaptics();
       
   507 
       
   508     /**
       
   509      * Resets the internal iEffectHandlePckg package with the given value.
       
   510      * 
       
   511      * The packages a used in asynchronous IPC-commands, so that the value 
       
   512      * stays available after the call returns (i.e. local variables cannot 
       
   513      * be used).
       
   514      *
       
   515      * @param aNewValue Value for the new instance of the package.
       
   516      */
       
   517     void ResetIntPckg( TInt& aNewValue );
       
   518 
       
   519     /**
       
   520      * Finalizes the construction.
       
   521      *
       
   522      * @param aHapticsCallback @see CHWRMHaptics
       
   523      * @param aActuatorCallback @see CHWRMHaptics
       
   524      */
       
   525     void FinalizeL( MHWRMHapticsObserver* aHapticsCallback,
       
   526                     MHWRMHapticsActuatorObserver* aActuatorCallback );
       
   527 
       
   528 private:
       
   529 
       
   530     /**
       
   531      * Wrapper for client side session object. Handles also 
       
   532      * server startup.
       
   533      */
       
   534     RHWRMHapticsSession iClient;
       
   535     
       
   536     /**
       
   537      * Message packetizer. Owned.
       
   538      */
       
   539     MHWRMHapticsPacketizer* iPacketizer;
       
   540 
       
   541     /**
       
   542      * Haptics status observer pointer. Owned.
       
   543      */
       
   544     CHWRMHapticsStatusObserver* iStatusObserver;
       
   545     
       
   546     /**
       
   547      * Indicates whether or not haptics is reserved for this client.
       
   548      */
       
   549     TBool iReserved;
       
   550 
       
   551     /**
       
   552      * Whether or not to use automatic reservation/release
       
   553      * on focus gain/lost.
       
   554      */
       
   555     TBool iAutoReserve;
       
   556 
       
   557     /**
       
   558      * Request data buffer for sending commands to server.
       
   559      */
       
   560     RBuf8 iReqData;
       
   561 
       
   562     /**
       
   563      * Device handle received, when an actuator is opened.
       
   564      */
       
   565     TInt iDeviceHandle;
       
   566     
       
   567     /**
       
   568      * The type of the currently open actuator. If none has been
       
   569      * opened successfully, the type is EHWRMLogicalActuatorLast.
       
   570      */
       
   571     THWRMLogicalActuators iOpenedActuator;
       
   572 
       
   573     /**
       
   574      * Package used to receive effect handle in asynchronous calls
       
   575      * to server.
       
   576      */
       
   577     TPckg<TInt> iEffectHandlePckg;
       
   578 
       
   579     /**
       
   580      * IVT-data cache.
       
   581      * Owned.
       
   582      */
       
   583     CHWRMHapticsIVTDataCache* iIVTDataCache;
       
   584     
       
   585     /**
       
   586      * Effect data getter.
       
   587      * Owned.
       
   588      */
       
   589     CHWRMHapticsEffectDataGetter* iEffectDataGetter;
       
   590     };
       
   591     
       
   592 #endif // C_HWRMHAPTICSIMPL_H   
       
   593             
       
   594 // End of File