|
1 /* |
|
2 * Copyright (c) 2005-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 HWRMVIBRACOMMONSERVICE_H |
|
27 #define HWRMVIBRACOMMONSERVICE_H |
|
28 |
|
29 // INCLUDES |
|
30 #include <e32base.h> |
|
31 #include "HWRMVibra.h" |
|
32 #include "HWRMService.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TInt KUseDefaultIntensity = KMaxTInt; |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CHWRMPluginHandler; |
|
39 class CHWRMReservationHandler; |
|
40 |
|
41 // CLASS DECLARATIONS |
|
42 class TVibraClientData |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * C++ constructor. |
|
47 */ |
|
48 TVibraClientData( CHWRMService* aClient, TSecureId aSid, TInt aIntensity ) |
|
49 : iClient( aClient ), |
|
50 iSid( aSid ), |
|
51 iIntensity( aIntensity ) |
|
52 { |
|
53 }; |
|
54 |
|
55 CHWRMService* iClient; // Session from which request comes. Not owned. |
|
56 TSecureId iSid; |
|
57 TInt iIntensity; |
|
58 }; |
|
59 |
|
60 |
|
61 /** |
|
62 * Hardware Resource Manager server side service object for all Vibra sessions. |
|
63 * Purpose of this function is to keep track of actively vibrating clients |
|
64 * and their data. When pulse API is used, it is specified that any ongoing vibration |
|
65 * will be continued after pulse, if there is still time remaining for it. Each client |
|
66 * has own service and this service keeps track of overlapping vibrations within service. |
|
67 * However, one client may interrupt another client's vibration and that is why there |
|
68 * must be common place to keep track of overlapping vibrations. |
|
69 */ |
|
70 class CHWRMVibraCommonService : public CHWRMService |
|
71 { |
|
72 public: // Constructors and Destructor |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 * |
|
77 * @param aPluginHandler The plugin handler to use with this service. |
|
78 * @param aReservationHandler The reservation handler to use with this service. |
|
79 */ |
|
80 static CHWRMVibraCommonService* NewL(CHWRMPluginHandler* aPluginHandler, |
|
81 CHWRMReservationHandler* aReservationHandler); |
|
82 |
|
83 /** |
|
84 * Destructor. |
|
85 */ |
|
86 virtual ~CHWRMVibraCommonService(); |
|
87 |
|
88 public: // Base class methods |
|
89 |
|
90 // From CHWRMService |
|
91 virtual TBool ExecuteMessageL(const RMessage2& aMessage); |
|
92 virtual void ProcessResponseL( TInt aCommandId, TUint8 aTransId, TDesC8& aData, TBool aTimeout ); |
|
93 virtual void SuspendSubResource(TInt aSubResource); |
|
94 virtual void ResumeSubResource(TInt aSubResource); |
|
95 virtual void ActivateSubResource(TInt aSubResource, TBool aActivate); |
|
96 |
|
97 public: // New methods |
|
98 |
|
99 /** |
|
100 * Sets active vibrating client data, which can be used |
|
101 * for policing and overlapping vibrations. |
|
102 * |
|
103 * @param aData Vibra client data. |
|
104 */ |
|
105 void SetClientData( TVibraClientData aData ); |
|
106 |
|
107 /** |
|
108 * Checks whether client has vibra data. |
|
109 * |
|
110 * @param aClient Session from which reset request comes. |
|
111 * @return Indication whether this session has still requests. |
|
112 */ |
|
113 TBool HasData( CHWRMService* aClient ); |
|
114 |
|
115 /** |
|
116 * Resets active vibrating client data. |
|
117 * |
|
118 * @param aClient Session from which reset request comes. |
|
119 */ |
|
120 void ResetClientData( CHWRMService* aClient ); |
|
121 |
|
122 /** |
|
123 * Returns ETrue if active vibrating client's priority is |
|
124 * higher than asking client's priority. |
|
125 * |
|
126 * @param aSid Secure ID of client asking for priority. |
|
127 * @return Indication whether vibra execution is requested |
|
128 * by a higher priority client than this client. |
|
129 */ |
|
130 TBool ExecutingPriorityHigher(TSecureId aSid); |
|
131 |
|
132 /** |
|
133 * Returns ETrue if specified client is allowed to |
|
134 * request vibra pulse. Otherwise EFalse. |
|
135 * |
|
136 * @param aSid Secure ID of client. |
|
137 * @return Indication whether vibra pulse request |
|
138 * is allowed for this client. |
|
139 */ |
|
140 TBool VibraPulseAllowed(TSecureId aSid); |
|
141 |
|
142 private: |
|
143 |
|
144 /** |
|
145 * C++ default constructor. |
|
146 */ |
|
147 CHWRMVibraCommonService(); |
|
148 |
|
149 /** |
|
150 * By default Symbian 2nd phase constructor is private. |
|
151 */ |
|
152 void ConstructL(CHWRMPluginHandler* aPluginHandler, |
|
153 CHWRMReservationHandler* aReservationHandler); |
|
154 |
|
155 /** |
|
156 * Restarts vibration with last suspended intensity. |
|
157 */ |
|
158 void RestartVibraL(); |
|
159 |
|
160 private: // data |
|
161 |
|
162 RArray<TVibraClientData> iVibraClients; // Vibra client objects. |
|
163 // Last client requesting vibration is always added as first in list. |
|
164 }; |
|
165 |
|
166 #endif // HWRMVIBRACOMMONSERVICE_H |
|
167 |
|
168 // End of File |