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