resourcemgmt/hwresourcesmgr/server/inc/HWRMVibraCommonData.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalTechnology 
       
    24 */
       
    25 
       
    26 #ifndef HWRMVIBRACOMMONDATA_H
       
    27 #define HWRMVIBRACOMMONDATA_H
       
    28 
       
    29 //  INCLUDES
       
    30 #include <e32base.h>
       
    31 #include "HWRMVibraProfileObserver.h"
       
    32 #include "HWRMVibra.h"
       
    33 #include <e32property.h>
       
    34 #include "HWRMPSChangeObserver.h"
       
    35 #include "HWRMVibraCommonService.h"
       
    36 
       
    37 
       
    38 
       
    39 // CONSTANTS
       
    40 // None
       
    41 
       
    42 // MACROS
       
    43 // None
       
    44 
       
    45 // DATA TYPES
       
    46 // None
       
    47 
       
    48 // FUNCTION PROTOTYPES
       
    49 // None
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 class CHWRMPluginHandler;
       
    53 class CHWRMReservationHandler;
       
    54 class CHWRMVibraService;
       
    55 
       
    56 // CLASS DECLARATION
       
    57 /**
       
    58 * Container for vibra data that is common for all sessions.
       
    59 * Also handles vibra related cenrep and PS data.
       
    60 * HWRM server upkeeps the instance.
       
    61 *
       
    62 */
       
    63 class CHWRMVibraCommonData : public CBase,
       
    64                              public MHWRMVibraProfileObserver,
       
    65                              public MHWRMPSChangeObserver
       
    66     {
       
    67     public: // Constructors and Destructor
       
    68     
       
    69         /**
       
    70         * Two-phased constructor.
       
    71         *
       
    72         * @param aPluginHandler Pointer to plugin handler for vibra
       
    73         * @param aReservationHandler Pointer to reservation handler for vibra
       
    74         * @param aCommonService Common vibra service instance for all sessions
       
    75         */
       
    76         static CHWRMVibraCommonData* NewL(CHWRMPluginHandler* aPluginHandler,
       
    77                                           CHWRMReservationHandler* aReservationHandler,
       
    78                                           CHWRMVibraCommonService& aCommonService);
       
    79 
       
    80         /**
       
    81         * Destructor.
       
    82         */
       
    83         virtual ~CHWRMVibraCommonData();
       
    84         
       
    85     public: // New functions
       
    86     
       
    87         /**
       
    88         * Getter for maximum time of vibra can be on in one go
       
    89         * before it is automatically turned off.
       
    90         *
       
    91         * @return Maximum on time for vibra 
       
    92         */
       
    93         inline TTimeIntervalMicroSeconds32 MaximumOnTime() const;
       
    94 
       
    95 
       
    96         /**
       
    97         * Getter for feedback default intensity.
       
    98         *
       
    99         * @return Feedback default intensity
       
   100         */
       
   101         inline TInt FeedbackDefaultIntensity() const;
       
   102 
       
   103         /**
       
   104         * Getter for feedback default duration.
       
   105         *
       
   106         * @return Feedback default duration
       
   107         */
       
   108         inline TInt FeedbackDefaultDuration() const;
       
   109 
       
   110         /**
       
   111         * Getter for pulse feedback support.
       
   112         *
       
   113         * @return Feedback default duration
       
   114         */
       
   115         inline TInt FeedbackPulseSupported() const;
       
   116 
       
   117 
       
   118         /**
       
   119         * Getter for vibra setting flag from profile settings.
       
   120         *
       
   121         * @return Vibra profile setting state
       
   122         */
       
   123         CHWRMVibra::TVibraModeState VibraState();
       
   124         
       
   125         /**
       
   126         * Getter for vibra feedback setting flag from profile settings.
       
   127         *
       
   128         * @return Vibra feedback profile setting state
       
   129         */
       
   130         CHWRMVibra::TVibraFeedbackModeState VibraFeedbackState();
       
   131         
       
   132 
       
   133         /**
       
   134         * Checks if vibra is blocked from being used or if it is
       
   135         * having a cool-out period.
       
   136         * 
       
   137         * @return EFalse if vibra is available, ETrue if vibra
       
   138         *         is cooling or blocked.
       
   139         */
       
   140         TBool VibraLocked() const;
       
   141 
       
   142         /**
       
   143         * Checks if vibra is blocked for some reason.
       
   144         * 
       
   145         * @return EFalse if vibra has no blocks, otherwise 
       
   146         *         p&s mask of vibra blocking source.
       
   147         */
       
   148         TInt VibraBlocked( ) const;
       
   149 
       
   150         /**
       
   151         * Checks if vibra is blocked from specified reason.
       
   152         * 
       
   153         * @param aMask Block mask to be checked.
       
   154         * @return EFalse if vibra has no blocks for specified
       
   155         *         reason, otherwise mask of vibra blocking source.
       
   156         */
       
   157         TBool VibraBlocked( TInt aMask ) const;      
       
   158 
       
   159         /**
       
   160         * Locks vibra for minimum lock period.
       
   161         */
       
   162         void LockVibra();
       
   163         
       
   164         /**
       
   165         * Publish Vibra status
       
   166         *
       
   167         * @param aStatus New Vibra status to be published.
       
   168         * @param aPrivilegedClient Indicates if client is privileged
       
   169         */
       
   170         void PublishVibraStatus(CHWRMVibra::TVibraStatus aStatus,
       
   171                                 TBool aPrivilegedClient = EFalse);
       
   172         
       
   173         /**
       
   174         * Checks if supplied SID matches privileged SID
       
   175         *
       
   176         * @param aClientSid SID to check against privileged SID
       
   177         */
       
   178         TBool IsPrivilegedSid(const TSecureId& aClientSid);
       
   179 
       
   180 
       
   181     public: // Functions from base classes
       
   182 
       
   183         // From MHWRMVibraProfileObserver
       
   184         void VibraModeChange(CHWRMVibra::TVibraModeState newState);
       
   185         void VibraFeedbackModeChange(CHWRMVibra::TVibraFeedbackModeState newState);
       
   186         
       
   187         // From MHWRMPSChangeObserver
       
   188         void PSValueChanged(const TUid& aUid, TUint32 aKey, TInt aValue);
       
   189 
       
   190     private:
       
   191     
       
   192         /**
       
   193         * C++ default constructor.
       
   194         */        
       
   195         CHWRMVibraCommonData(CHWRMVibraCommonService& aCommonService);
       
   196 
       
   197         /**
       
   198         * By default Symbian 2nd phase constructor is private.
       
   199         *
       
   200         * @param aPluginHandler Pointer to plugin handler for vibra
       
   201         * @param aReservationHandler Pointer to reservation handler for vibra
       
   202         */
       
   203         void ConstructL(CHWRMPluginHandler* aPluginHandler,
       
   204                         CHWRMReservationHandler* aReservationHandler);        
       
   205 
       
   206     private:
       
   207     
       
   208         TTimeIntervalMicroSeconds32 iMinimumOffTime;      // Minimum offtime after maximum ontime
       
   209         TTimeIntervalMicroSeconds32 iMaximumOnTime;       // Maximum continuous ontime for vibra
       
   210         CHWRMVibra::TVibraModeState iVibraSetting;        // Flag to see if vibra is enabled in profile    
       
   211         CHWRMVibra::TVibraFeedbackModeState iVibraFeedbackSetting; // Flag to see if feedback vibration is enabled in profile    
       
   212         TInt                        iFeedbackIntensity;   // Feedback vibration default intensity 
       
   213         TInt                        iFeedbackDuration;    // Feedback vibration default duration 
       
   214         CHWRMVibraProfileObserver*  iProfileObserver;     // Vibra profile observer pointer. Owned.
       
   215         TTime                       iVibraLockedUntil;    // Vibra cannot be set on before this time.
       
   216         RProperty                   iProperty;            // P&S property for publishing vibra status
       
   217         CHWRMVibraService*          iVibraService;        // Vibra service used to stop vibra when
       
   218                                                           // someone blocks it via HW Resource Blocking API
       
   219         CHWRMPSChangeObserver*      iAccessoryBlockObserver;  // Observes accessory blocking of vibra    
       
   220         CHWRMPSChangeObserver*      iInternalBlockObserver;   // Observes HWRM internal blocking of vibra    
       
   221         TUint32                     iVibraBlockMask;      // Blocking of vibra is indicated by this bitmask
       
   222         TUint32                     iConfVibraBlockMask;  // Cenrep configured vibra blocking bitmask
       
   223         TSecureId*                  iPrivilegedSid;       // Privileged secure id (client with this SID ignores profile checks)
       
   224         TBool                       iPrivilegedVibraOn;   // If privileged client has turned vibra on, this bool is set
       
   225         TBool                       iPulseSupported;      // Indication whether tactile feedback pulse command handling supported.
       
   226         CHWRMVibra::TVibraStatus    iLastPublishedStatus; // Last successfully published vibra status
       
   227         CHWRMVibraCommonService&    iCommonService;       // Vibra common service           
       
   228     };
       
   229 
       
   230 #include "HWRMVibraCommonData.inl"
       
   231 
       
   232 #endif  // HWRMVIBRACOMMONDATA_H
       
   233             
       
   234 // End of File