|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\euser\us_property.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "us_std.h" |
|
19 |
|
20 /** |
|
21 Defines a property with the specified category ID. This method should only be |
|
22 used to specify a category different from the creating process's secure ID in |
|
23 exceptional circumstances. In most cases the overload: |
|
24 |
|
25 RProperty::Define(TUint aKey, TInt aAttr, const TSecurityPolicy& aReadPolicy, const TSecurityPolicy& aWritePolicy, TInt aPreallocate) |
|
26 |
|
27 should be used. For details see the document located at: |
|
28 |
|
29 Symbian OS guide » Base » Using User Library (E32) » Publish and Subscribe » Security issues |
|
30 |
|
31 Defines the attributes and access control for a property. This can only be done |
|
32 once for each property. Subsequent attempts to define the same property will return |
|
33 KErrAlreadyExists. |
|
34 |
|
35 Only processes with the write-system-data capability are allowed to define |
|
36 properties either in the system category (KUidSystemCategory) or with |
|
37 aCategory < KUidSecurityThresholdCategoryValue. Any attempt to define |
|
38 a property with these categories by a process with insufficient capabilities |
|
39 will fail with a KErrPermissionDenied error. |
|
40 |
|
41 Following the property's definition, it will have a default value, 0 for integer |
|
42 properties and zero-length data for byte-array and text properties. |
|
43 Pending subscriptions for this property will not be completed until a new |
|
44 value is published. |
|
45 |
|
46 @param aCategory The UID that identifies the property category. |
|
47 This must either be the current process's Secure ID, or |
|
48 KUidSystemCategoryValue. |
|
49 @param aKey The property sub-key, i.e. the key that identifies the |
|
50 specific property within the category. |
|
51 @param aAttr This describes the property type, a TType value; |
|
52 persistence, as defined by the KPersistent bit, may |
|
53 be ORed in. |
|
54 @param aReadPolicy A security policy defining the security attributes a |
|
55 process must have in order to read this value. |
|
56 @param aWritePolicy A security policy defining the security attributes a |
|
57 process must have in order to write this value. |
|
58 @param aPreallocate The number of bytes to be pre-allocated for variable |
|
59 sized properties. Pre-allocating enough space ensures that |
|
60 a variable sized property can be set in 'real-time', |
|
61 (i.e. the time to set the property is bounded). |
|
62 |
|
63 @return KErrNone, if successful; |
|
64 KErrArgument, if the wrong type or attribute was specified; |
|
65 KErrArgument, if aType is TInt and aPreallocate is not 0; |
|
66 KErrTooBig, if aPreallocate is greater than KMaxPropertySize; |
|
67 KErrPermissionDenied, if an attempt is made to define a property in |
|
68 the system category by a process with insufficient capabilities, or |
|
69 the category secified wasn't the same as the current process's Secure ID. |
|
70 |
|
71 @capability WriteDeviceData if aCategory==KUidSystemCategoryValue. |
|
72 @capability WriteDeviceData if aCategory not equal to the current process's |
|
73 Secure ID and aCategory<KUidSecurityThresholdCategoryValue. |
|
74 |
|
75 |
|
76 @see KUidSecurityThresholdCategoryValue |
|
77 |
|
78 @publishedPartner |
|
79 @released |
|
80 */ |
|
81 EXPORT_C TInt RProperty::Define(TUid aCategory, TUint aKey, TInt aAttr, const TSecurityPolicy& aReadPolicy, const TSecurityPolicy& aWritePolicy, TInt aPreallocate) |
|
82 { |
|
83 if(aPreallocate < 0) |
|
84 return KErrArgument; |
|
85 if(aPreallocate > KMaxLargePropertySize) |
|
86 return KErrTooBig; |
|
87 |
|
88 TPropertyInfo info; |
|
89 info.iType = (RProperty::TType)(aAttr & RProperty::ETypeMask); |
|
90 info.iAttr = (aAttr & ~RProperty::ETypeMask); |
|
91 info.iSize = (TUint16) aPreallocate; |
|
92 info.iReadPolicy = aReadPolicy; |
|
93 info.iWritePolicy = aWritePolicy; |
|
94 return(Exec::PropertyDefine(TUint(aCategory.iUid), aKey, &info)); |
|
95 } |
|
96 |
|
97 |
|
98 /** |
|
99 Defines a property. |
|
100 |
|
101 Defines the attributes and access control for a property. This can only be done |
|
102 once for each property. Subsequent attempts to define the same property will return |
|
103 KErrAlreadyExists. |
|
104 |
|
105 The category ID for the property will be the same as the current processes Secure ID. |
|
106 |
|
107 Following the property's definition, it will have a default value, 0 for integer |
|
108 properties and zero-length data for byte-array and text properties. |
|
109 Pending subscriptions for this property will not be completed until a new |
|
110 value is published. |
|
111 |
|
112 @param aKey The property sub-key, i.e. the key that identifies the |
|
113 specific property within the category. |
|
114 @param aAttr This describes the property type, a TType value; |
|
115 persistence, as defined by the KPersistent bit, may |
|
116 be ORed in. |
|
117 @param aReadPolicy A security policy defining the security attributes a |
|
118 process must have in order to read this value. |
|
119 @param aWritePolicy A security policy defining the security attributes a |
|
120 process must have in order to write this value. |
|
121 @param aPreallocate The number of bytes to be pre-allocated for variable |
|
122 sized properties. Pre-allocating enough space ensures that |
|
123 a variable sized property can be set in 'real-time', |
|
124 (i.e. the time to set the property is bounded). |
|
125 |
|
126 @return KErrNone, if successful; |
|
127 KErrArgument, if the wrong type or attribute was specified; |
|
128 KErrArgument, if aType is TInt and aPreallocate is not 0; |
|
129 KErrTooBig, if aPreallocate is greater than KMaxPropertySize; |
|
130 |
|
131 @publishedPartner |
|
132 @released |
|
133 */ |
|
134 EXPORT_C TInt RProperty::Define(TUint aKey, TInt aAttr, const TSecurityPolicy& aReadPolicy, const TSecurityPolicy& aWritePolicy, TInt aPreallocate) |
|
135 { |
|
136 TUid category = {-1}; |
|
137 return Define(category, aKey, aAttr, aReadPolicy, aWritePolicy, aPreallocate); |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 /** |
|
143 NOTE - The use of this method is deprecated. |
|
144 |
|
145 Defines a property with the specified category ID. This method should only be |
|
146 used to specify a category different from the creating process's secure ID in |
|
147 exceptional circumstances. In most cases the overload: |
|
148 |
|
149 RProperty::Define(TUint aKey, TInt aAttr, const TSecurityPolicy& aReadPolicy, const TSecurityPolicy& aWritePolicy, TInt aPreallocate) |
|
150 |
|
151 should be used. For details see the document located at: |
|
152 |
|
153 Symbian OS guide » Base » Using User Library (E32) » Publish and Subscribe » Security issues |
|
154 |
|
155 Defines the attributes and access control for a property. This can only be done |
|
156 once for each property. Subsequent attempts to define the same property will |
|
157 return KErrAlreadyExists. |
|
158 |
|
159 Only processes with the write-system-data capability are allowed to define |
|
160 properties either in the system category (KUidSystemCategory) or with |
|
161 aCategory < KUidSecurityThresholdCategoryValue. Any attempt to define |
|
162 a property with these categories by a process with insufficient capabilities |
|
163 will fail with a KErrPermissionDenied error. |
|
164 |
|
165 Following the property's definition, it will have a default value, 0 for integer |
|
166 properties and zero-length data for byte-array and text properties. |
|
167 Pending subscriptions for this property will not be completed until a new |
|
168 value is published. |
|
169 |
|
170 @param aCategory The UID that identifies the property category. |
|
171 @param aKey The property sub-key, i.e. the key that identifies the |
|
172 specific property within the category. |
|
173 @param aAttr This describes the property type, a TType value; |
|
174 persistence, as defined by the KPersistent bit, may |
|
175 be ORed in. |
|
176 @param aPreallocate The number of bytes to be pre-allocated for variable |
|
177 sized properties. Pre-allocating enough space ensures that |
|
178 a variable sized property can be set in 'real-time', |
|
179 (i.e. the time to set the property is bounded). |
|
180 |
|
181 @return KErrNone, if successful; |
|
182 KErrArgument, if the wrong type or attribute was specified; |
|
183 KErrArgument, if aType is TInt and aPreallocate is not 0; |
|
184 KErrTooBig, if aPreallocate is greater than KMaxPropertySize; |
|
185 KErrPermissionDenied, if an attempt is made to define a property in |
|
186 the system category by a process with insufficient capabilities. |
|
187 |
|
188 @capability WriteDeviceData if aCategory==KUidSystemCategoryValue. |
|
189 @capability WriteDeviceData if aCategory not equal to the current process's |
|
190 Secure ID and aCategory<KUidSecurityThresholdCategoryValue. |
|
191 |
|
192 @see KUidSecurityThresholdCategoryValue |
|
193 @publishedAll |
|
194 @deprecated Use RProperty::Define(TUint aKey, TInt aAttr, const TSecurityPolicy &aReadPolicy, const TSecurityPolicy &aWritePolicy, TInt aPreallocated=0) |
|
195 instead. |
|
196 */ |
|
197 EXPORT_C TInt RProperty::Define(TUid aCategory, TUint aKey, TInt aAttr, TInt aPreallocate) |
|
198 { |
|
199 TPropertyInfo info; |
|
200 info.iType = (RProperty::TType)(aAttr & RProperty::ETypeMask); |
|
201 info.iAttr = (aAttr & ~RProperty::ETypeMask); |
|
202 info.iSize = (TUint16) aPreallocate; |
|
203 info.iReadPolicy = TSecurityPolicy(TSecurityPolicy::EAlwaysPass); |
|
204 info.iWritePolicy = TSecurityPolicy(TSecurityPolicy::EAlwaysPass); |
|
205 return(Exec::PropertyDefine(TUint(aCategory.iUid), aKey, &info)); |
|
206 } |
|
207 |
|
208 |
|
209 /** |
|
210 Deletes a property. |
|
211 |
|
212 This can only be called by the property owner, as defined by |
|
213 the process Security ID; any attempt by another process to delete |
|
214 the property will fail. |
|
215 |
|
216 Any pending subscriptions for this property will be completed |
|
217 with KErrNotFound. |
|
218 Any new request will not complete until the property is defined |
|
219 and published again. |
|
220 |
|
221 @param aCategory The UID that identifies the property category. |
|
222 @param aKey The property sub-key, i.e. the key that identifies the |
|
223 specific property within the category. |
|
224 |
|
225 @return KErrNone, if successful; |
|
226 KErrPermissionDenied, if a process that is not the owner of |
|
227 the property attempts to delete it. |
|
228 KErrNotFound, if the property has not been defined. |
|
229 */ |
|
230 EXPORT_C TInt RProperty::Delete(TUid aCategory, TUint aKey) |
|
231 { |
|
232 return(Exec::PropertyDelete(TUint(aCategory.iUid), aKey)); |
|
233 } |
|
234 |
|
235 |
|
236 |
|
237 /** |
|
238 Deletes a property. |
|
239 |
|
240 The category ID for the property will be the same as the current processes Secure ID. |
|
241 |
|
242 Any pending subscriptions for this property will be completed |
|
243 with KErrNotFound. |
|
244 Any new request will not complete until the property is defined |
|
245 and published again. |
|
246 |
|
247 @param aKey The property sub-key, i.e. the key that identifies the |
|
248 specific property within the category. |
|
249 |
|
250 @return KErrNone, if successful; |
|
251 KErrNotFound, if the property has not been defined. |
|
252 */ |
|
253 EXPORT_C TInt RProperty::Delete(TUint aKey) |
|
254 { |
|
255 return(Exec::PropertyDelete(KMaxTUint, aKey)); |
|
256 } |
|
257 |
|
258 |
|
259 /** |
|
260 Gets an integer property. |
|
261 |
|
262 The function gets the integer value of the specified property. |
|
263 |
|
264 The Platform Security attributes of the current process are checked against |
|
265 the Read Policy which was specified when the property was defined. |
|
266 If this check fails the action taken is determined by the system wide Platform Security |
|
267 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
268 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
269 check failed. |
|
270 |
|
271 @param aCategory The UID that identifies the property category. |
|
272 @param aKey The property sub-key, i.e. the key that identifies the |
|
273 specific property within the category. |
|
274 @param aValue A reference to the variable where the property value will |
|
275 be reported. |
|
276 |
|
277 @return KErrNone, if successful; |
|
278 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
279 KErrNotFound, if the property has not been defined; |
|
280 KErrArgument, if the property is not of integral type. |
|
281 */ |
|
282 EXPORT_C TInt RProperty::Get(TUid aCategory, TUint aKey, TInt& aValue) |
|
283 { |
|
284 return(Exec::PropertyFindGetI(TUint(aCategory.iUid), aKey, &aValue)); |
|
285 } |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 /** |
|
291 Gets a binary property. |
|
292 |
|
293 The function gets the byte-array (binary) value of the specified property. |
|
294 |
|
295 The Platform Security attributes of the current process are checked against |
|
296 the Read Policy which was specified when the property was defined. |
|
297 If this check fails the action taken is determined by the system wide Platform Security |
|
298 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
299 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
300 check failed. |
|
301 |
|
302 @param aCategory The UID that identifies the property category. |
|
303 @param aKey The property sub-key, i.e. the key that identifies the |
|
304 specific property within the category. |
|
305 @param aDes A reference to the buffer descriptor where the property value |
|
306 will be reported. |
|
307 |
|
308 @return KErrNone if successful; |
|
309 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
310 KErrNotFound, if the property has not been defined; |
|
311 KErrArgument, if the property is not a byte-array (binary) type; |
|
312 KErrOverflow, if the supplied buffer is too small to contain the full |
|
313 property value, and note that the buffer aDes contains the |
|
314 truncated property value. |
|
315 */ |
|
316 EXPORT_C TInt RProperty::Get(TUid aCategory, TUint aKey, TDes8& aDes) |
|
317 { |
|
318 TInt size = aDes.MaxSize(); |
|
319 TInt r = Exec::PropertyFindGetB(TUint(aCategory.iUid), aKey, (TUint8*) aDes.Ptr(), size); |
|
320 if (r < 0) |
|
321 { |
|
322 if (r == KErrOverflow) |
|
323 { |
|
324 aDes.SetLength(size); |
|
325 } |
|
326 return r; |
|
327 } |
|
328 aDes.SetLength(r); |
|
329 return KErrNone; |
|
330 } |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 /** |
|
336 Gets a text property. |
|
337 |
|
338 The function gets the text value of the specified property. |
|
339 |
|
340 The Platform Security attributes of the current process are checked against |
|
341 the Read Policy which was specified when the property was defined. |
|
342 If this check fails the action taken is determined by the system wide Platform Security |
|
343 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
344 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
345 check failed. |
|
346 |
|
347 @param aCategory The UID that identifies the property category. |
|
348 @param aKey The property sub-key, i.e. the key that identifies the |
|
349 specific property within the category. |
|
350 @param aDes A reference to the buffer descriptor where the property value |
|
351 will be reported. |
|
352 |
|
353 @return KErrNone, if successful; |
|
354 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
355 KErrNotFound, if the property has not been defined; |
|
356 KErrArgument, if the property is not a text type; |
|
357 KErrOverflow, if the supplied buffer is too small to contain the full |
|
358 property value, and note that the buffer aDes contains the |
|
359 truncated property value. |
|
360 */ |
|
361 EXPORT_C TInt RProperty::Get(TUid aCategory, TUint aKey, TDes16& aDes) |
|
362 { |
|
363 TInt size = aDes.MaxSize(); |
|
364 TInt r = Exec::PropertyFindGetB(TUint(aCategory.iUid), aKey, (TUint8*) aDes.Ptr(), size); |
|
365 if (r < 0) |
|
366 { |
|
367 if (r == KErrOverflow) |
|
368 { |
|
369 aDes.SetLength(size >> 1); |
|
370 } |
|
371 return r; |
|
372 } |
|
373 aDes.SetLength(r >> 1); |
|
374 return KErrNone; |
|
375 } |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 /** |
|
381 Sets an integer property. |
|
382 |
|
383 The function publishes a new integral property value. |
|
384 |
|
385 Any pending subscriptions for this property will be completed. |
|
386 |
|
387 The Platform Security attributes of the current process are checked against |
|
388 the Write Policy which was specified when the property was defined. |
|
389 If this check fails the action taken is determined by the system wide Platform Security |
|
390 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
391 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
392 check failed. |
|
393 |
|
394 @param aCategory The UID that identifies the property category. |
|
395 @param aKey The property sub-key, i.e. the key that identifies the |
|
396 specific property within the category. |
|
397 @param aValue The new property value. |
|
398 |
|
399 @return KErrNone, if successful; |
|
400 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
401 KErrNotFound, if the property has not been defined; |
|
402 KErrArgument, if the property is not of integral type. |
|
403 */ |
|
404 EXPORT_C TInt RProperty::Set(TUid aCategory, TUint aKey, TInt aValue) |
|
405 { |
|
406 return(Exec::PropertyFindSetI(TUint(aCategory.iUid), aKey, aValue)); |
|
407 } |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 /** |
|
413 Sets a binary property. |
|
414 |
|
415 The function Publishes a new byte-array (binary) value for |
|
416 the specified property. |
|
417 |
|
418 Any pending subscriptions for this property will be completed. |
|
419 |
|
420 Note that if the new property value requires more storage space than is |
|
421 currently allocated, then memory allocation will be required. |
|
422 This invalidates any real-time guarantee, i.e. the guarantee that the operation |
|
423 will complete within a bounded time. |
|
424 |
|
425 The Platform Security attributes of the current process are checked against |
|
426 the Write Policy which was specified when the property was defined. |
|
427 If this check fails the action taken is determined by the system wide Platform Security |
|
428 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
429 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
430 check failed. |
|
431 |
|
432 @param aCategory The UID that identifies the property category. |
|
433 @param aKey The property sub-key, i.e. the key that identifies the |
|
434 specific property within the category. |
|
435 @param aDes A reference to the descriptor containing the |
|
436 new property value. |
|
437 |
|
438 @return KErrNone, if successful; |
|
439 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
440 KErrNotFound, if the property has not been defined; |
|
441 KErrArgument, if the property is not a byte-array (binary) type; |
|
442 KErrNoMemory, if memory allocation is required, and there is |
|
443 insufficient available. |
|
444 */ |
|
445 EXPORT_C TInt RProperty::Set(TUid aCategory, TUint aKey, const TDesC8& aDes) |
|
446 { |
|
447 return(Exec::PropertyFindSetB(TUint(aCategory.iUid), aKey, (TUint8*) aDes.Ptr(), aDes.Size())); |
|
448 } |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 /** |
|
454 Sets a text property. |
|
455 |
|
456 The function publishes a new text value for the specified property. |
|
457 |
|
458 Any pending subscriptions for this property will be completed. |
|
459 |
|
460 Note that if the new property value requires more storage space than is |
|
461 currently allocated, then memory allocation will be required. |
|
462 This invalidates any real-time guarantee, i.e. the guarantee that the operation |
|
463 will complete within a bounded time. |
|
464 |
|
465 The Platform Security attributes of the current process are checked against |
|
466 the Write Policy which was specified when the property was defined. |
|
467 If this check fails the action taken is determined by the system wide Platform Security |
|
468 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
469 If PlatSecEnforcement is OFF, then this function will return KErrNone even though the |
|
470 check failed. |
|
471 |
|
472 @param aCategory The UID that identifies the property category. |
|
473 @param aKey The property sub-key, i.e. the key that identifies the |
|
474 specific property within the category. |
|
475 @param aDes A reference to the descriptor containing the |
|
476 new property value. |
|
477 |
|
478 @return KErrNone, if successful; |
|
479 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
480 KErrNotFound, if the property has not been defined; |
|
481 KErrArgument, if the property is not a text type; |
|
482 KErrNoMemory, if memory allocation is required, and there is |
|
483 insufficient available; |
|
484 KErrTooBig, if the property is larger than KMaxPropertySize; |
|
485 */ |
|
486 EXPORT_C TInt RProperty::Set(TUid aCategory, TUint aKey, const TDesC16& aDes) |
|
487 { |
|
488 return(Exec::PropertyFindSetB(TUint(aCategory.iUid), aKey, (TUint8*) aDes.Ptr(), aDes.Size())); |
|
489 } |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 /** |
|
495 Attaches to the specified property. |
|
496 |
|
497 The function creates a handle (this object) to the specified property. |
|
498 This allows the caller to subscribe for notification of changes to this |
|
499 property, and to faster and real-time property access methods. |
|
500 |
|
501 If the specified property does not exist, then this operation will |
|
502 still succeed. However, memory allocation will be required. |
|
503 Note that this invalidates any real-time guarantee, i.e. the guarantee that |
|
504 the operation completes within a bounded time. |
|
505 |
|
506 @param aCategory The UID that identifies the property category. |
|
507 @param aKey The property sub-key, i.e. the key that identifies the |
|
508 specific property within the category. |
|
509 @param aType The ownership of this property handle. |
|
510 By default, ownership is vested in the current process, |
|
511 but can be vested in the current thread by |
|
512 specifying EOwnerThread. |
|
513 |
|
514 @return KErrNone, if successful; |
|
515 KErrNoMemory, if memory allocation is required, and there is |
|
516 insufficient available. |
|
517 */ |
|
518 EXPORT_C TInt RProperty::Attach(TUid aCategory, TUint aKey, TOwnerType aType) |
|
519 { |
|
520 TInt r = Exec::PropertyAttach(TUint(aCategory.iUid), aKey, aType); |
|
521 if (r < 0) |
|
522 { // error |
|
523 iHandle = 0; |
|
524 return r; |
|
525 } |
|
526 iHandle = r; |
|
527 return KErrNone; |
|
528 } |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 /** |
|
534 Subscribes to a property. |
|
535 |
|
536 The function issues an asynchronous request to be notified when the property |
|
537 is changed. The calling thread is signalled, and the specified request status |
|
538 object is updated when the property is next changed. |
|
539 |
|
540 The property may change several times before the subscribing thread can deal |
|
541 with a notification request completion. To ensure that the subscriber does not |
|
542 miss updates, it should re-issue a subscription request before retrieving |
|
543 the current value and acting on it. |
|
544 |
|
545 If the property has not been defined, the request does not complete until |
|
546 the property is subsequently defined and published. When defined, if the caller |
|
547 process doesn't pass the Read Policy, then the request completes with KErrPermissionDenied. |
|
548 |
|
549 If the property is already defined, and the caller process doesn't pass the Read Policy, |
|
550 then the request completes immediately with KErrPermissionDenied. |
|
551 |
|
552 When Read Policy checks fail the action taken is determined by the system wide Platform Security |
|
553 configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. |
|
554 If PlatSecEnforcement is OFF, then the request will complete successfully even though the |
|
555 check failed. |
|
556 |
|
557 If an outstanding request is cancelled through a call to Cancel(), then it |
|
558 completes with KErrCancel. |
|
559 |
|
560 @param aRequest The request status object to be signalled on update. |
|
561 |
|
562 @panic KERN-EXEC 9 if there is already a subscription on this property handle; |
|
563 only one subscription per RProperty is allowed. |
|
564 */ |
|
565 EXPORT_C void RProperty::Subscribe(TRequestStatus& aRequest) |
|
566 { |
|
567 aRequest = KRequestPending; |
|
568 Exec::PropertySubscribe(iHandle, &aRequest); |
|
569 } |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 /** |
|
575 Cancels an outstanding subscription request for this property handle. |
|
576 |
|
577 If the request has not already completed, then it completes with KErrCancel. |
|
578 */ |
|
579 EXPORT_C void RProperty::Cancel() |
|
580 { |
|
581 Exec::PropertyCancel(iHandle); |
|
582 } |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 /** |
|
588 Gets the integer value of this property. |
|
589 |
|
590 The implementation guarantees that this call has a bounded response time. |
|
591 |
|
592 @param aValue A reference to the variable where the property value |
|
593 will be reported. |
|
594 |
|
595 @return KErrNone, if successful; |
|
596 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
597 KErrNotFound, if the property has not been defined; |
|
598 KErrArgument, if the property is not of integral type. |
|
599 */ |
|
600 EXPORT_C TInt RProperty::Get(TInt& aValue) |
|
601 { |
|
602 return(Exec::PropertyGetI(iHandle, &aValue)); |
|
603 } |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 /** |
|
609 Gets the byte-array (binary) value of this property. |
|
610 |
|
611 The implementation guarantees that this call has a bounded response time. |
|
612 |
|
613 @param aDes A reference to the buffer descriptor where the property value |
|
614 will be reported. |
|
615 |
|
616 @return KErrNone, if successful; |
|
617 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
618 KErrNotFound, if the property has not been defined; |
|
619 KErrArgument, if the property is not a byte-array (binary) type. |
|
620 KErrOverflow, if the supplied buffer is too small to contain the full |
|
621 property value, and note that the buffer aDes contains the |
|
622 truncated property value. |
|
623 */ |
|
624 EXPORT_C TInt RProperty::Get(TDes8& aDes) |
|
625 { |
|
626 TInt size = aDes.MaxSize(); |
|
627 TInt r = Exec::PropertyGetB(iHandle, (TUint8*) aDes.Ptr(), size); |
|
628 if (r < 0) |
|
629 { |
|
630 if (r == KErrOverflow) |
|
631 { |
|
632 aDes.SetLength(size); |
|
633 } |
|
634 return r; |
|
635 } |
|
636 aDes.SetLength(r); |
|
637 return KErrNone; |
|
638 } |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 /** |
|
644 Gets the text value of this property. |
|
645 |
|
646 The implementation guarantees that this call has a bounded response time. |
|
647 |
|
648 @param aDes A reference to the buffer descriptor where the property value |
|
649 will be reported. |
|
650 |
|
651 @return KErrNone, if successful; |
|
652 KErrPermissionDenied, if the caller process doesn't pass the Read Policy; |
|
653 KErrNotFound, if the property has not been defined; |
|
654 KErrArgument, if the property is not a text type; |
|
655 KErrOverflow, if the supplied buffer is too small to contain the full |
|
656 property value, and note that the buffer aDes contains the |
|
657 truncated property value. |
|
658 */ |
|
659 EXPORT_C TInt RProperty::Get(TDes16& aDes) |
|
660 { |
|
661 TInt size = aDes.MaxSize(); |
|
662 TInt r = Exec::PropertyGetB(iHandle, (TUint8*) aDes.Ptr(), size); |
|
663 if (r < 0) |
|
664 { |
|
665 if (r == KErrOverflow) |
|
666 { |
|
667 aDes.SetLength(size >> 1); |
|
668 } |
|
669 return r; |
|
670 } |
|
671 aDes.SetLength(r >> 1); |
|
672 return KErrNone; |
|
673 } |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 /** |
|
679 Sets a new integer value for this property. |
|
680 |
|
681 The function publishes the attached new integral property value, and any |
|
682 pending subscriptions for this property are completed. |
|
683 |
|
684 The implementation guarantees that this call has a bounded response time. |
|
685 |
|
686 @param aValue The property new value. |
|
687 |
|
688 @return KErrNone, if successful; |
|
689 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
690 KErrNotFound, if the property has not been defined; |
|
691 KErrArgument, if the property is not of integral type. |
|
692 */ |
|
693 EXPORT_C TInt RProperty::Set(TInt aValue) |
|
694 { |
|
695 return(Exec::PropertySetI(iHandle, aValue)); |
|
696 } |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 /** |
|
702 Sets the byte-array (binary) property. |
|
703 |
|
704 The function publishes the attached new binary property value, and any |
|
705 pending subscriptions for this property are completed. |
|
706 |
|
707 The implementation guarantees that this call has a bounded response time only |
|
708 if the new property value requires no more storage space than is |
|
709 currently allocated. If more memory needs to be allocated, then this |
|
710 invalidates the real-time guarantee. |
|
711 |
|
712 @param aDes A reference to the descriptor containing the property new value. |
|
713 |
|
714 @return KErrNone, if successful; |
|
715 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
716 KErrNotFound, if the property has not been defined; |
|
717 KErrArgument, if the property is not a byte-array (binary) type; |
|
718 KErrNoMemory, if memory allocation is required, and there is |
|
719 insufficient available. |
|
720 KMaxPropertySize, if the property is larger than KErrTooBig. |
|
721 */ |
|
722 EXPORT_C TInt RProperty::Set(const TDesC8& aDes) |
|
723 { |
|
724 return(Exec::PropertySetB(iHandle, (TUint8*) aDes.Ptr(), aDes.Size())); |
|
725 } |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 /** |
|
731 Sets the text property |
|
732 |
|
733 The function publishes the attached new text property value, and any |
|
734 pending subscriptions for this property are completed. |
|
735 |
|
736 The implementation guarantees that this call has a bounded response time only |
|
737 if the new property value requires no more storage space than is |
|
738 currently allocated. If more memory needs to be allocated, then this |
|
739 invalidates the real-time guarantee. |
|
740 |
|
741 @param aDes A reference to the descriptor containing the property new value. |
|
742 |
|
743 @return KErrNone, if successful; |
|
744 KErrPermissionDenied, if the caller process doesn't pass the Write Policy; |
|
745 KErrNotFound, if the property has not been defined; |
|
746 KErrArgument, if the property is not a byte-array (binary) type; |
|
747 KErrNoMemory, if memory allocation is required, and there is |
|
748 insufficient available. |
|
749 KMaxPropertySize, if the property is larger than KErrTooBig. |
|
750 */ |
|
751 EXPORT_C TInt RProperty::Set(const TDesC16& aDes) |
|
752 { |
|
753 return(Exec::PropertySetB(iHandle, (TUint8*) aDes.Ptr(), aDes.Size())); |
|
754 } |