|
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 #ifndef C_RADIOREPOSITORYMANAGER_H |
|
19 #define C_RADIOREPOSITORYMANAGER_H |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 |
|
24 // Forward declarations |
|
25 class MRadioRepositoryEntityObserver; |
|
26 |
|
27 /** The maximum length of a string buffer. */ |
|
28 const TInt KRadioEntityBuf16Length = 256; // Maximum: NCentralRepositoryConstants::KMaxUnicodeStringLength; |
|
29 /** The maximum length of a binary buffer. */ |
|
30 const TInt KRadioEntityBuf8Length = KRadioEntityBuf16Length * 2; // Maximum: NCentralRepositoryConstants::KMaxBinaryLength; |
|
31 |
|
32 /** Maximum length binary buffer. */ |
|
33 typedef TBuf8<KRadioEntityBuf8Length> TRadioEntityBuf8; |
|
34 /** Maximum length string buffer. */ |
|
35 typedef TBuf16<KRadioEntityBuf16Length> TRadioEntityBuf16; |
|
36 |
|
37 /** |
|
38 * Central repository entity manager. |
|
39 * |
|
40 * Manages central repository entities that listen to specific repository and a key within it, notifying the observer |
|
41 * whenever the key's value changes. |
|
42 * |
|
43 * Also a set of static methods are provided that wrap the common use case of central repository where the user |
|
44 * is only interested to read or write the value of a key and then discard the repository object. |
|
45 */ |
|
46 NONSHARABLE_CLASS( CRadioRepositoryManager ) : public CBase |
|
47 { |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Possible entity types. |
|
53 */ |
|
54 enum TRadioEntityType |
|
55 { |
|
56 ERadioEntityInt, /**< The entity is an integer. */ |
|
57 ERadioEntityReal, /**< The entity is a floating point number. */ |
|
58 ERadioEntityDes8, /**< The entity is a binary value. */ |
|
59 ERadioEntityDes16 /**< The entity is a string. */ |
|
60 }; |
|
61 |
|
62 IMPORT_C static CRadioRepositoryManager* NewL( TInt aGranularity ); |
|
63 |
|
64 IMPORT_C ~CRadioRepositoryManager(); |
|
65 |
|
66 /** |
|
67 * Adds observer |
|
68 * |
|
69 * @param aObserver The observer that is notified of all the changes in the observed keys' values. |
|
70 */ |
|
71 virtual void AddObserverL( MRadioRepositoryEntityObserver* aObserver ) = 0; |
|
72 |
|
73 /** |
|
74 * Removes observer |
|
75 * |
|
76 * @param aObserver The observer that is to be removed |
|
77 */ |
|
78 virtual void RemoveObserver( MRadioRepositoryEntityObserver* aObserver ) = 0; |
|
79 |
|
80 /** |
|
81 * Enables or disables the writing of entities' values to the repository. |
|
82 * |
|
83 * Disabling the save functionality is important when the free disk space reaches critical level. |
|
84 * |
|
85 * @param aEnable <code>ETrue</code> if the entities are allowed to write their value to the repository, <code>EFalse</code> otherwise. |
|
86 */ |
|
87 virtual void EnableSave( TBool aEnable ) = 0; |
|
88 |
|
89 /** |
|
90 * Adds an entity to the manager. |
|
91 * |
|
92 * @param aUid The UID of the repository. |
|
93 * @param aKey The key within the repository. |
|
94 * @param aType The type of the key within the repository. |
|
95 */ |
|
96 virtual void AddEntityL( const TUid& aUid, TUint32 aKey, TRadioEntityType aType ) = 0; |
|
97 |
|
98 /** |
|
99 * Removes an entity from the manager. |
|
100 * |
|
101 * Entities should only be removed when they are no longer needed. The destructor of the repository manager |
|
102 * deletes all the remaining entities. |
|
103 * |
|
104 * @param aUid The UID of the entity to be removed. |
|
105 * @param aKey The key of the entity to be removed. |
|
106 */ |
|
107 virtual void RemoveEntity( const TUid& aUid, TUint32 aKey ) = 0; |
|
108 |
|
109 /** |
|
110 * Sets the value of an integer entity. |
|
111 * |
|
112 * @param aUid The UID of the entity. |
|
113 * @param aKey The key of the entity. |
|
114 * @param aValue The value to set. |
|
115 */ |
|
116 virtual TInt SetEntityValue( const TUid& aUid, TUint32 aKey, TInt aValue ) = 0; |
|
117 |
|
118 /** |
|
119 * Sets the value of a floating point entity. |
|
120 * |
|
121 * @param aUid The UID of the entity. |
|
122 * @param aKey The key of the entity. |
|
123 * @param aValue The value to set. |
|
124 */ |
|
125 virtual TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TReal& aValue ) = 0; |
|
126 |
|
127 /** |
|
128 * Sets the value of a binary entity. |
|
129 * |
|
130 * @param aUid The UID of the entity. |
|
131 * @param aKey The key of the entity. |
|
132 * @param aValue The value to set. |
|
133 */ |
|
134 virtual TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TDesC8& aValue ) = 0; |
|
135 |
|
136 /** |
|
137 * Sets the value of a string entity. |
|
138 * |
|
139 * @param aUid The UID of the entity. |
|
140 * @param aKey The key of the entity. |
|
141 * @param aValue The value to set. |
|
142 */ |
|
143 virtual TInt SetEntityValue( const TUid& aUid, TUint32 aKey, const TDesC16& aValue ) = 0; |
|
144 |
|
145 /** |
|
146 * Returns the cached value of an integer entity. |
|
147 * |
|
148 * @param aUid The UID of the entity. |
|
149 * @param aKey The key of the entity. |
|
150 * @return The cached value of the entity. |
|
151 */ |
|
152 virtual TInt EntityValueInt( const TUid& aUid, TUint32 aKey ) const = 0; |
|
153 |
|
154 /** |
|
155 * Returns the cached value of a floating point entity. |
|
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 virtual const TReal& EntityValueReal( const TUid& aUid, TUint32 aKey ) const = 0; |
|
162 |
|
163 /** |
|
164 * Returns the cached value of a binary entity. |
|
165 * |
|
166 * @param aUid The UID of the entity. |
|
167 * @param aKey The key of the entity. |
|
168 * @return The cached value of the entity. |
|
169 */ |
|
170 virtual const TDesC8& EntityValueDes8( const TUid& aUid, TUint32 aKey ) const = 0; |
|
171 |
|
172 /** |
|
173 * Returns the cached value of a string entity. |
|
174 * |
|
175 * @param aUid The UID of the entity. |
|
176 * @param aKey The key of the entity. |
|
177 * @return The cached value of the entity. |
|
178 */ |
|
179 virtual const TDesC16& EntityValueDes16( const TUid& aUid, TUint32 aKey ) const = 0; |
|
180 |
|
181 /** |
|
182 * Sets the value of an integer key in the repository. |
|
183 * |
|
184 * @param aUid The UID of the repository. |
|
185 * @param aKey The key within the repository. |
|
186 * @param aValue The value to set. |
|
187 */ |
|
188 IMPORT_C static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, TInt aValue ); |
|
189 |
|
190 /** |
|
191 * Sets the value of a floating point key in the repository. |
|
192 * |
|
193 * @param aUid The UID of the repository. |
|
194 * @param aKey The key within the repository. |
|
195 * @param aValue The value to set. |
|
196 */ |
|
197 IMPORT_C static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TReal& aValue ); |
|
198 |
|
199 /** |
|
200 * Sets the value of a binary key in the repository. |
|
201 * |
|
202 * @param aUid The UID of the repository. |
|
203 * @param aKey The key within the repository. |
|
204 * @param aValue The value to set. |
|
205 */ |
|
206 IMPORT_C static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TDesC8& aValue ); |
|
207 |
|
208 /** |
|
209 * Sets the value of a string key in the repository. |
|
210 * |
|
211 * @param aUid The UID of the repository. |
|
212 * @param aKey The key within the repository. |
|
213 * @param aValue The value to set. |
|
214 */ |
|
215 IMPORT_C static void SetRepositoryValueL( const TUid& aUid, TUint32 aKey, const TDesC16& aValue ); |
|
216 |
|
217 /** |
|
218 * Gets the value of an integer key in the repository. |
|
219 * |
|
220 * @param aUid The UID of the repository. |
|
221 * @param aKey The key within the repository. |
|
222 * @param aValue On return, the value of the key within the repository. |
|
223 */ |
|
224 IMPORT_C static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TInt& aValue ); |
|
225 |
|
226 /** |
|
227 * Gets the value of a floating point key in the repository. |
|
228 * |
|
229 * @param aUid The UID of the repository. |
|
230 * @param aKey The key within the repository. |
|
231 * @param aValue On return, the value of the key within the repository. |
|
232 */ |
|
233 IMPORT_C static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TReal& aValue ); |
|
234 |
|
235 /** |
|
236 * Gets the value of a binary key in the repository. |
|
237 * |
|
238 * @param aUid The UID of the repository. |
|
239 * @param aKey The key within the repository. |
|
240 * @param aValue On return, the value of the key within the repository. |
|
241 */ |
|
242 IMPORT_C static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TDes8& aValue ); |
|
243 |
|
244 /** |
|
245 * Gets the value of a string key in the repository. |
|
246 * |
|
247 * @param aUid The UID of the repository. |
|
248 * @param aKey The key within the repository. |
|
249 * @param aValue On return, the value of the key within the repository. |
|
250 */ |
|
251 IMPORT_C static void GetRepositoryValueL( const TUid& aUid, TUint32 aKey, TDes16& aValue ); |
|
252 |
|
253 }; |
|
254 |
|
255 #endif // C_RADIOREPOSITORYMANAGER_H |