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