|
1 /* |
|
2 * Copyright (c) 2006-2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IRFAVORITESDB_H |
|
20 #define IRFAVORITESDB_H |
|
21 |
|
22 #include <pspresetobserver.h> |
|
23 #include <psserv.h> |
|
24 |
|
25 class CIRIsdsPreset; |
|
26 class CIRPreset; |
|
27 class CIRSettings; |
|
28 class CPSPresetNotifier; |
|
29 |
|
30 |
|
31 //typedefed to array of pointer array |
|
32 typedef RPointerArray<CIRPreset> RIRPresetArray; |
|
33 |
|
34 //this class is an handle to the presetclient |
|
35 //provides apis to access the presetserver functionalities |
|
36 |
|
37 NONSHARABLE_CLASS( CIRFavoritesDb ):public CBase ,public MPSPresetObserver |
|
38 { |
|
39 |
|
40 public: |
|
41 |
|
42 /**CIRFavoritesDb::NewL() |
|
43 *standard symbian 1st phase constructor |
|
44 *@return CIRFavoritesDb* ,db instance |
|
45 */ |
|
46 IMPORT_C static CIRFavoritesDb* NewL(); |
|
47 |
|
48 |
|
49 /**CIRFavoritesDb::~CIRFavoritesDb() |
|
50 *standard c++ destructor |
|
51 */ |
|
52 ~CIRFavoritesDb(); |
|
53 |
|
54 |
|
55 /**CIRFavoritesDb::AddPresetL() |
|
56 *exported function to add a preset |
|
57 *@param CIRIsdsPreset& the isds preset,TInt index(not in use for 3.2) |
|
58 *@return KerrNone on success,KErrNoMemory if the no of presets is 20 |
|
59 */ |
|
60 IMPORT_C void AddPresetL(CIRIsdsPreset& aPreset,TInt& aIndex, TBool aIsLogoAvialable=EFalse); |
|
61 |
|
62 |
|
63 /**CIRFavoritesDb::AddPresetL() |
|
64 *exported,overloaded function to add a preset manually |
|
65 *@param TDesC name,TDesC url of the preset,TInt,TIntindex and id not in use for 3.2 |
|
66 *@return KerrNone on success,KErrNoMemory if the no of presets is 20 |
|
67 */ |
|
68 IMPORT_C void AddPresetL(const TDesC& aName,const TDesC& aURl, |
|
69 TInt& aReturn, TBool aIsLogoAvialable=EFalse); |
|
70 |
|
71 |
|
72 /**CIRFavoritesDb::DeletePresetL() |
|
73 *exported, function to delete a preset |
|
74 *@param TInt is the id of the preset to be deleted |
|
75 *@return KerrNone on success, |
|
76 */ |
|
77 IMPORT_C void DeletePresetL( TInt aUniqId ); |
|
78 |
|
79 |
|
80 /**CIRFavoritesDb::GetAllPresetL() |
|
81 *exported,function to get the list of saved presets in the array iFavPresetList |
|
82 */ |
|
83 IMPORT_C void GetAllPreset(); |
|
84 |
|
85 /* |
|
86 * get all presets sorted by played times |
|
87 */ |
|
88 IMPORT_C const RIRPresetArray& GetAllSortedPresets(); |
|
89 |
|
90 /**CIRFavoritesDb::SearchPreset() |
|
91 *exported, function to find out if a preset exists in the favorites list |
|
92 *@param TInt the id of the preset to search. |
|
93 *@return the index number of the preset being searched(if found) else KErrNotFound |
|
94 */ |
|
95 IMPORT_C TInt SearchPreset( const TInt aUniqPresetId, |
|
96 const TInt aIsdsPresetId); |
|
97 |
|
98 |
|
99 /**CIRFavoritesDb::GetPreviousPreset() |
|
100 *exported, function to find out if a preset exists in the favorites list |
|
101 *@param TInt the id of the preset . |
|
102 *@return the index number of the previous preset |
|
103 */ |
|
104 IMPORT_C TInt GetPreviousPreset(TInt aIndex); |
|
105 |
|
106 |
|
107 /**CIRFavoritesDb::GetNextPreset() |
|
108 *exported, function to find out if a preset exists in the favorites list |
|
109 *@param TInt the id of the preset . |
|
110 *@return the index number of the next preset |
|
111 */ |
|
112 IMPORT_C TInt GetNextPreset(TInt aIndex); |
|
113 |
|
114 |
|
115 |
|
116 /**CIRFavoritesDb::SwapPresetsInDbL() |
|
117 *returns the previous preset for a given presetId |
|
118 *@param TInt,TInt,TInt,TIntswaps the presets between two |
|
119 *channelIds for given channel Indices |
|
120 *@return TInt system wode error code |
|
121 **/ |
|
122 IMPORT_C void SwapPresetsInDbL(TInt aChannelIdFrom,TInt aChannelIdTo, |
|
123 TInt aChannelIndexFro,TInt aChannelIndexTo); |
|
124 |
|
125 |
|
126 /**CIRFavoritesDb::ReplacePresetL() |
|
127 *replaces a preset with a new preset |
|
128 *@param CIRIsdsPreset instance |
|
129 *for presetSync |
|
130 *@return TInt system wode error code |
|
131 **/ |
|
132 IMPORT_C void ReplacePresetL(CIRIsdsPreset& aNewPreset); |
|
133 |
|
134 |
|
135 /**CIRFavoritesDb::ReplaceUserDefinedPresetL() |
|
136 *replaces a userdefined preset with a new userdefined preset |
|
137 *@param CIRIsdsPreset instance |
|
138 *for presetSync |
|
139 *@return TInt system wide error code |
|
140 **/ |
|
141 IMPORT_C void ReplaceUserDefinedPresetL(CIRIsdsPreset& aNewPreset); |
|
142 |
|
143 |
|
144 /**CIRFavoritesDb::MakePresetUserDefinedL() |
|
145 *for a favorite preset that has been removed from the isds. |
|
146 *it is made a user defined preset by changing the type to 0. |
|
147 *index value is preseved so that the relative positions in the saved |
|
148 *stations view remains the same. |
|
149 *@param TInt,TInt |
|
150 *@return TInt |
|
151 **/ |
|
152 IMPORT_C void MakePresetUserDefinedL(TInt aChannelId,TInt aUserDefinedChannelId); |
|
153 |
|
154 /** |
|
155 *const RVRPresetArray& CVRPresetHandler::Presets() const |
|
156 * @return RIRPresetArray& an array containing all Internet Radio presets. |
|
157 */ |
|
158 IMPORT_C const RIRPresetArray& Presets() const; |
|
159 /** |
|
160 *TInt CIRFavoritesDb::EmptyPresetCount() const |
|
161 *Returns the number of empty presets |
|
162 *@return TInt the number of empty presets |
|
163 */ |
|
164 IMPORT_C TInt EmptyPresetCount() const; |
|
165 |
|
166 /** |
|
167 *TInt CIRFavoritesDb::AddObserver( MPSPresetObserver& aObserver ) |
|
168 *Adds an observer that is notified upon changes in presets. |
|
169 *@param MPSPresetObserver& |
|
170 */ |
|
171 |
|
172 IMPORT_C TInt AddObserver( const MPSPresetObserver& aObserver ); |
|
173 |
|
174 /** |
|
175 *TInt CIRPresetHandler::RemoveObserver( MPSPresetObserver& aObserver ) |
|
176 *Removes an observer for a preset. |
|
177 */ |
|
178 IMPORT_C void RemoveObserver(const MPSPresetObserver& aObserver ); |
|
179 |
|
180 /**CIRFavoritesDb::MaxPresetCount() |
|
181 *returns the maximum number of presets that can be stored in the favorites list |
|
182 *@return TInt maximum number of presets that can be stored in the favorites list |
|
183 **/ |
|
184 IMPORT_C TInt MaxPresetCount(); |
|
185 |
|
186 /** CIRFavoritesDb::SetMoveStatus(TBool aStatus) |
|
187 * @aStatus, sets the status of the Move functionality progression |
|
188 **/ |
|
189 IMPORT_C void SetMoveStatus(TBool aStatus); |
|
190 |
|
191 /** CIRFavoritesDb::GetMoveStatus() |
|
192 * returns the status of the Move functionality |
|
193 **/ |
|
194 IMPORT_C TBool GetMoveStatus(); |
|
195 |
|
196 /* |
|
197 * Increase the played times of a channel if it has been in the favorites |
|
198 * return : KErrNone if success |
|
199 * KErrNotFound if the preset is not in the favorites |
|
200 */ |
|
201 IMPORT_C TInt IncreasePlayedTimesL(const CIRIsdsPreset &aIsdsPreset); |
|
202 |
|
203 private: |
|
204 |
|
205 /**CIRFavoritesDb::HandlePresetChangedL() |
|
206 *function to notify a change in saved presets |
|
207 *@param TInt,TUid,TPSReason the id of the preset,the id of the |
|
208 *preset handler i.e CIRPreset,the reason of change. |
|
209 */ |
|
210 void HandlePresetChangedL( TInt aId, TUid aDataHandler, MPSPresetObserver::TPSReason aReason ); |
|
211 |
|
212 |
|
213 /**CIRFavoritesDb::MovePresetL() |
|
214 *moves a preset to destination index |
|
215 *@param TInt,TInt,the preset id ,the destination index |
|
216 **/ |
|
217 void MovePresetL( const TInt aId,const TInt aDestinationIndex ); |
|
218 |
|
219 |
|
220 /**CIRFavoritesDb::ConstructL() |
|
221 *Standard 2nd phase construction |
|
222 **/ |
|
223 void ConstructL(); |
|
224 |
|
225 |
|
226 /**CIRFavoritesDb::SortByIndex() |
|
227 *sorts the preset list by index |
|
228 **/ |
|
229 void SortByIndex(); |
|
230 |
|
231 /** |
|
232 *TInt CIRFavoritesDb::MatchingPresetId( TInt aId ) |
|
233 *returns the index of the preset whose id is aId |
|
234 *@return TInt the index of the preset whose id is aId |
|
235 */ |
|
236 TInt MatchingPresetId( TInt aId ); |
|
237 |
|
238 |
|
239 /** |
|
240 *TInt CIRFavoritesDb::CreatePresetL( TInt aIndex ) |
|
241 *creates a preset by the index aIndex |
|
242 *@param TInt aIndex,index of the new preset |
|
243 *@return CIRPreset* |
|
244 */ |
|
245 CIRPreset* CreatePresetL( TInt aIndex ); |
|
246 |
|
247 /* |
|
248 * Search a user defined preset by name and url |
|
249 */ |
|
250 TInt SearchUserDefinedPreset(const TDesC &aName, const TDesC &aUrl); |
|
251 |
|
252 public: |
|
253 |
|
254 /** |
|
255 *CIRFavoritesDb::PresetByIndex(TInt aIndex) |
|
256 * Returns a preset by its id. |
|
257 * @param aId Id of the preset. |
|
258 * @return The preset matching the id or <code>NULL</code> if no such preset exists. |
|
259 */ |
|
260 CIRPreset* PresetByIndex( TInt aIndex ); |
|
261 |
|
262 |
|
263 /** |
|
264 * CIRFavoritesDb::PresetById(TInt aIndex) |
|
265 * Returns a preset by its id. |
|
266 * @param aId Id of the preset. |
|
267 * @return The preset matching the id or <code>NULL</code> if no such preset exists. |
|
268 */ |
|
269 IMPORT_C CIRPreset* PresetById( TInt aId ); |
|
270 |
|
271 |
|
272 /**the preset list accessible to ui*/ |
|
273 /** Internet Radio presets currently stored in the preset server. */ |
|
274 RIRPresetArray iFavPresetList; |
|
275 private: |
|
276 |
|
277 /** Session with the preset server. */ |
|
278 RPSServ iServ; |
|
279 //private: |
|
280 |
|
281 /** Notifier that informs about changes in presets. */ |
|
282 CPSPresetNotifier* iNotifier; |
|
283 /** Observers to notify when presets change. */ |
|
284 RPointerArray<MPSPresetObserver> iObservers; |
|
285 |
|
286 /** The maximum number of supported presets. */ |
|
287 TInt iMaxPresetCount; |
|
288 /**cenrep handle*/ |
|
289 CIRSettings *iSettings; |
|
290 /**type of presets(source)*/ |
|
291 enum TChannelType |
|
292 { |
|
293 EUserDefined,/**added by user*/ |
|
294 EIsdsPreset,/**fetched from isds*/ |
|
295 }; |
|
296 |
|
297 /** iMoveStatus, to know the status of the Move funcitionality */ |
|
298 TBool iMoveStatus; |
|
299 }; |
|
300 |
|
301 #endif //end IRFAVORITESDB_H |