1 /* |
|
2 * Copyright (c) 2005 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: Defines APIs to communicate with Central Repository |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef RADIOFMPRESETCENTRALREPOSITORYHANDLER_H |
|
20 #define RADIOFMPRESETCENTRALREPOSITORYHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <RadioFmPresetUtility.h> |
|
24 #include <RadioPresetUtility.h> |
|
25 #include "RadioFmPresetChannel.h" |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KBufferLength = 20; |
|
29 const TInt KStreamBufferSize = 100; |
|
30 |
|
31 // Forward declare implementation class |
|
32 class TRadioSettings; |
|
33 class CRepository; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * it is a wrapper of Central Repository, responsible for the operations that need to access |
|
39 * the central respositorhy. |
|
40 * |
|
41 * @lib FmPresetUtility.lib |
|
42 * @since Series 60 3.0_version |
|
43 */ |
|
44 class CCentralRepositoryHandler : public CBase |
|
45 { |
|
46 public: |
|
47 /** |
|
48 * Two-phased class constructor. |
|
49 * @param aRadioSettings pointer to the CRadioSettings class |
|
50 */ |
|
51 static CCentralRepositoryHandler* NewL(TRadioSettings& aRadioSettings); |
|
52 /** |
|
53 * Destructor of CCentralRepositoryHandler class. |
|
54 */ |
|
55 virtual ~CCentralRepositoryHandler(); |
|
56 public: |
|
57 /** |
|
58 * Retrieve the preset frequency from Central Repository |
|
59 * @since Series 60 3.0 |
|
60 * @param aIndex the index of which preset to retrieve |
|
61 * @return the frequency stored in Central Repository |
|
62 */ |
|
63 TInt RetrievePresetFrequencyL(TInt aIndex) const; |
|
64 |
|
65 /** |
|
66 * Save channel preset info back to Central Repository |
|
67 * @since Series 60 3.0 |
|
68 * @param aIndex the index of which preset to save |
|
69 * @param aFrequency the frequency to be saved |
|
70 */ |
|
71 void SavePresetFrequencyL(TInt aIndex, TInt aFrequency); |
|
72 |
|
73 /** |
|
74 * Retrieve the preset name from Central Repository |
|
75 * @since Series 60 3.0 |
|
76 * @param aIndex the index of which preset to retrieve |
|
77 * @return the name of the preset stored in Central Repository |
|
78 */ |
|
79 TFmPresetName RetrievePresetNameL(TInt aIndex) const; |
|
80 |
|
81 /** |
|
82 * Retrieve the preset URL from Central Repository |
|
83 * @since Series 60 5.2 |
|
84 * @param aIndex the index of which preset to retrieve |
|
85 * @return the URL of the preset stored in Central Repository |
|
86 */ |
|
87 TFmPresetUrl RetrievePresetUrlL(TInt aIndex) const; |
|
88 |
|
89 /** |
|
90 * Retrieve the preset PTY (programme type) from Central Repository |
|
91 * @since Series 60 5.2 |
|
92 * @param aIndex the index of which preset to retrieve |
|
93 * @return the PTY of the preset stored in Central Repository |
|
94 */ |
|
95 TUint RetrievePresetPTYL(TInt aIndex) const; |
|
96 |
|
97 /** |
|
98 * Retrieve the preset PI code (programme identification) from Central Repository |
|
99 * @since Series 60 5.2 |
|
100 * @param aIndex the index of which preset to retrieve |
|
101 * @return the PI code of the preset stored in Central Repository |
|
102 */ |
|
103 TUint RetrievePresetPIL(TInt aIndex) const; |
|
104 |
|
105 /** |
|
106 * Retrieve the preset favourite information from Central Repository |
|
107 * @since Series 60 5.2 |
|
108 * @param aIndex the index of which preset to retrieve |
|
109 * @return the favourite info of the preset stored in Central Repository |
|
110 */ |
|
111 TBool RetrievePresetFavouriteL(TInt aIndex) const; |
|
112 |
|
113 /** |
|
114 * Retrieve the preset user rename information from Central Repository |
|
115 * @since Series 60 5.2 |
|
116 * @param aIndex the index of which preset to retrieve |
|
117 * @return the user rename info of the preset stored in Central Repository |
|
118 */ |
|
119 TBool RetrievePresetUserRenameL(TInt aIndex) const; |
|
120 |
|
121 /** |
|
122 * Save channel preset name back to Central Repository |
|
123 * @since Series 60 3.0 |
|
124 * @param aIndex the index of which preset to save |
|
125 * @param aStationName the preset name to be saved |
|
126 * @return none |
|
127 */ |
|
128 void SavePresetNameL(TInt aIndex, const TFmPresetName& aStationName ); |
|
129 |
|
130 /** |
|
131 * Save channel URL name back to Central Repository |
|
132 * @since Series 60 5.2 |
|
133 * @param aIndex the index of which preset to save |
|
134 * @param aStationUrl the preset URL to be saved |
|
135 * @return none |
|
136 */ |
|
137 void SavePresetUrlL(TInt aIndex, const TFmPresetUrl& aStationUrl); |
|
138 |
|
139 /** |
|
140 * Save channel PI code back to Central Repository |
|
141 * @since Series 60 5.2 |
|
142 * @param aIndex the index of which preset to save |
|
143 * @param aPI the preset programme identification to be saved |
|
144 * @return none |
|
145 */ |
|
146 void SavePresetPIL(TInt aIndex, TUint aPI); |
|
147 |
|
148 /** |
|
149 * Save channel PTY (genre) back to Central Repository |
|
150 * @since Series 60 5.2 |
|
151 * @param aIndex the index of which preset to save |
|
152 * @param aPTY the preset programme type to be saved |
|
153 * @return none |
|
154 */ |
|
155 void SavePresetPTYL(TInt aIndex, TUint aPTY); |
|
156 |
|
157 /** |
|
158 * Save channel favourite info back to Central Repository |
|
159 * @since Series 60 5.2 |
|
160 * @param aIndex the index of which preset to save |
|
161 * @param aFav the preset favourite info to be saved |
|
162 * @return none |
|
163 */ |
|
164 void SavePresetFavouriteInfoL(TInt aIndex, TBool aFav); |
|
165 |
|
166 /** |
|
167 * Save channel user rename info back to Central Repository |
|
168 * @since Series 60 5.2 |
|
169 * @param aIndex the index of which preset to save |
|
170 * @param aUR the preset user rename info to be saved |
|
171 * @return none |
|
172 */ |
|
173 void SavePresetUserRenameInfoL(TInt aIndex, TBool aUR); |
|
174 |
|
175 /** |
|
176 * Save all FmPreset related persistent info back to Central Repository |
|
177 * @since Series 60 3.0 |
|
178 * @param aIndex - the index of which preset to save |
|
179 * @return none |
|
180 */ |
|
181 void SaveFmPresetSettings(); |
|
182 |
|
183 /** |
|
184 * Delete the specified preset. |
|
185 * Specifying aIndex == 0, will delete all presets. |
|
186 * Has no effect if specified index contains no preset. |
|
187 */ |
|
188 void DeletePresetL(TInt aIndex); |
|
189 |
|
190 /** |
|
191 * Get the current number of presets. |
|
192 * @param aNum - the number of presets. |
|
193 * @return none |
|
194 */ |
|
195 void GetNumberOfPresetsL(TInt& aNum); |
|
196 |
|
197 /** |
|
198 * Get the index of first preset. |
|
199 * @param aIndex - the first preset index. |
|
200 * @return none |
|
201 */ |
|
202 void GetFirstPresetL(TInt& aIndex); |
|
203 |
|
204 /** |
|
205 * Get the index of the next preset. |
|
206 * @param aIndex - the first preset index. |
|
207 * @param aNextIndex - the next preset index. |
|
208 * @return none |
|
209 */ |
|
210 void GetNextPresetL(TInt aIndex,TInt& aNextIndex); |
|
211 |
|
212 |
|
213 private: |
|
214 /** |
|
215 * Default class constructor. |
|
216 * @param aFmPreset - pointer to the CRadioFmPresetUtility instance (used for callbacks) |
|
217 * @param aRadioSettings - pointer to the CRadioSettings class |
|
218 */ |
|
219 CCentralRepositoryHandler(TRadioSettings& aRadioSettings); |
|
220 /** |
|
221 * Second phase class constructor. |
|
222 */ |
|
223 void ConstructL(); |
|
224 /** |
|
225 * Retrieves persistent settings from Central Repository. |
|
226 */ |
|
227 void RetrieveInitialSettings(); |
|
228 |
|
229 /** |
|
230 * Get the channel PTY from the externalized stream. |
|
231 * @param aString - the raw data received from Central Repository |
|
232 */ |
|
233 TUint ConvertStringToChannelPTYL(const TDesC8& aString) const; |
|
234 |
|
235 /** |
|
236 * Get the channel PI code from the externalized stream. |
|
237 * @param aString - the raw data received from Central Repository |
|
238 */ |
|
239 TUint ConvertStringToChannelPIL(const TDesC8& aString) const; |
|
240 |
|
241 /** |
|
242 * Get the channel favourite info from the externalized stream. |
|
243 * @param aString - the raw data received from Central Repository |
|
244 */ |
|
245 TBool ConvertStringToChannelFavouriteL(const TDesC8& aString) const; |
|
246 |
|
247 /** |
|
248 * Get the channel user rename info from the externalized stream. |
|
249 * @param aString - the raw data received from Central Repository |
|
250 */ |
|
251 TBool ConvertStringToChannelUserRenameL(const TDesC8& aString) const; |
|
252 |
|
253 /** |
|
254 * Update the current preset channel's PI code (programme identification). |
|
255 * @param aIndex - the index of which preset's channel name to be updated |
|
256 * @param aPresetChannel - reference to the CRadioSettings class |
|
257 * @param aPI - the new channel PI code to be updated to the preset channel |
|
258 */ |
|
259 void UpdateChannelObjectWithPIL (TInt aIndex, TPresetChannel& aPresetChannel, TUint aPI); |
|
260 |
|
261 /** |
|
262 * Update the current preset channel's PTY (programme type). |
|
263 * @param aIndex - the index of which preset's channel name to be updated |
|
264 * @param aPresetChannel - reference to the CRadioSettings class |
|
265 * @param aPTY - the new channel PTY (genre) to be updated to the preset channel |
|
266 */ |
|
267 void UpdateChannelObjectWithPTYL (TInt aIndex, TPresetChannel& aPresetChannel, TUint aPTY); |
|
268 |
|
269 /** |
|
270 * Update the current preset channel's favourite information. |
|
271 * @param aIndex - the index of which preset's channel name to be updated |
|
272 * @param aPresetChannel - reference to the CRadioSettings class |
|
273 * @param aFav - the new channel favourite info to be updated to the preset channel |
|
274 */ |
|
275 void UpdateChannelObjectWithFavouriteInfoL (TInt aIndex, TPresetChannel& aPresetChannel, TBool aFav); |
|
276 |
|
277 /** |
|
278 * Update the current preset channel's user rename information. |
|
279 * @param aIndex - the index of which preset's channel name to be updated |
|
280 * @param aPresetChannel - reference to the CRadioSettings class |
|
281 * @param aUR - the new channel user rename info to be updated to the preset channel |
|
282 */ |
|
283 void UpdateChannelObjectWithUserRenameInfoL (TInt aIndex, TPresetChannel& aPresetChannel, TBool aUR); |
|
284 /** |
|
285 * Externalize the string in the aBuffer. |
|
286 * @param aPresetChannel - reference to the RadioSettings class |
|
287 * @param aBuffer - the buffer to be externalized |
|
288 */ |
|
289 void ExternalizeToStreamL(const TPresetChannel& aPresetChannel, TDes8& aBuffer); |
|
290 /** |
|
291 * Internalize TPresetChannel from the aBuffer. |
|
292 * @param aPresetChannel - reference to the RadioSettings class |
|
293 * @param aBuffer - the buffer where to internalize from |
|
294 */ |
|
295 void InternalizeFromStreamL(TPresetChannel& aPresetChannel, TDes8& aBuffer); |
|
296 |
|
297 /** |
|
298 * Gets stored information of given index and internalizes the stream to aPreset |
|
299 * @param aIndex the index of the stored preset to be read |
|
300 * @param aPreset a reference to TPresetChannel where to internalize from |
|
301 * @return KErrNone if no errors |
|
302 */ |
|
303 TInt GetPresetL(TInt aIndex, TPresetChannel& aPreset); |
|
304 |
|
305 // Handle to Central Repository server |
|
306 CRepository* iCentralRepository; |
|
307 // Reference to RadioSetting object |
|
308 TRadioSettings* iRadioSettings; |
|
309 |
|
310 TInt iFirstPreset; |
|
311 }; |
|
312 |
|
313 #endif // RADIOFMPRESETCENTRALREPOSITORYHANDLER_H |
|
314 |
|
315 // end of file |
|