|
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: Haptics policy header file. |
|
15 * This class is designed to parse the associated text file |
|
16 * and determine the HWRMHaptics clients priorities for |
|
17 * reservation of resources. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef C_HWRMHAPTICSPOLICY_H |
|
23 #define C_HWRMHAPTICSPOLICY_H |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 class RFs; |
|
28 |
|
29 /** |
|
30 * This class is intended to parse the associated priority text file and |
|
31 * provide an API to return the clients priority. |
|
32 * |
|
33 * @since S60 5.1 |
|
34 */ |
|
35 class CHWRMHapticsPolicy : public CBase |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Two-phased constructor. |
|
41 * |
|
42 * @param aFilename Filename of policy file, which should not |
|
43 * include the path as the file is stored in |
|
44 * the private directory. |
|
45 */ |
|
46 static CHWRMHapticsPolicy* NewL( const TDesC& aFilename ); |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * Leaves instance on the cleanup stack. |
|
51 * |
|
52 * @param aFilename Filename of policy file, which should not |
|
53 * include the path as the file is stored in |
|
54 * the private directory. |
|
55 */ |
|
56 static CHWRMHapticsPolicy* NewLC( const TDesC& aFilename ); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 virtual ~CHWRMHapticsPolicy(); |
|
62 |
|
63 public: |
|
64 |
|
65 /** |
|
66 * Method to retrieve the priority of a client with the given ID. |
|
67 * This ID can be the UID or SID defined in the policy file. |
|
68 * |
|
69 * @param aSid Secure id of the client. |
|
70 * @param aTrusted Returns ETrue if client is trusted, i.e. |
|
71 * it is specified in policy file. |
|
72 * @param Priority of client. If client does not exist, |
|
73 * default priority is returned. |
|
74 */ |
|
75 void GetPriority( const TSecureId aSid, TBool& aTrusted, TInt& aPriority ) const; |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * C++ constructor. |
|
81 */ |
|
82 CHWRMHapticsPolicy(); |
|
83 |
|
84 /** |
|
85 * By default Symbian 2nd phase constructor is private. |
|
86 * |
|
87 * @param aFilename Filename of policy file, which should not |
|
88 * include the path as the file is stored in |
|
89 * the private directory. |
|
90 */ |
|
91 void ConstructL( const TDesC& aFilename ); |
|
92 |
|
93 /** |
|
94 * Method constructs the array of policy clients from the |
|
95 * given stream (usually an RFileReadStream) |
|
96 * |
|
97 * @param aFs File server session |
|
98 * @param aFilename Filename to read |
|
99 */ |
|
100 void ParsePriorityFileL( RFs& aFs, const TDesC& aFilename ); |
|
101 |
|
102 /** |
|
103 * Helper method to convert and validate SID from a descriptor. |
|
104 * |
|
105 * @param aSidDes The Sid to be converted |
|
106 * @param aSid Reference that will contain the SID |
|
107 * @return KErrNone if successful, KErrCorrupt if invalid |
|
108 */ |
|
109 TInt ConvertId( const TDesC8& aSidDes, TSecureId& aSid ) const; |
|
110 |
|
111 /** |
|
112 * Adds a policy client to the array, first checks that no other |
|
113 * client has been registered with the identical id. If one already |
|
114 * exists KErrAlreadyExists is returned. |
|
115 * |
|
116 * @param aPriority Clients priority |
|
117 * @param aSid Clients SID or KAllPolicySid |
|
118 * @param aFeedbackClient Indication whether feedback client |
|
119 * @param aAppName Clients application name |
|
120 * @return KErrNone if successful |
|
121 * KErrAlreadyExists if client id already exists |
|
122 */ |
|
123 TInt AddPolicyClientL( const TInt aPriority, const TSecureId& aSid, |
|
124 const TBool aFeedbackClient, |
|
125 const TDesC8& aAppName ); |
|
126 |
|
127 /** |
|
128 * Searches for client with the given id. |
|
129 * |
|
130 * @param aSid Clients SID or KAllPolicySid. |
|
131 * @return Client position in iClientArray, |
|
132 * KErrNotFound if client does not exist. |
|
133 */ |
|
134 TInt FindClient( const TSecureId& aSid ) const; |
|
135 |
|
136 private: |
|
137 |
|
138 /** |
|
139 * Embedded class to contain policy client data intended |
|
140 * to be read from the policy file. |
|
141 * |
|
142 * @since S60 5.1 |
|
143 */ |
|
144 class CPolicyClient : public CBase |
|
145 { |
|
146 public: |
|
147 |
|
148 /** |
|
149 * Two-phased constructor. |
|
150 * |
|
151 * @param aPriority Clients priority |
|
152 * @param aSid Clients SID or KAllPolicySid |
|
153 * @param aFeedbackClient Indication whether feedback client |
|
154 * @param aAppName Clients application name |
|
155 */ |
|
156 static CPolicyClient* NewL( const TInt aPriority, |
|
157 const TSecureId& aSid, |
|
158 const TBool aFeedbackClient, |
|
159 const TDesC8& aAppName ); |
|
160 |
|
161 /** |
|
162 * Two-phased constructor. |
|
163 * Leaves instance on the cleanup stack. |
|
164 * |
|
165 * @param aPriority Clients priorty |
|
166 * @param aSid Clients SID or KAllPolicySid |
|
167 * @param aFeedbackClient Indication whether feedback client |
|
168 * @param aAppName Clients application name |
|
169 */ |
|
170 static CPolicyClient* NewLC( const TInt aPriority, |
|
171 const TSecureId& aSid, |
|
172 const TBool aFeedbackClient, |
|
173 const TDesC8& aAppName ); |
|
174 |
|
175 /** |
|
176 * Destructor. |
|
177 */ |
|
178 virtual ~CPolicyClient(); |
|
179 |
|
180 public: |
|
181 |
|
182 /** |
|
183 * Method to return the clients priority. |
|
184 * |
|
185 * @return Priority of client |
|
186 */ |
|
187 TInt Priority() const; |
|
188 |
|
189 /** |
|
190 * Returns the client's SID. |
|
191 * |
|
192 * @return SID of client |
|
193 */ |
|
194 TSecureId Sid() const; |
|
195 |
|
196 /** |
|
197 * Returns indication whether feedback client. |
|
198 * |
|
199 * @return ETrue if feedback client, otherwise EFalse. |
|
200 */ |
|
201 TBool FeedbackClient() const; |
|
202 |
|
203 /** |
|
204 * Returns the client application name. |
|
205 * |
|
206 * @return Application name of the client. |
|
207 */ |
|
208 const TDesC& AppName() const; |
|
209 |
|
210 private: |
|
211 |
|
212 /** |
|
213 * C++ constructor. |
|
214 * |
|
215 * @param aPriority Clients priority |
|
216 * @param aSid Clients SID or KAllPolicySid |
|
217 * @param aFeedbackClient Indication whether feedback client. |
|
218 */ |
|
219 CPolicyClient( const TInt aPriority, |
|
220 const TSecureId& aSid, |
|
221 const TBool aFeedbackClient ); |
|
222 |
|
223 /** |
|
224 * By default Symbian 2nd phase constructor is private. |
|
225 * |
|
226 * @param aAppName Clients application name |
|
227 */ |
|
228 void ConstructL( const TDesC8& aAppName ); |
|
229 |
|
230 private: // Data |
|
231 |
|
232 /** |
|
233 * Priority of client |
|
234 */ |
|
235 TInt iPriority; |
|
236 |
|
237 /** |
|
238 * SID of client |
|
239 */ |
|
240 TSecureId iSid; |
|
241 |
|
242 /** |
|
243 * Whether or not the client is tactile feedback clien. |
|
244 */ |
|
245 TBool iFeedbackClient; |
|
246 |
|
247 /** |
|
248 * Client's application name. Owned. |
|
249 */ |
|
250 HBufC* iAppName; |
|
251 }; |
|
252 |
|
253 private: |
|
254 |
|
255 /** |
|
256 * Array of objects representing each client from the policy file. |
|
257 */ |
|
258 RPointerArray<CPolicyClient> iClientArray; |
|
259 }; |
|
260 |
|
261 #endif // C_HWRMHAPTICSPOLICY_H |
|
262 |
|
263 // End of File |