1 /* |
|
2 * Copyright (c) 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 #ifndef C_RADIOREPOSITORYMANAGERIMP_H |
|
20 #define C_RADIOREPOSITORYMANAGERIMP_H |
|
21 |
|
22 // System includes |
|
23 #include <centralrepository.h> |
|
24 |
|
25 // User includes |
|
26 #include "mradiorepositoryentityobserver.h" |
|
27 |
|
28 // Forward declarations |
|
29 class CRadioRepositoryEntityBase; |
|
30 |
|
31 /** |
|
32 * Central repository entity manager. |
|
33 * |
|
34 * Manages central repository entities that listen to specific repository and a key within it, notifying the observer |
|
35 * whenever the key's value changes. |
|
36 * |
|
37 * Also a set of static methods are provided that wrap the common use case of central repository where the user |
|
38 * is only interested to read or write the value of a key and then discard the repository object. |
|
39 */ |
|
40 NONSHARABLE_CLASS( CRadioRepositoryManagerImp ) : public CRadioRepositoryManager |
|
41 , public MRadioRepositoryEntityObserver |
|
42 { |
|
43 |
|
44 public: |
|
45 |
|
46 static CRadioRepositoryManagerImp* NewL( TInt aGranularity ); |
|
47 |
|
48 ~CRadioRepositoryManagerImp(); |
|
49 |
|
50 /** |
|
51 * Sets the value of an integer key in the repository. |
|
52 * |
|
53 * @param aUid The UID of the repository. |
|
54 * @param aKey The key within the repository. |
|
55 * @param aValue The value to set. |
|
56 */ |
|
57 static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, TInt aValue ); |
|
58 |
|
59 /** |
|
60 * Sets the value of a floating point key in the repository. |
|
61 * |
|
62 * @param aUid The UID of the repository. |
|
63 * @param aKey The key within the repository. |
|
64 * @param aValue The value to set. |
|
65 */ |
|
66 static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TReal& aValue ); |
|
67 |
|
68 /** |
|
69 * Sets the value of a binary key in the repository. |
|
70 * |
|
71 * @param aUid The UID of the repository. |
|
72 * @param aKey The key within the repository. |
|
73 * @param aValue The value to set. |
|
74 */ |
|
75 static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TDesC8& aValue ); |
|
76 |
|
77 /** |
|
78 * Sets the value of a string key in the repository. |
|
79 * |
|
80 * @param aUid The UID of the repository. |
|
81 * @param aKey The key within the repository. |
|
82 * @param aValue The value to set. |
|
83 */ |
|
84 static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TDesC16& aValue ); |
|
85 |
|
86 /** |
|
87 * Gets the value of an integer key in the repository. |
|
88 * |
|
89 * @param aUid The UID of the repository. |
|
90 * @param aKey The key within the repository. |
|
91 * @param aValue On return, the value of the key within the repository. |
|
92 */ |
|
93 static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TInt& aValue ); |
|
94 |
|
95 /** |
|
96 * Gets the value of a floating point key in the repository. |
|
97 * |
|
98 * @param aUid The UID of the repository. |
|
99 * @param aKey The key within the repository. |
|
100 * @param aValue On return, the value of the key within the repository. |
|
101 */ |
|
102 static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TReal& aValue ); |
|
103 |
|
104 /** |
|
105 * Gets the value of a binary key in the repository. |
|
106 * |
|
107 * @param aUid The UID of the repository. |
|
108 * @param aKey The key within the repository. |
|
109 * @param aValue On return, the value of the key within the repository. |
|
110 */ |
|
111 static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TDes8& aValue ); |
|
112 |
|
113 /** |
|
114 * Gets the value of a string key in the repository. |
|
115 * |
|
116 * @param aUid The UID of the repository. |
|
117 * @param aKey The key within the repository. |
|
118 * @param aValue On return, the value of the key within the repository. |
|
119 */ |
|
120 static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TDes16& aValue ); |
|
121 |
|
122 private: |
|
123 |
|
124 CRadioRepositoryManagerImp( TInt aGranularity ); |
|
125 |
|
126 void ConstructL(); |
|
127 |
|
128 // from base class CRadioRepositoryManager |
|
129 |
|
130 void AddObserverL( MRadioRepositoryEntityObserver* aObserver ); |
|
131 void RemoveObserver( MRadioRepositoryEntityObserver* aObserver ); |
|
132 void EnableSave( TBool aEnable ); |
|
133 void AddEntityL( const TUid& aUid, TUint32 aKey, TRadioEntityType aType ); |
|
134 void RemoveEntity( const TUid& aUid, TUint32 aKey ); |
|
135 TInt SetEntityValue( const TUid& aUid, TUint32 aKey, TInt aValue ); |
|
136 TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TReal& aValue ); |
|
137 TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TDesC8& aValue ); |
|
138 TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TDesC16& aValue ); |
|
139 TInt EntityValueInt( const TUid& aUid, TUint32 aKey ) const; |
|
140 const TReal& EntityValueReal( const TUid& aUid, TUint32 aKey ) const; |
|
141 const TDesC8& EntityValueDes8( const TUid& aUid, TUint32 aKey ) const; |
|
142 const TDesC16& EntityValueDes16( const TUid& aUid, TUint32 aKey ) const; |
|
143 |
|
144 /** |
|
145 * Sets the value of an entity. |
|
146 * |
|
147 * @param aUid The UID of the entity. |
|
148 * @param aKey The key of the entity. |
|
149 * @param aValue The value to set. |
|
150 */ |
|
151 template <typename T> |
|
152 TInt DoSetEntityValue( const TUid& aUid, TUint32 aKey, const T& aValue ); |
|
153 |
|
154 /** |
|
155 * Returns an entity's cached value. |
|
156 * |
|
157 * @param aUid The UID of the entity. |
|
158 * @param aKey The key of the entity. |
|
159 * @return The cached value of the entity. |
|
160 */ |
|
161 template <typename T> |
|
162 const T& DoEntityValue( const TUid& aUid, TUint32 aKey ) const; |
|
163 |
|
164 /** |
|
165 * Sets the value of a key. |
|
166 * |
|
167 * @param aUid The UID of the repository. |
|
168 * @param aKey The key within the repository. |
|
169 * @param aValue The value to set. |
|
170 */ |
|
171 template <typename T> |
|
172 static void DoSetRepositoryValueL( const TUid& aUid, TUint32 aKey, const T& aValue ); |
|
173 |
|
174 /** |
|
175 * Returns a key's value. |
|
176 * |
|
177 * @param aUid The UID of the repository. |
|
178 * @param aKey The key within the repository. |
|
179 * @return The key's value. |
|
180 */ |
|
181 template <typename T> |
|
182 static void DoGetRepositoryValueL( const TUid& aUid, TUint32 aKey, T& aValue ); |
|
183 |
|
184 /** |
|
185 * Returns the entity's index by its UID and key. |
|
186 * |
|
187 * @param aUid The UID of the entity. |
|
188 * @param aKey The key of the entity. |
|
189 * @param The entity's index or <code>KErrNotFound</code> if no such entity could be found. |
|
190 */ |
|
191 TInt EntityIndex( const TUid& aUid, TUint32 aKey ) const; |
|
192 |
|
193 /** |
|
194 * SIS installation does not update central repository, this checks that the new keys are in the repository. |
|
195 */ |
|
196 void CheckRepositoryKeysL(); |
|
197 |
|
198 // from base class MRadioRepositoryEntityObserver |
|
199 |
|
200 void HandleRepositoryValueChangeL( const TUid& aUid, TUint32 aKey, TInt aValue, TInt aError ); |
|
201 void HandleRepositoryValueChangeL( const TUid& aUid, TUint32 aKey, const TReal& aValue, TInt aError ); |
|
202 void HandleRepositoryValueChangeL( const TUid& aUid, TUint32 aKey, const TDesC8& aValue, TInt aError ); |
|
203 void HandleRepositoryValueChangeL( const TUid& aUid, TUint32 aKey, const TDesC16& aValue, TInt aError ); |
|
204 |
|
205 private: // data |
|
206 |
|
207 /** The observers that are notified of changes in the entities' values. */ |
|
208 RPointerArray<MRadioRepositoryEntityObserver> iObservers; |
|
209 |
|
210 /** The entities registered. */ |
|
211 RPointerArray<CRadioRepositoryEntityBase> iEntities; |
|
212 |
|
213 /** Indicates whether or not the entities are allowed to write to the repository. */ |
|
214 TBool iEnableSave; |
|
215 |
|
216 }; |
|
217 |
|
218 #endif // C_RADIOREPOSITORYMANAGERIMP_H |
|