|
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 |
|
27 #ifndef HWRMRESERVATIONHANDLER_H |
|
28 #define HWRMRESERVATIONHANDLER_H |
|
29 |
|
30 // INCLUDES |
|
31 #include <e32base.h> |
|
32 #include "HWRMPolicy.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TInt KHWRMAllSubResources = 0; |
|
36 |
|
37 // MACROS |
|
38 // None |
|
39 |
|
40 // DATA TYPES |
|
41 // None |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 class CHWRMService; |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 /** |
|
52 * Handles reservations of single resource. |
|
53 * |
|
54 */ |
|
55 class CHWRMReservationHandler : public CBase |
|
56 { |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * |
|
62 * @param aSubResourceCount Number of subresources this handler needs |
|
63 * to be able to handle. |
|
64 * @param aPolicyFilename Policy file name. Must not include path. |
|
65 */ |
|
66 static CHWRMReservationHandler* NewL(TInt aSubResourceCount, |
|
67 const TDesC& aPolicyFilename); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CHWRMReservationHandler(); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** |
|
77 * Reserve set of subresources |
|
78 * |
|
79 * @param aMessage Message pointer for identifying the reserving client |
|
80 * @param aForceNoCCoeEnv Indicates if reservation is done in force CCoeEnv mode. |
|
81 * @param aServiceCallback The callback of service requesting reservation check. |
|
82 * @param aSubResourceMask Mask of subresources for which reservation check is done. |
|
83 * Zero means the whole resource. |
|
84 * @return SubresourceMask indicating subresources that were immediately suspended. |
|
85 * @leave KErrAccessDenied if trying to force no CCoeEnv and client is not trusted. |
|
86 */ |
|
87 TInt ReserveL(const RMessagePtr2& aMessage, TBool aForceNoCCoeEnv, CHWRMService* aServiceCallback, TInt aSubResourceMask = KHWRMAllSubResources); |
|
88 |
|
89 /** |
|
90 * Release set of subresources |
|
91 * |
|
92 * @param aServiceCallback The callback of service requesting release |
|
93 * @param aSubResourceMask Mask of subresources for which release targets. |
|
94 * Zero means the whole resource. |
|
95 * @return SubresourceMask indicating subresources that do not have any more reservations. |
|
96 * Note that this includes all unreserved subresources, not just ones among |
|
97 * aSubResourceMask subresources. |
|
98 */ |
|
99 TInt Release(CHWRMService* aServiceCallback, TInt aSubResourceMask = KHWRMAllSubResources); |
|
100 |
|
101 /** |
|
102 * Check if set of subresources is reserved. Suspended reservations are also checked. |
|
103 * |
|
104 * @param aServiceCallback The callback of service requesting reservation check. |
|
105 * @param aSubResourceMask Mask of subresources for which reservation check is done. |
|
106 * Zero means the whole resource. |
|
107 * @return ETrue if (sub)resource is reserved for some other service than the requester. |
|
108 */ |
|
109 TBool IsReserved(const CHWRMService* aServiceCallback, TInt aSubResourceMask = KHWRMAllSubResources) const; |
|
110 |
|
111 /** |
|
112 * Get unreserved targets mask |
|
113 * |
|
114 * @return target mask containing unreserved targets |
|
115 */ |
|
116 TInt GetUnreservedTargets(); |
|
117 |
|
118 /** |
|
119 * Updates active targets mask and notifies target activity state changes |
|
120 * to sessions that have active reservations. However, activation is not |
|
121 * notified to whichever session calls this method to avoid unnecessary |
|
122 * transitory light state. Deactivation must be notified also to caller, |
|
123 * if it has active reservation for that target. |
|
124 * |
|
125 * @param aOriginalTarget Original target before modification |
|
126 * @param aModifiedTarget Target after modification was applied |
|
127 * @param aUpdater Session from which the update request comes. |
|
128 */ |
|
129 void UpdateActiveMask(TInt aOriginalTarget, TInt aModifiedTarget, CHWRMService* aUpdater); |
|
130 |
|
131 /** |
|
132 * Get the active reserver for specified target |
|
133 * |
|
134 * @param aTargetIndex Single target index for which to get the reserver info. |
|
135 * @return Pointer to active reserver session or NULL. |
|
136 */ |
|
137 CHWRMService* GetActiveReserver(TInt aTargetIndex); |
|
138 |
|
139 |
|
140 /** |
|
141 * Get policy instance |
|
142 * |
|
143 * @return Pointer to policy. |
|
144 */ |
|
145 CHWRMPolicy* GetPolicy(); |
|
146 public: // Functions from base classes |
|
147 |
|
148 protected: // New functions |
|
149 |
|
150 protected: // Functions from base classes |
|
151 |
|
152 private: |
|
153 |
|
154 /** |
|
155 * C++ default constructor. |
|
156 * |
|
157 * @param aSubResourceCount Number of subresources this handler needs |
|
158 * to be able to handle. |
|
159 */ |
|
160 CHWRMReservationHandler(TInt aSubResourceCount); |
|
161 |
|
162 /** |
|
163 * By default Symbian 2nd phase constructor is private. |
|
164 * |
|
165 * @param aPolicyFilename Policy file name. Must not include path. |
|
166 */ |
|
167 void ConstructL(const TDesC& aPolicyFilename); |
|
168 |
|
169 public: // Data |
|
170 |
|
171 protected: // Data |
|
172 |
|
173 private: // Data |
|
174 |
|
175 /** |
|
176 * Embedded class to contain reservation data. |
|
177 * All data members are public as this is basically a struct. |
|
178 * |
|
179 */ |
|
180 class TReservationData |
|
181 { |
|
182 public: // Constructors and destructor |
|
183 |
|
184 /** |
|
185 * C++ constructor to initialize defaults. |
|
186 */ |
|
187 TReservationData() |
|
188 : iCallback(NULL), |
|
189 iPriority(KMaxTInt), |
|
190 iSuspendedData(NULL) |
|
191 { |
|
192 }; |
|
193 |
|
194 // data |
|
195 |
|
196 CHWRMService* iCallback; // Service callback of the reserver. Not owned. |
|
197 |
|
198 TInt iPriority; // Priority of the reservation |
|
199 TReservationData* iSuspendedData; // Link for first suspended data. Not owned. |
|
200 }; |
|
201 |
|
202 |
|
203 TInt iSubResourceCount; // Number of subresources supported. |
|
204 TInt iAllMask; // This subresource mask is used if 0 mask is specified. |
|
205 // Cannot just use constant as number of subs varies. |
|
206 CHWRMPolicy* iPolicy; // Pointer to policy. Owned. |
|
207 RPointerArray<TReservationData> iReservations; // Pointers to reservation data objects. |
|
208 // First reservation is the active one, |
|
209 // Suspended reservations are linked via iSuspendedDatas. |
|
210 // Suspended reservations naturally arrange in priority order |
|
211 // NULL value indicates that |
|
212 // selected subresource is not reserved. |
|
213 |
|
214 TInt iActiveMask; // Mask of active targets (i.e. not removed by target modifier plugin) |
|
215 |
|
216 public: // Friend classes |
|
217 |
|
218 protected: // Friend classes |
|
219 |
|
220 private: // Friend classes |
|
221 |
|
222 |
|
223 }; |
|
224 |
|
225 #endif // HWRMRESERVATIONHANDLER_H |
|
226 |
|
227 // End of File |