1 /* |
|
2 * Copyright (c) 2006-2006 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: Song History database used for stroing song history entries. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /* --------------------------------------------------------------------------- |
|
20 * Version history: |
|
21 * Template version: |
|
22 * <ccm_history> |
|
23 * |
|
24 * Version: 3, Thu Apr 14 12:00:00 2008 by Rohit |
|
25 * Ref: |
|
26 * Pc lint fixes |
|
27 * |
|
28 * Version: 2, Thu Apr 10 20:00:00 2008 by Rohit |
|
29 * Ref: |
|
30 * Implemented SongHistory changes for channelwise songs |
|
31 * |
|
32 * </ccm_history> |
|
33 * ============================================================================ |
|
34 */ |
|
35 |
|
36 #ifndef CIRSONGHISTORYDB_H |
|
37 #define CIRSONGHISTORYDB_H |
|
38 |
|
39 #include <d32dbms.h> |
|
40 #include "irsettings.h" |
|
41 |
|
42 class CIRSongHistoryInfo; |
|
43 class CIRSettings; |
|
44 |
|
45 |
|
46 // Maximum no of entries to be stored in the history list. |
|
47 const TInt KMaxNoChannelHistoryDbEntries = 30; |
|
48 const TInt KMaxNoSongHistoryDbEntries = 100; |
|
49 |
|
50 // Maximum length of Dbms field string |
|
51 const TInt KIRDbMaxStrLen = 255; |
|
52 |
|
53 const TInt KIRDbMaxChType = 2; |
|
54 |
|
55 const TInt KMaxColumnLength = 255; |
|
56 |
|
57 NONSHARABLE_CLASS(CIRSongHistoryDb) : public RDbNamedDatabase |
|
58 { |
|
59 //member functions |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Function : NewL() |
|
64 * Two phased construction |
|
65 * @return instance of CIRSongHistoryDb |
|
66 */ |
|
67 static CIRSongHistoryDb* NewL(); |
|
68 |
|
69 /** |
|
70 * Function : NewLC() |
|
71 * Two phased construction |
|
72 * @return instance of CIRSongHistoryDb |
|
73 */ |
|
74 static CIRSongHistoryDb* NewLC(); |
|
75 |
|
76 /** |
|
77 * Function : ~CIRSongHistoryDb() |
|
78 * default destructor |
|
79 */ |
|
80 ~CIRSongHistoryDb(); |
|
81 |
|
82 |
|
83 |
|
84 /** |
|
85 * Function : AddToSongHistoryDbL() |
|
86 * adds the song history entry into data base |
|
87 * @param various channel information |
|
88 */ |
|
89 TBool AddToSongHistoryDbL( const TDesC& aSongName, |
|
90 const TDesC& aArtistName, |
|
91 const TDesC& aChannelName, |
|
92 const TDesC& aChannelUrl, |
|
93 RBuf& aDelSongName, |
|
94 RBuf& aDelArtistname, |
|
95 RBuf& aDelChannelName, |
|
96 RBuf& aDelChannelUrl, |
|
97 TInt aChannelType, |
|
98 TInt aChannelId, |
|
99 TInt aBitrate, |
|
100 const TDesC& aChannelDesc, |
|
101 const TDesC& aImageUrl, |
|
102 const TDesC& aGenreName, |
|
103 const TDesC& aCountryName, |
|
104 const TDesC& aLanguageName, |
|
105 const TDesC& aMusicFlag); |
|
106 /** |
|
107 * Function : AddToSongHistoryDb2L() |
|
108 * adds the song history entry into data base |
|
109 * @param various song information |
|
110 */ |
|
111 TBool AddToSongHistoryDb2L( const TDesC& aSongName, |
|
112 const TDesC& aArtistName, |
|
113 const TDesC& aChannelName, |
|
114 const TDesC& aMusicFlag); |
|
115 |
|
116 |
|
117 /** |
|
118 * CIRSongHistoryDb::GetAllSongHistoryListL() |
|
119 * gets all the song history entries into an array |
|
120 * @param aSongHistoryEntries is the array which is to be filled by the SongHistoryDb. |
|
121 */ |
|
122 |
|
123 void GetAllSongHistoryListL(RPointerArray<CIRSongHistoryInfo>& aSongHistoryEntries); |
|
124 /** |
|
125 * CIRSongHistoryDb::GetAllSongHistoryList2L() |
|
126 * gets all the song history entries into an array |
|
127 * @param aSongEntries is the array which is to be filled by the SongHistoryDb. |
|
128 */ |
|
129 void GetAllSongHistoryList2L(RPointerArray<CIRSongHistoryInfo>& aSongEntries); |
|
130 /** |
|
131 * Function : ClearAllSongHistoryFromDb |
|
132 * delete all the song entries from the database. |
|
133 */ |
|
134 |
|
135 TInt ClearAllSongHistoryFromDb(); |
|
136 |
|
137 /** |
|
138 * Function : ClearAllSongHistoryFromDb2 |
|
139 * delete all the song entries from the database. |
|
140 */ |
|
141 TInt ClearAllSongHistoryFromDb2(); |
|
142 |
|
143 /** |
|
144 * Function : CountSongHistoryDb() |
|
145 * count the database entries |
|
146 */ |
|
147 |
|
148 TInt CountSongHistoryDb(); |
|
149 |
|
150 /** |
|
151 * Function : CountSongHistoryDb2() |
|
152 * count the database entries |
|
153 */ |
|
154 TInt CountSongHistoryDb2(); |
|
155 |
|
156 /** |
|
157 * Function : GetLastHistoryItemL() |
|
158 * Gives the last added entry in the database |
|
159 * @param Channel data to be filled . |
|
160 */ |
|
161 void GetLastHistoryItemL(RBuf& aSongName, RBuf& aArtistName, |
|
162 RBuf& aChannelName, RBuf& aChannelUrl); |
|
163 |
|
164 /** |
|
165 * Function : GetChannelSongsCount() |
|
166 * Returns SongsCount for given channel |
|
167 */ |
|
168 TUint GetChannelSongsCountL( const RBuf& aChannelName, const RBuf& aChannelUrl ); |
|
169 |
|
170 /** |
|
171 * Function : GetChannelSongsCount() |
|
172 * Updates the song history DB when there is a channel removed in the isds. |
|
173 */ |
|
174 void SyncSongHistoryDbL(TInt aChannelId) ; |
|
175 |
|
176 /** |
|
177 * Function : GetIdPresentInDb() |
|
178 * Gets whether the particular channel ID is present in history DB or not. |
|
179 */ |
|
180 TBool GetIdPresentInDbL(TInt aChannelId) ; |
|
181 |
|
182 /** |
|
183 * Function : UpdateSongHistoryDb() |
|
184 * Updates the song history DB when there is a channel change in the isds. |
|
185 */ |
|
186 TInt UpdateSongHistoryDbL( TInt aChannelId, |
|
187 const TDesC& aChannelUrl, |
|
188 const TDesC& aImageUrl, |
|
189 const TDesC& aGenreName, |
|
190 const TDesC& aCountryName, |
|
191 const TDesC& aLanguageName, |
|
192 const TDesC& aMusicFlag); |
|
193 |
|
194 /* |
|
195 * search if a record already exists in database. If yes, delete it. |
|
196 */ |
|
197 void SearchAndDeleteRecordL(const TDesC& aChannelName, const TDesC& aChannelUrl, |
|
198 TInt aChannelType, TInt aPresetId); |
|
199 |
|
200 /* |
|
201 * delete a recorder by the index, for station history database |
|
202 * */ |
|
203 TInt DeleteOneHistory(TInt aIndex); |
|
204 |
|
205 /* |
|
206 * delete a recorder by the index, for songhistory database |
|
207 * */ |
|
208 TInt DeleteOneSongHistory(TInt aIndex); |
|
209 |
|
210 private: |
|
211 |
|
212 /** |
|
213 * Function : ConstructL() |
|
214 * two phase construction |
|
215 */ |
|
216 void ConstructL(); |
|
217 |
|
218 /** |
|
219 * Function : CloseSongHistoryDb() |
|
220 * Closes the database |
|
221 */ |
|
222 void CloseSongHistoryDb(); |
|
223 |
|
224 /** |
|
225 * Function : CreateSongHistoryTablesL() |
|
226 * creates songhistory table with three columns |
|
227 * log data |
|
228 * --------------------------------------------------------------------------- |
|
229 * SongHistoryTable |
|
230 *--------------------------- |
|
231 *| SongName | ArtistName | ChannelName | ChannelUrl | ChannelType | ChannelId | Bitrate | ChannelDesc | ImageUrl | GenreName | CountryName | LanguageName | MusicStatus |
|
232 *--------------------------- |
|
233 *|EDbColText| EDbColText | EDbColText | EDbColText | EDbColUint8 | EDbColUint16 | EDbColUint16 | EDbColText | EDbColText | EDbColText | EDbColText | EDbColText | EDbColText |
|
234 *---------------------------------------------------------------------------- |
|
235 */ |
|
236 void CreateSongHistoryTablesL(); |
|
237 |
|
238 /** |
|
239 * Function : CreateSongHistoryTables2L() |
|
240 * creates songhistory table with three columns |
|
241 * log data |
|
242 * --------------------------------------------------------------------------- |
|
243 * SongHistoryTable |
|
244 *--------------------------- |
|
245 *| SongName | ArtistName | ChannelName | MusicStatusFlag |
|
246 *--------------------------- |
|
247 *|EDbColText| EDbColText | EDbColText | EDbColText | |
|
248 *---------------------------------------------------------------------------- |
|
249 */ |
|
250 void CreateSongHistoryTables2L(); |
|
251 |
|
252 /** |
|
253 * Function : CreateDbCondition() |
|
254 * Creates the dbms file conditionally(only if not yet created) |
|
255 * @param aSongHistoryDbFile the Database file name |
|
256 */ |
|
257 void CreateDbCondition(const TFileName& aSongHistoryDbFile); |
|
258 |
|
259 |
|
260 /** |
|
261 * Function : OpenSongHistoryDbL() |
|
262 * @param aSongHistoryDbFile the Database file name |
|
263 * opening the data base |
|
264 */ |
|
265 void OpenSongHistoryDbL(const TFileName& aSongHistoryDbFile); |
|
266 |
|
267 /** |
|
268 * Function : CreateSongHistoryDb() |
|
269 * creates the dbms files |
|
270 * @param aSongHistoryDbFile database filename |
|
271 */ |
|
272 TInt CreateSongHistoryDb(const TFileName& aSongHistoryDbFile); |
|
273 |
|
274 /** |
|
275 * to wrapper the delete leaving |
|
276 */ |
|
277 TInt DeleteOneHistoryL(TInt aIndex); |
|
278 |
|
279 /** |
|
280 * to wrapper the delete leaving |
|
281 */ |
|
282 TInt DeleteOneSongHistoryL(TInt aIndex); |
|
283 |
|
284 /** |
|
285 * Data-structure to hold unique channel info |
|
286 */ |
|
287 class CIRChannelInfo : public CBase |
|
288 { |
|
289 public: |
|
290 ~CIRChannelInfo() |
|
291 { |
|
292 iChannelUrl.Close(); |
|
293 iChannelName.Close(); |
|
294 } |
|
295 RBuf iChannelUrl; |
|
296 RBuf iChannelName; |
|
297 TInt iChannelType; |
|
298 }; |
|
299 |
|
300 |
|
301 |
|
302 /** |
|
303 * Comparer function to compare two CIRChannelInfo's |
|
304 */ |
|
305 static TBool CompareChannelInfos(const CIRChannelInfo& aFirst, const CIRChannelInfo& aSecond); |
|
306 |
|
307 //data members |
|
308 |
|
309 private: |
|
310 |
|
311 // File session |
|
312 |
|
313 RFs iFsSession; |
|
314 |
|
315 |
|
316 // Table which stores History information |
|
317 |
|
318 RDbTable iSongHistoryTable; |
|
319 |
|
320 // only save the song info for the song history view. |
|
321 RDbTable iSongHistoryTable2; |
|
322 |
|
323 }; |
|
324 |
|
325 #endif //CIRSONGHISTORYDB_H |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|