|
1 // Copyright (c) 2007-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "rstrepos.h" |
|
17 |
|
18 /** |
|
19 Constructor. |
|
20 Constructs the object of this class with the specified uid. |
|
21 |
|
22 @param aUid The uid of the repository which is to be restored |
|
23 */ |
|
24 CRestoredRepository::CRestoredRepository(TUid aUid) : |
|
25 iReposUid(aUid), iChangedKeys() |
|
26 { |
|
27 } |
|
28 |
|
29 /** |
|
30 Destructor. |
|
31 Closes the array of the changed keys. |
|
32 */ |
|
33 CRestoredRepository::~CRestoredRepository() |
|
34 { |
|
35 iChangedKeys.Close(); |
|
36 } |
|
37 |
|
38 /** |
|
39 Get the uid of the repository represented by this class. |
|
40 |
|
41 @return the uid of the repository represented by this class. |
|
42 */ |
|
43 TUid CRestoredRepository::Uid() const |
|
44 { |
|
45 return iReposUid; |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 Gets the reference of the array of changed keys. |
|
51 |
|
52 @return the reference of the array of changed keys. |
|
53 */ |
|
54 const RArray<TUint32>& CRestoredRepository::ChangedKeys() const |
|
55 { |
|
56 return const_cast<const RArray<TUint32>&>(iChangedKeys); |
|
57 } |
|
58 |
|
59 |
|
60 /** |
|
61 Adds a specified key to the key list of the repository. |
|
62 which has been changed during the restoration. |
|
63 If the key is already on the list, no repeated entry will be added. |
|
64 |
|
65 @param aKey The key to be added. |
|
66 @leave The function leaves with one of the system wide error codes except for |
|
67 KErrAlreadyExists, if the operation fails. |
|
68 */ |
|
69 void CRestoredRepository::AddKeyL(TUint32 aKey) |
|
70 { |
|
71 TInt err = iChangedKeys.InsertInUnsignedKeyOrder(aKey); |
|
72 if((err != KErrNone) && (err != KErrAlreadyExists)) |
|
73 { |
|
74 User::Leave(err); |
|
75 } |
|
76 } |
|
77 |
|
78 /** |
|
79 Compares 2 CRestoredRepository objects using their data members iUid. |
|
80 |
|
81 @param aRstRepos1 The first CRestoredRepository object to be compared. |
|
82 @param aRstRepos2 The second CRestoredRepository object to be compared. |
|
83 @return: 1 if the first object is greater than the second. -1 if the |
|
84 first object is less than the second. 0 if they are equal. |
|
85 */ |
|
86 TInt CRestoredRepository::CompareUids(const CRestoredRepository& aRstRepos1,const CRestoredRepository& aRstRepos2) |
|
87 { |
|
88 if (aRstRepos1.iReposUid.iUid < aRstRepos2.iReposUid.iUid) |
|
89 { |
|
90 return -1 ; |
|
91 } |
|
92 else |
|
93 { |
|
94 if (aRstRepos1.iReposUid.iUid > aRstRepos2.iReposUid.iUid) |
|
95 { |
|
96 return 1 ; |
|
97 } |
|
98 else |
|
99 { |
|
100 return 0 ; |
|
101 } |
|
102 } |
|
103 } |