os/persistentdata/persistentstorage/centralrepository/cenrepcli/centralrepository.cpp
Update contrib.
1 // Copyright (c) 2004-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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 /** Creates a CRepository object for accessing a repository.
19 If there is no such repository, the function leaves with KErrNotFound.
20 A pointer to the object is left on the cleanup stack.
21 @param aRepositoryUid The UID of the repository to be accessed
22 @return A pointer to a newly created CRepository object
24 EXPORT_C CRepository* CRepository::NewLC(TUid aRepositoryUid)
26 return CClientRepository::NewLC(aRepositoryUid);
30 /** Creates a CRepository object for accessing a repository.
31 If there is no such repository, the function leaves with KErrNotFound.
32 @param aRepositoryUid The UID of the repository to be accessed
33 @return A pointer to a newly created CRepository object
35 EXPORT_C CRepository* CRepository::NewL(TUid aRepositoryUid)
37 CRepository* rep = CRepository::NewLC(aRepositoryUid);
45 EXPORT_C CRepository::~CRepository()
50 /** Creates a new setting with an integer value.
51 @param aKey New setting key.
52 @param aValue Setting value.
54 KErrNone if successful,
55 KErrAbort if in a transaction that has previously failed
56 KErrPermissionDenied if caller fails capability check,
57 KErrAlreadyExists if a setting with that key already exists
58 plus other system-wide error codes.
60 Transactions fail on all error conditions.
61 Outside transactions: on success the new setting is persistent,
62 on failure the repository is unmodified.
63 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
65 EXPORT_C TInt CRepository::Create(TUint32 aKey, TInt aValue)
67 return (static_cast<CClientRepository*>(this))->Create(aKey, aValue);
71 /** Creates a new setting with a floating-point value.
72 @param aKey New setting key.
73 @param aValue Setting value.
75 KErrNone if successful,
76 KErrAbort if in a transaction that has previously failed
77 KErrPermissionDenied if caller fails capability check,
78 KErrAlreadyExists if a setting with that key already exists
79 plus other system-wide error codes.
81 Transactions fail on all error conditions.
82 Outside transactions: on success the new setting is persistent,
83 on failure the repository is unmodified.
84 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
86 EXPORT_C TInt CRepository::Create(TUint32 aKey, const TReal& aValue)
88 return (static_cast<CClientRepository*>(this))->Create(aKey, aValue);
92 /** Creates a new setting with a descriptor value.
93 @param aKey New setting key.
94 @param aValue Setting value.
96 KErrNone if successful,
97 KErrAbort if in a transaction that has previously failed
98 KErrPermissionDenied if caller fails capability check,
99 KErrAlreadyExists if a setting with that key already exists
100 KErrArgument if the descriptor is longer than KMaxBinaryLength,
101 plus other system-wide error codes.
103 Transactions fail on all error conditions.
104 Outside transactions: on success the new setting is persistent,
105 on failure the repository is unmodified.
106 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
108 EXPORT_C TInt CRepository::Create(TUint32 aKey, const TDesC8& aValue)
110 return (static_cast<CClientRepository*>(this))->Create(aKey, aValue);
113 /** Creates a new setting with a descriptor value.
114 @param aKey New setting key.
115 @param aValue Setting value.
117 KErrNone if successful,
118 KErrAbort if in a transaction that has previously failed
119 KErrPermissionDenied if caller fails capability check,
120 KErrAlreadyExists if a setting with that key already exists
121 KErrArgument if the descriptor is longer than KMaxUnicodeStringLength,
122 plus other system-wide error codes.
124 Transactions fail on all error conditions.
125 Outside transactions: on success the new setting is persistent,
126 on failure the repository is unmodified.
127 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
129 EXPORT_C TInt CRepository::Create(TUint32 aKey, const TDesC16& aValue)
131 return (static_cast<CClientRepository*>(this))->Create(aKey, aValue);
134 /** Deletes a setting.
135 @param aKey Key of setting to be deleted.
137 KErrNone if successful,
138 KErrAbort if in a transaction that has previously failed
139 KErrPermissionDenied if caller fails capability check,
140 KErrNotFound if the setting does not exist,
141 plus other system-wide error codes.
143 Transactions fail on all error conditions except KErrNotFound.
144 Outside transactions: on success the deletion of the setting is persistent,
145 on failure the repository is unmodified.
146 @capability Dependent Caller must satisfy the write access policy for that key in the repository
148 EXPORT_C TInt CRepository::Delete(TUint32 aKey)
150 return (static_cast<CClientRepository*>(this))->Delete(aKey);
153 /** Deletes all the settings that exist and match the specification:
154 (key & mask) == (partialKey & mask)
155 Partial key is guaranteed to be masked before use.
157 - To delete a single key.
158 Delete(key, 0xFFFFFFFF, errorKey);
159 - To delete all keys from 0 to 0xFF:
160 Delete(0, 0xFFFFFF00, errorKey);
161 (digits from 0 to 0xFF would be ignored if given in the partial key)
162 - To delete all keys matching 0x5B??3A?6:
163 Delete(0x5B003A06, 0xFF00FF0F, errorKey);
166 Contains a bit pattern that all the keys must at least partially
169 Has bits set for all the bits in aPartialKey that must match the keys being deleted.
170 @param aErrorKey If the delete operation fails this contains the key involved in the
171 failure, or aPartialKey or KUnspecifiedKey if it could not be attributed to any key
173 KErrNone if successful,
174 KErrAbort if in a transaction that has previously failed
175 KErrNotFound if no items were found in the partial key range.
176 KErrPermissionDenied if caller fails capability check.
177 plus other system-wide error codes.
179 Transactions fail on all error conditions except KErrNotFound
180 Outside transactions: on success the changes are persistent, on failure the
181 repository is unmodified.
182 @capability Dependent Caller must satisfy the write policies of all settings found in the
185 EXPORT_C TInt CRepository::Delete (TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey)
187 return (static_cast<CClientRepository*>(this))->Delete(aPartialKey, aMask, aErrorKey);
191 /** Reads an integer setting.
192 @param aKey Key of setting to be read.
193 @param aValue Returns the value of the setting if it is an integer.
195 KErrNone if successful,
196 KErrAbort if in a transaction that has previously failed
197 KErrPermissionDenied if caller fails capability check,
198 KErrNotFound if the setting does not exist,
199 KErrArgument if the setting exists but is not an integer,
200 plus other system-wide error codes.
201 @post Transactions fail only on those "other system-wide error codes".
202 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
204 EXPORT_C TInt CRepository::Get(TUint32 aKey, TInt& aValue)
206 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue);
210 /** Sets an existing integer setting to a new value or creates a new setting
211 with an integer value if the setting doesn't exist.
212 @param aKey Key of setting to be written to.
213 @param aValue Value to be written.
215 KErrNone if successful,
216 KErrAbort if in a transaction that has previously failed
217 KErrPermissionDenied if caller fails capability check,
218 KErrArgument if the setting exists but is not an integer
219 plus other system-wide error codes.
221 Transactions fail on all error conditions.
222 Outside transactions: on success the new value is persistent,
223 on failure the repository is unmodified.
224 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
226 EXPORT_C TInt CRepository::Set(TUint32 aKey, TInt aValue)
228 return (static_cast<CClientRepository*>(this))->Set(aKey, aValue);
232 /** Reads a floating point setting.
233 @param aKey Key of setting to be read.
234 @param aValue Returns the value of the setting if it is a floating point value.
236 KErrNone if successful,
237 KErrAbort if in a transaction that has previously failed
238 KErrPermissionDenied if caller fails capability check,
239 KErrNotFound if the setting does not exist,
240 KErrArgument if the setting exists but is not a floating point value,
241 plus other system-wide error codes.
242 @post Transactions fail only on those "other system-wide error codes".
243 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
245 EXPORT_C TInt CRepository::Get(TUint32 aKey, TReal& aValue)
247 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue);
251 /** Sets an existing floating point setting to a new value or creates a new setting
252 with a floating point value if the setting doesn't exist.
253 @param aKey Key of setting to be written to.
254 @param aValue Value to be written.
256 KErrNone if successful,
257 KErrAbort if in a transaction that has previously failed
258 KErrPermissionDenied if caller fails capability check,
259 KErrArgument if the setting exists but is not a floating point value
260 plus other system-wide error codes.
262 Transactions fail on all error conditions.
263 Outside transactions: on success the new value is persistent,
264 on failure the repository is unmodified.
265 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
267 EXPORT_C TInt CRepository::Set(TUint32 aKey, const TReal& aValue)
269 return (static_cast<CClientRepository*>(this))->Set(aKey, aValue);
273 /** Reads a descriptor setting.
274 @param aKey Key of setting to be read.
275 @param aValue Returns the value of the setting if it is a descriptor.
277 KErrNone if successful,
278 KErrAbort if in a transaction that has previously failed
279 KErrPermissionDenied if caller fails capability check,
280 KErrNotFound if the setting does not exist,
281 KErrArgument if the setting exists but is not a descriptor,
282 KErrOverflow if the descriptor is too small to receive the value in the repository,
283 plus other system-wide error codes.
284 @post Transactions fail only on those "other system-wide error codes".
285 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
287 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue)
289 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue);
292 /** Reads a descriptor setting.
293 @param aKey Key of setting to be read.
294 @param aValue Returns the value of the setting if it is a descriptor.
295 @param aActualLength Returns the actual length of the setting if it is a descriptor.
297 KErrNone if successful,
298 KErrAbort if in a transaction that has previously failed
299 KErrPermissionDenied if caller fails capability check,
300 KErrNotFound if the setting does not exist,
301 KErrArgument if the setting exists but is not a descriptor,
302 KErrOverflow if the descriptor is too small to receive the value in the repository,
303 plus other system-wide error codes.
304 @post Transactions fail only on those "other system-wide error codes".
305 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
307 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
309 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue, aActualLength);
312 /** Sets an existing descriptor setting to a new value or creates a new setting
313 with a descriptor value if the setting doesn't exist.
314 @param aKey Key of setting to be written to.
315 @param aValue Value to be written.
317 KErrNone if successful,
318 KErrAbort if in a transaction that has previously failed
319 KErrPermissionDenied if caller fails capability check,
320 KErrArgument if aValue is longer than KMaxBinaryLength or
321 the setting exists but is not a descriptor,
322 plus other system-wide error codes.
324 Transactions fail on all error conditions.
325 Outside transactions: on success the new value is persistent,
326 on failure the repository is unmodified.
327 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
329 EXPORT_C TInt CRepository::Set(TUint32 aKey, const TDesC8& aValue)
331 return (static_cast<CClientRepository*>(this))->Set(aKey, aValue);
335 /** Reads a descriptor setting.
336 @param aKey Key of setting to be read.
337 @param aValue Returns the value of the setting if it is a descriptor.
339 KErrNone if successful,
340 KErrAbort if in a transaction that has previously failed
341 KErrPermissionDenied if caller fails capability check,
342 KErrNotFound if the setting does not exist,
343 KErrArgument if the setting exists but is not a descriptor,
344 KErrOverflow if the descriptor is too small to receive the value in the repository,
345 plus other system-wide error codes.
346 @post Transactions fail only on those "other system-wide error codes".
347 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
349 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue)
351 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue);
354 /** Reads a descriptor setting.
355 @param aKey Key of setting to be read.
356 @param aValue Returns the value of the setting if it is a descriptor.
357 @param aActualLength Returns the actual length of the setting if it is a descriptor.
359 KErrNone if successful,
360 KErrAbort if in a transaction that has previously failed
361 KErrPermissionDenied if caller fails capability check,
362 KErrNotFound if the setting does not exist,
363 KErrArgument if the setting exists but is not a descriptor,
364 KErrOverflow if the descriptor is too small to receive the value in the repository,
365 plus other system-wide error codes.
366 @post Transactions fail only on those "other system-wide error codes".
367 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
369 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue, TInt& aActualLength)
371 return (static_cast<CClientRepository*>(this))->Get(aKey, aValue, aActualLength);
374 /** Sets an existing descriptor setting to a new value or creates a new setting
375 with a descriptor value if it doesn't exist.
376 @param aKey Key of setting to be written to.
377 @param aValue Value to be written.
379 KErrNone if successful,
380 KErrAbort if in a transaction that has previously failed
381 KErrPermissionDenied if caller fails capability check,
382 KErrArgument if aValue is longer than KMaxUnicodeStringLength or
383 the setting exists but is not a descriptor,
384 plus other system-wide error codes.
386 Transactions fail on all error conditions.
387 Outside transactions: on success the new value is persistent,
388 on failure the repository is unmodified.
389 @capability Dependent Caller must satisfy the write access policy of that key in the repository.
391 EXPORT_C TInt CRepository::Set(TUint32 aKey, const TDesC16& aValue)
393 return (static_cast<CClientRepository*>(this))->Set(aKey, aValue);
396 /** Reads the metadata bound to a key
398 @param aMeta Returns the metadata value for the key
400 KErrNone if successful,
401 KErrAbort if in a transaction that has previously failed
402 KErrPermissionDenied if caller fails capability check,
403 KErrNotFound if the setting does not exist,
404 plus other system-wide error codes.
405 @post Transactions fail only on those "other system-wide error codes".
406 @capability Dependent Caller must satisfy the read access policy of that key in the repository.
408 EXPORT_C TInt CRepository::GetMeta(TUint32 aKey, TUint32& aMeta)
410 return (static_cast<CClientRepository*>(this))->GetMeta(aKey, aMeta);
413 /** Moves all the settings that exist and match the specification:
414 (oldkey & mask) == (sourcePartialKey & mask)
415 to new locations where
416 (newkey & mask) == (targetPartialKey & mask).
417 For those keys that match the source specification, those bits in the key for
418 which the corresponding mask bit is zero remain unchanged. All remaining bits
419 change from (sourcePartialKey & mask) to (targetPartialKey & mask).
420 Both partial keys are guaranteed to be masked before use.
422 - To move a single key from oldKey to newKey.
423 Move(oldKey, newKey, 0xFFFFFFFF, errorKey);
424 - To move all keys from 0 to 0xFF to be from 0x100 to 0x1FF:
425 Move(0, 0x100, 0xFFFFFF00, errorKey);
426 (digits from 0 to 0xFF would be ignored if given in the partial keys)
427 - To move all keys matching 0x5B??3A?6 to 0xDC??44?F:
428 Move(0x5B003A06, 0xDC00440F, 0xFF00FF0F, errorKey);
430 @param aSourcePartialKey
431 Contains a bit pattern that all the source keys which must at least partially
434 Has bits set for all the bits in aPartialKey that must match the keys being moved.
435 @param aTargetPartialKey
436 Contains a bit pattern that all the target keys which must at least partially
438 @param aErrorKey on failure, contains the key or partial key involved in the error
439 or KUnspecifiedKey if failure could not be attributed to any key.
441 KErrNone if successful,
442 KErrAbort if in a transaction that has previously failed
443 KErrNotFound if no items were found in the source range.
444 KErrPermissionDenied if caller fails capability check,
445 KErrAlreadyExists if an existing setting is using any intended target key.
446 plus other system-wide error codes.
448 Transactions fail on all error conditions except KErrNotFound.
449 Outside transactions: on success the changes are persistent, on failure the
450 repository is unmodified.
451 @capability Dependent Caller must satisfy the read and write policies of all settings found in the
452 source range, and write policies on all intended target keys.
454 EXPORT_C TInt CRepository::Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,
455 TUint32 aMask, TUint32 &aErrorKey)
457 return (static_cast<CClientRepository*>(this))->Move(aSourcePartialKey, aTargetPartialKey, aMask, aErrorKey);
461 /** Finds all the settings that exist and match the specification given by
462 aPartialKey and aMask.
463 Matches occur whenever (key & mask) == (partialKey & mask).
464 The partial key is guaranteed to be masked before use.
466 Contains a bit pattern that all the keys returned must at least partially
469 Has bits set for all the bits in aPartialKey that must match the returned
471 @param aFoundKeys All the keys found.
473 KErrNone if successful,
474 KErrAbort if in a transaction that has previously failed
475 KErrNotFound if no items were found in the source range,
476 plus other system-wide error codes.
477 @post Transactions fail only on those "other system-wide error codes".
479 EXPORT_C TInt CRepository::FindL(TUint32 aPartialKey, TUint32 aMask,
480 RArray<TUint32>& aFoundKeys)
482 return (static_cast<CClientRepository*>(this))->FindL(aPartialKey, aMask, aFoundKeys);
486 /** Finds all the settings that contain a given integer and match the
487 specification given by aPartialKey and aMask.
489 Contains a bit pattern that all the keys returned must at least partially
492 Has bits set for all the bits in aPartialKey that must match the returned
494 @param aValue Settings for the keys found will be integers with value aValue.
495 @param aFoundKeys All the keys found.
496 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
497 the setting with key k is an integer aValue.
500 KErrNone if successful,
501 KErrAbort if in a transaction that has previously failed
502 KErrPermissionDenied if caller fails capability check,
503 KErrNotFound if capability check passed but no matching items are found,
504 plus other system-wide error codes.
505 @post Transactions fail only on those "other system-wide error codes".
506 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
508 EXPORT_C TInt CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask,
509 TInt aValue, RArray<TUint32>& aFoundKeys)
511 return (static_cast<CClientRepository*>(this))->FindEqL(aPartialKey, aMask, aValue, aFoundKeys);
515 /** Finds all the settings that contain a given floating point value and match
516 the specification given by aPartialKey and aMask.
518 Contains a bit pattern that all the keys returned must at least partially
521 Has bits set for all the bits in aPartialKey that must match the returned
524 Settings for the keys found will be floating point values with value aValue.
525 @param aFoundKeys All the keys found.
526 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
527 the setting with key k is a floating point value aValue.
530 KErrNone if successful,
531 KErrAbort if in a transaction that has previously failed
532 KErrPermissionDenied if caller fails capability check,
533 KErrNotFound if capability check passed but no matching items are found,
534 plus other system-wide error codes.
535 @post Transactions fail only on those "other system-wide error codes".
536 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
538 EXPORT_C TInt CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask,
539 const TReal& aValue, RArray<TUint32>& aFoundKeys)
541 return (static_cast<CClientRepository*>(this))->FindEqL(aPartialKey, aMask, aValue, aFoundKeys);
545 /** Finds all the settings that contain a given string value and match the
546 specification given by aPartialKey and aMask.
548 Contains a bit pattern that all the keys returned must at least partially
551 Has bits set for all the bits in aPartialKey that must match the returned
554 Settings for the keys found will be string values with value aValue.
555 @param aFoundKeys All the keys found.
556 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
557 the setting with key k is a string value aValue.
560 KErrNone if successful,
561 KErrAbort if in a transaction that has previously failed
562 KErrPermissionDenied if caller fails capability check,
563 KErrNotFound if capability check passed but no matching items are found,
564 plus other system-wide error codes.
565 @post Transactions fail only on those "other system-wide error codes".
566 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
568 EXPORT_C TInt CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask,
569 const TDesC8& aValue, RArray<TUint32>& aFoundKeys)
571 return (static_cast<CClientRepository*>(this))->FindEqL(aPartialKey, aMask, aValue, aFoundKeys);
575 /** Finds all the settings that contain a given string value and match the
576 specification given by aPartialKey and aMask.
578 Contains a bit pattern that all the keys returned must at least partially
581 Has bits set for all the bits in aPartialKey that must match the returned
584 Settings for the keys found will be string values with value aValue.
585 @param aFoundKeys All the keys found.
586 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
587 the setting with key k is a string value aValue.
590 KErrNone if successful,
591 KErrAbort if in a transaction that has previously failed
592 KErrPermissionDenied if caller fails capability check,
593 KErrNotFound if capability check passed but no matching items are found,
594 plus other system-wide error codes.
595 @post Transactions fail only on those "other system-wide error codes".
596 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
598 EXPORT_C TInt CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask,
599 const TDesC16& aValue, RArray<TUint32>& aFoundKeys)
601 return (static_cast<CClientRepository*>(this))->FindEqL(aPartialKey, aMask, aValue, aFoundKeys);
605 /** Finds all the settings that match the specification given by aPartialKey
606 and aMask, but are either not integer values or do not have the given value.
608 Contains a bit pattern that all the keys returned must at least partially
611 Has bits set for all the bits in aPartialKey that must match the returned
614 Settings for the keys found will be settings that either contain values
615 that are not integers or integers other than aValue.
616 @param aFoundKeys All the keys found.
617 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
618 the setting with key k is either not an integer or an integer not equal to
622 KErrNone if successful,
623 KErrAbort if in a transaction that has previously failed
624 KErrPermissionDenied if caller fails capability check,
625 KErrNotFound if capability check passed but no non-matching items are found,
626 plus other system-wide error codes.
627 @post Transactions fail only on those "other system-wide error codes".
628 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
630 EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
631 TInt aValue, RArray<TUint32>& aFoundKeys)
633 return (static_cast<CClientRepository*>(this))->FindNeqL(aPartialKey, aMask, aValue, aFoundKeys);
637 /** Finds all the settings that match the specification given by aPartialKey
638 and aMask, but are either not floating point values or do not have the given value.
640 Contains a bit pattern that all the keys returned must at least partially
643 Has bits set for all the bits in aPartialKey that must match the returned
646 Settings for the keys found will be settings that either contain values
647 that are not floating point or floating point values other than aValue.
648 @param aFoundKeys All the keys found.
649 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
650 the setting with key k is either not a floating point value or a floating
651 point value not equal to aValue.
654 KErrNone if successful,
655 KErrAbort if in a transaction that has previously failed
656 KErrPermissionDenied if caller fails capability check,
657 KErrNotFound if capability check passed but no non-matching items are found,
658 plus other system-wide error codes.
659 @post Transactions fail only on those "other system-wide error codes".
660 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
662 EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
663 const TReal& aValue, RArray<TUint32>& aFoundKeys)
665 return (static_cast<CClientRepository*>(this))->FindNeqL(aPartialKey, aMask, aValue, aFoundKeys);
669 /** Finds all the settings that match the specification given by aPartialKey
670 and aMask, but are either not string values or do not match the given string.
672 Contains a bit pattern that all the keys returned must at least partially
675 Has bits set for all the bits in aPartialKey that must match the returned
678 Settings for the keys found will be settings that either contain values
679 that are not strings or strings with value other than aValue.
680 @param aFoundKeys All the keys found.
681 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
682 the setting with key k is either not a string value or a string value not
686 KErrNone if successful,
687 KErrAbort if in a transaction that has previously failed
688 KErrPermissionDenied if caller fails capability check,
689 KErrNotFound if capability check passed but no non-matching items are found,
690 plus other system-wide error codes.
691 @post Transactions fail only on those "other system-wide error codes".
692 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
694 EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
695 const TDesC8& aValue, RArray<TUint32>& aFoundKeys)
697 return (static_cast<CClientRepository*>(this))->FindNeqL(aPartialKey, aMask, aValue, aFoundKeys);
700 /** Finds all the settings that match the specification given by aPartialKey
701 and aMask, but are either not string values or do not match the given string.
703 Contains a bit pattern that all the keys returned must at least partially
706 Has bits set for all the bits in aPartialKey that must match the returned
709 Settings for the keys found will be settings that either contain values
710 that are not strings or strings with value other than aValue.
711 @param aFoundKeys All the keys found.
712 For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
713 the setting with key k is either not a string value or a string value not
717 KErrNone if successful,
718 KErrAbort if in a transaction that has previously failed
719 KErrPermissionDenied if caller fails capability check,
720 KErrNotFound if capability check passed but no non-matching items are found,
721 plus other system-wide error codes.
722 @post Transactions fail only on those "other system-wide error codes".
723 @capability Dependent Caller must satisfy the read policies of all settings found in the source range.
725 EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
726 const TDesC16& aValue, RArray<TUint32>& aFoundKeys)
728 return (static_cast<CClientRepository*>(this))->FindNeqL(aPartialKey, aMask, aValue, aFoundKeys);
732 /** Requests a notification if the value of a given setting changes.
733 Only one notification can be received per call to NotifyRequest.
734 Only one notification per setting per CRepository may be active at any one
736 @param aKey The key setting to be informed about.
737 @param aStatus The object that will receive the notification. On a successful
738 outcome, this will contain the Uid of the changed setting.
739 If there is an existing notification on the same setting and same session, aStatus
740 will be set to KErrAlreadyExists and the return value will be KErrNone.
742 KErrNone if successful or if aStatus is set to KErrAlreadyExists.
743 KErrPermissionDenied if caller fails capability check.
744 KErrNotFound if the requested setting does not exist.
745 @capability Note The caller must satisfy the relevant access policies for the repository
747 EXPORT_C TInt CRepository::NotifyRequest(TUint32 aKey, TRequestStatus& aStatus)
749 return (static_cast<CClientRepository*>(this))->NotifyRequest(aKey, aStatus);
753 /** Cancels a notification previously requested from the two-argument overload
755 @param aKey The parameter to the previous call to NotifyRequest to be cancelled.
756 @return KErrNone The method always returns KErrNone.
758 EXPORT_C TInt CRepository::NotifyCancel(TUint32 aKey)
760 //We deliberately ignore the return value from the server and return KErrNone because
761 //it is incorrect for a cancel function to return an error code - if there is no
762 //outstanding notification then the cancel should do nothing.
763 (void)(static_cast<CClientRepository*>(this))->NotifyCancel(aKey);
768 /** Cancels all uncompleted notifications from this CRepository.
769 @return KErrNone The method always returns KErrNone.
771 EXPORT_C TInt CRepository::NotifyCancelAll()
773 //We deliberately ignore the return value from the server and return KErrNone because
774 //it is incorrect for a cancel function to return an error code - if there is no
775 //outstanding notification then the cancel should do nothing.
776 (void)(static_cast<CClientRepository*>(this))->NotifyCancelAll();
781 /** Requests a notification if the value of a given setting changes.
782 Only one notification can be received per call to NotifyRequest.
783 Only one notification per setting per CRepository may be active at any one
785 @param aPartialKey The partial key setting to be informed about.
786 @param aMask The mask to be used with the partial key.
787 @param aStatus The object that will receive the notification. On a successful
788 outcome, this will contain the Uid of the changed setting.
789 On error the error code is stored in aStatus and KErrNone is returned.
791 KErrNone The method always returns KErrNone.
792 @capability Note The caller must satisfy the relevant access policies for the repository
794 EXPORT_C TInt CRepository::NotifyRequest(TUint32 aPartialKey, TUint32 aMask,
795 TRequestStatus& aStatus)
797 return (static_cast<CClientRepository*>(this))
798 ->NotifyRequest(aPartialKey, aMask, aStatus);
802 /** Cancels a notification previously requested from the three-argument overload
804 @param aPartialKey The parameter to the previous call to NotifyRequest to be cancelled.
805 @param aMask The mask to be used with the partial key
806 @return KErrNone The method always returns KErrNone.
808 EXPORT_C TInt CRepository::NotifyCancel(TUint32 aPartialKey, TUint32 aMask)
810 (void)(static_cast<CClientRepository*>(this))->NotifyCancel(aPartialKey, aMask);
815 /** Resets the whole repository to the state of the initialization file
816 originally used to set it up. Not currently supported in transactions.
818 KErrNone if successful,
819 KErrNotSupported if this client session is in a transaction
820 plus other system-wide error codes.
821 @post Fails transaction if called when session is in one.
822 @capability Dependent The caller must satisfy the relevant access policies for the repository
824 EXPORT_C TInt CRepository::Reset()
826 return (static_cast<CClientRepository*>(this))->Reset();
830 /** Resets the a setting within the repository to the state of the setting
831 described by the initialization file originally used to set the repository up.
832 Not currently supported in transactions.
833 @param aKey Key of setting to be reset.
835 KErrNone if successful,
836 KErrNotSupported if this client session is in a transaction
837 plus other system-wide error codes.
838 @post Fails transaction if called when session is in one.
839 @capability Note The caller must satisfy the relevant access policies for the repository
841 EXPORT_C TInt CRepository::Reset(TUint32 aKey)
843 return (static_cast<CClientRepository*>(this))->Reset(aKey);
847 /** Attempts to starts a transaction in the given mode.
848 Consistency and persistence of all values read and written during the transaction
849 is only guaranteed after a successful return from CommitTransaction.
850 @param aMode transaction mode: EConcurrentReadWriteTransaction (standard),
851 EReadTransaction or EReadWriteTransaction.
852 @return KErrNone if successful - guaranteed for EConcurrentReadWriteTransaction,
853 KErrLocked for other transaction types if read or write locks held by other clients
854 prevent transaction from starting.
855 @see CRepository::TTransactionMode
856 @pre Must not be in a transaction.
857 @post If it returns KErrNone: in a transaction; Any other error code: not in a transaction.
858 @panic CENREPCLI 3 Panics client if this session is already in a transaction.
860 EXPORT_C TInt CRepository::StartTransaction(TTransactionMode aMode)
862 return (static_cast<CClientRepository*>(this))->StartTransaction(aMode);
866 /** Attempts to starts a transaction in the given mode asynchronously to
867 allow client to avoid being blocked by server activity before starting.
868 Consistency and persistence of all values read and written during the transaction
869 is only guaranteed after a successful return from CommitTransaction.
870 Use CancelTransaction to cancel asynchronous request.
871 @param aMode transaction mode: EConcurrentReadWriteTransaction (standard),
872 EReadTransaction or EReadWriteTransaction.
873 @see CRepository::TTransactionMode
874 @param aStatus On completion of asynchronous request: KErrNone if successful -
875 guaranteed for EConcurrentReadWriteTransaction unless cancelled,
876 KErrLocked for other transaction types if read or write locks held by other clients
877 prevent transaction from starting.
878 @pre Must not be in a transaction.
879 @post If it completes with KErrNone and request not cancelled: in a transaction;
880 Any other error code or request cancelled: not in a transaction.
881 @panic CENREPCLI 3 Panics client if this session is already in a transaction.
883 EXPORT_C void CRepository::StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus)
885 (static_cast<CClientRepository*>(this))->StartTransaction(aMode, aStatus);
889 /** Commits a transaction. A successful return guarantees the consistency and
890 persistence of all values read and written during the transaction.
891 @return KErrNone on success, or error code giving first reason for failing.
892 If KErrLocked is returned for EConcurrentReadWriteTransaction, transaction
893 was interrupted by another client committing changes and should be repeated.
895 On success: returns the number of keys whose values were modified.
896 On failure: returns the key or partial key involved in the first error, or
897 KUnspecifiedKey if failure could not be attributed to any key.
898 @pre Must be in a transaction.
899 @post Not in a transaction. On success, changes have been made persistent. On failure,
900 transaction changes have been rolled back.
901 @panic CENREPCLI 4 Panics client if this session is not in a transaction.
903 EXPORT_C TInt CRepository::CommitTransaction(TUint32& aKeyInfo)
905 return (static_cast<CClientRepository*>(this))->CommitTransaction(aKeyInfo);
909 /** Commits a transaction asynchronously to allow client to avoid being blocked
910 during the persist operation and other server activity. A successful return guarantees
911 the consistency and persistence of all values read and written during the transaction.
912 Use CancelTransaction to cancel asynchronous request.
914 A descriptor to receive a TUint32 value, e.g. TTransactionKeyInfoBuf, which
915 client must ensure remains in scope for the duration of the asynchronous request.
916 On success: returns the number of keys whose values were modified.
917 On failure: returns the key or partial key involved in the first error, or
918 KUnspecifiedKey if failure could not be attributed to any key.
919 @see CRepository::TTransactionKeyInfoBuf
920 @param aStatus Completion status of asynchronous request:
921 On success (if not cancelled): KErrNone;
922 On failure: error code giving first reason for failing.
923 If KErrLocked is returned for EConcurrentReadWriteTransaction, transaction
924 was interrupted by another client committing changes and should be repeated.
925 @pre Must be in a transaction.
926 @post Cannot assume that transaction is "pending commit" as may have completed already.
927 Once request is complete, session is not in a transaction: on success, changes
928 have been made persistent; on failure, transaction changes have been rolled back.
929 @panic CENREPCLI 4 Panics client if this session is not in a transaction.
931 EXPORT_C void CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
933 (static_cast<CClientRepository*>(this))->CommitTransaction(aKeyInfo, aStatus);
937 /** Cancels the current transaction with rollback: discards any uncommitted changes.
938 If the transaction is pending start or commit asynchronously, the request is
939 completed with KErrCancel (unless it had already completed).
940 @post Not in a transaction.
942 EXPORT_C void CRepository::CancelTransaction()
944 (static_cast<CClientRepository*>(this))->CancelTransaction();
948 /** Pushes onto the CleanupStack a TCleanupItem that calls CancelTransaction if
949 activated by a Leave or PopAndDestroy. Important for releasing transaction resources
950 including caches and read/write locks held over the repository.
951 @post CleanupStack has another item on it which must be popped later with
952 CleanupStack::Pop() or similar.
954 EXPORT_C void CRepository::CleanupCancelTransactionPushL()
956 (static_cast<CClientRepository*>(this))->CleanupCancelTransactionPushL();
960 /** Sets the active transaction to a failed state, releasing cache and locks but
961 keeping it open. Has no effect when not in an active transaction, including when it
962 has already failed or when pending asynchronous start or commit request completion.
963 Use in preference to CancelTransaction whenever it is inappropriate to close the
964 transaction at the time.
966 If previously in an active transaction: It is marked as failed. All uncommitted
967 changes are discarded. Transaction resources including cache and read/write locks
968 are released in the repository. All subsequent operations in the transaction fail
969 until it is closed by CancelTransaction or CommitTransaction. CommitTransaction
970 will fail and return KErrAbort.
972 EXPORT_C void CRepository::FailTransaction()
974 (static_cast<CClientRepository*>(this))->FailTransaction();
978 /** Pushes onto the CleanupStack a TCleanupItem that calls FailTransaction if
979 activated by a Leave or PopAndDestroy.
980 @post CleanupStack has another item on it which must be popped later with
981 CleanupStack::Pop() or similar.
983 EXPORT_C void CRepository::CleanupFailTransactionPushL()
985 (static_cast<CClientRepository*>(this))->CleanupFailTransactionPushL();