author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:28:40 +0300 | |
branch | RCL_3 |
changeset 66 | 1f1dad4af8f8 |
parent 56 | 2cbbefa9af78 |
permissions | -rw-r--r-- |
53 | 1 |
/* |
2 |
* Copyright (c) 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: Responsible for interation with the music table. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <mpxlog.h> |
|
21 |
#include <mpxmedia.h> |
|
22 |
#include <mpxmediaarray.h> |
|
23 |
#include <mpxcollectionpath.h> |
|
24 |
#include <mpxmediageneraldefs.h> |
|
25 |
#include <mpxmediamusicdefs.h> |
|
26 |
#include <mpxmediaaudiodefs.h> |
|
27 |
#include <mpxmediadrmdefs.h> |
|
28 |
#include <mpxmediamtpdefs.h> |
|
29 |
#include <mpxcollectiondbhgres.rsg> |
|
30 |
||
31 |
#include "mpxdbcommondef.h" |
|
32 |
#include "mpxdbcommonstd.h" |
|
33 |
#include "mpxdbcommonutil.h" |
|
34 |
#include "mpxresource.h" |
|
35 |
||
36 |
#include "mpxcollectiondbdef.h" |
|
37 |
#include "mpxcollectiondbstd.h" |
|
38 |
#include "mpxdbpluginqueries.h" |
|
39 |
#include "mpxdbutil.h" |
|
40 |
#include "mpxdbmanager.h" |
|
41 |
#include "mpxdbmusic.h" |
|
42 |
||
43 |
// CONSTANTS |
|
44 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
45 |
// This is what KNullDesC album computes to for the hash |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
46 |
// to-do: generate this Id through |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
47 |
// MPXDbUtil::GenerateUniqueIdL(EMPXAlbum, KNullDesC, EFalse) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
48 |
// instead of hard-coding the number so if GenerateUniqueIdL |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
49 |
// is modified, this constant doesn't need to be redefined |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
50 |
const TInt KUnknownAlbumID = 1770790356; |
53 | 51 |
// UniqueID column in Uris requests |
52 |
const TInt KColUniqueID = 0; |
|
53 |
// URI column in Uris requests |
|
54 |
const TInt KColUri = 1; |
|
55 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
56 |
_LIT( KAbstractAlbumExt, ".alb" ); |
|
57 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
58 |
||
59 |
const TInt KAllSongsQueryResultGranularity = 250; |
|
60 |
||
61 |
// ============================ MEMBER FUNCTIONS ============================== |
|
62 |
||
63 |
// ---------------------------------------------------------------------------- |
|
64 |
// Two-phased constructor. |
|
65 |
// ---------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
CMPXDbMusic* CMPXDbMusic::NewL( |
|
68 |
CMPXDbManager& aDbManager, |
|
69 |
CMPXResource& aResource, |
|
70 |
MMPXDbMusicObserver& aObserver) |
|
71 |
{ |
|
72 |
MPX_FUNC("CMPXDbMusic::NewL"); |
|
73 |
CMPXDbMusic* self = CMPXDbMusic::NewLC(aDbManager, aResource, aObserver); |
|
74 |
CleanupStack::Pop(self); |
|
75 |
return self; |
|
76 |
} |
|
77 |
||
78 |
// ---------------------------------------------------------------------------- |
|
79 |
// Two-phased constructor. |
|
80 |
// ---------------------------------------------------------------------------- |
|
81 |
// |
|
82 |
CMPXDbMusic* CMPXDbMusic::NewLC( |
|
83 |
CMPXDbManager& aDbManager, |
|
84 |
CMPXResource& aResource, |
|
85 |
MMPXDbMusicObserver& aObserver) |
|
86 |
{ |
|
87 |
MPX_FUNC("CMPXDbMusic::NewLC"); |
|
88 |
||
89 |
CMPXDbMusic* self = new (ELeave) CMPXDbMusic(aDbManager, aObserver); |
|
90 |
CleanupStack::PushL(self); |
|
91 |
self->ConstructL(aResource); |
|
92 |
return self; |
|
93 |
} |
|
94 |
||
95 |
// ---------------------------------------------------------------------------- |
|
96 |
// Destructor |
|
97 |
// ---------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
CMPXDbMusic::~CMPXDbMusic() |
|
100 |
{ |
|
101 |
MPX_FUNC("CMPXDbMusic::~CMPXDbMusic"); |
|
102 |
delete iExtensionsDrm; |
|
103 |
iAllSongsQueryResult.ResetAndDestroy(); |
|
104 |
} |
|
105 |
||
106 |
// ---------------------------------------------------------------------------- |
|
107 |
// Constructor |
|
108 |
// ---------------------------------------------------------------------------- |
|
109 |
// |
|
110 |
CMPXDbMusic::CMPXDbMusic( |
|
111 |
CMPXDbManager& aDbManager, |
|
112 |
MMPXDbMusicObserver& aObserver) : |
|
113 |
CMPXDbTable(aDbManager), |
|
114 |
iObserver(aObserver) |
|
115 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
116 |
,iArtNeedUpdated(ETrue) |
|
117 |
#endif |
|
118 |
,iAllSongsQueryResult(KAllSongsQueryResultGranularity) |
|
119 |
{ |
|
120 |
MPX_FUNC("CMPXDbMusic::CMPXDbMusic"); |
|
121 |
} |
|
122 |
||
123 |
// ---------------------------------------------------------------------------- |
|
124 |
// Second phase constructor. |
|
125 |
// ---------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
void CMPXDbMusic::ConstructL( |
|
128 |
CMPXResource& aResource) |
|
129 |
{ |
|
130 |
MPX_FUNC("CMPXDbMusic::ConstructL"); |
|
131 |
||
132 |
BaseConstructL(); |
|
133 |
iExtensionsDrm = aResource.ReadDesCArrayL(R_MC_FILE_EXTENSIONS_DRM); |
|
134 |
} |
|
135 |
||
136 |
// ---------------------------------------------------------------------------- |
|
137 |
// CMPXDbMusic::AddSongL |
|
138 |
// ---------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
TUint32 CMPXDbMusic::AddSongL( |
|
141 |
const CMPXMedia& aMedia, |
|
142 |
TInt aDrive, |
|
143 |
CMPXMessageArray* aMessageArray) |
|
144 |
{ |
|
145 |
MPX_FUNC("CMPXDbMusic::AddSongL"); |
|
146 |
||
147 |
TUint32 songId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, |
|
148 |
aMedia.ValueText(KMPXMediaGeneralUri), EFalse)); |
|
149 |
||
150 |
if (SongExistsL(songId)) |
|
151 |
{ |
|
152 |
// Delete the existing record first and start from scratch |
|
153 |
DeleteSongL(songId, aDrive, ETrue); |
|
154 |
} |
|
155 |
// add the song |
|
156 |
DoAddSongL(songId, aMedia, aDrive, aMessageArray); |
|
157 |
||
158 |
return songId; |
|
159 |
} |
|
160 |
||
161 |
// ---------------------------------------------------------------------------- |
|
162 |
// CMPXDbMusic::DoAddSongL |
|
163 |
// ---------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
TBool CMPXDbMusic::DoAddSongL( |
|
166 |
TUint32 aSongId, |
|
167 |
const CMPXMedia& aMedia, |
|
168 |
TInt aDrive, |
|
169 |
CMPXMessageArray* aItemChangedMessages) |
|
170 |
{ |
|
171 |
MPX_FUNC("CMPXDbMusic::DoAddSongL"); |
|
172 |
||
173 |
CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount); |
|
174 |
CleanupStack::PushL(fields); |
|
175 |
CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount); |
|
176 |
CleanupStack::PushL(values); |
|
177 |
||
178 |
// add known fields |
|
179 |
MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicUniqueId, aSongId); |
|
180 |
MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicDel, 0); |
|
181 |
||
182 |
TTime time; |
|
183 |
time.HomeTime(); |
|
184 |
HBufC* timeAdded = MPXDbCommonUtil::TTimeToDesLC(time); |
|
185 |
MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicTimeAdded, *timeAdded); |
|
186 |
CleanupStack::PopAndDestroy(timeAdded); |
|
187 |
||
188 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
189 |
//update ContainEmbeddedArt |
|
190 |
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
|
191 |
if (albumArtFilename.Length() > 0) |
|
192 |
{ |
|
193 |
MPXDbCommonUtil::AppendValueL(*fields, *values, KMCMusicContainEmbeddedArt, 1); |
|
194 |
} |
|
195 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
196 |
// process the media parameter and construct the fields and values array |
|
197 |
TBool visible(GenerateMusicFieldsValuesL(aSongId, aMedia, aItemChangedMessages, |
|
198 |
NULL, *fields, *values, aDrive)); |
|
199 |
||
200 |
// create the fields and values strings |
|
201 |
HBufC* fieldStr = MPXDbCommonUtil::StringFromArrayLC(*fields, KMCCommaSign); |
|
202 |
HBufC* valueStr = MPXDbCommonUtil::StringFromArrayLC(*values, KMCCommaSign); |
|
203 |
||
204 |
// execute the query |
|
205 |
iDbManager.ExecuteQueryL(aDrive, KQueryMusicInsert, fieldStr, valueStr); |
|
206 |
||
207 |
CleanupStack::PopAndDestroy(valueStr); |
|
208 |
CleanupStack::PopAndDestroy(fieldStr); |
|
209 |
CleanupStack::PopAndDestroy(values); |
|
210 |
CleanupStack::PopAndDestroy(fields); |
|
211 |
||
212 |
return visible; |
|
213 |
} |
|
214 |
||
215 |
// ---------------------------------------------------------------------------- |
|
216 |
// CMPXDbMusic::UpdateSongL |
|
217 |
// ---------------------------------------------------------------------------- |
|
218 |
// |
|
219 |
CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::UpdateSongL( |
|
220 |
TUint32 aSongId, |
|
221 |
const CMPXMedia& aMedia, |
|
222 |
CMPXMessageArray& aItemChangedMessages) |
|
223 |
{ |
|
224 |
MPX_FUNC("CMPXDbMusic::UpdateSongL"); |
|
225 |
return DoUpdateSongL(aSongId, aMedia, &aItemChangedMessages); |
|
226 |
} |
|
227 |
||
228 |
// ---------------------------------------------------------------------------- |
|
229 |
// CMPXDbMusic::DoUpdateSongL |
|
230 |
// ---------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL( |
|
233 |
TUint32 aSongId, |
|
234 |
const CMPXMedia& aMedia, |
|
235 |
CMPXMessageArray* aItemChangedMessages) |
|
236 |
{ |
|
237 |
MPX_FUNC("CMPXDbMusic::DoUpdateSongL"); |
|
238 |
||
239 |
CMPXDbActiveTask::TChangeVisibility visible(CMPXDbActiveTask::ENotVisibile); |
|
240 |
if (IsSupported(aMedia)) |
|
241 |
{ |
|
242 |
// retrieve the existing record |
|
243 |
TInt oldSongId(0); |
|
244 |
oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2; |
|
245 |
if ( oldSongId <= 0 ) |
|
246 |
{ |
|
247 |
oldSongId = aSongId; |
|
248 |
} |
|
249 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetSong, oldSongId)); |
|
250 |
CleanupClosePushL(recordset); |
|
251 |
||
252 |
if (recordset.Next() != KSqlAtRow) |
|
253 |
{ |
|
254 |
User::Leave(KErrNotFound); |
|
255 |
} |
|
256 |
||
257 |
TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
258 |
recordset.ColumnInt64(EMusicVolumeId))); |
|
259 |
visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages, |
|
260 |
recordset); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
261 |
|
53 | 262 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
263 |
if(iArtNeedUpdated) |
|
264 |
{ |
|
265 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
266 |
// Update Album table |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
267 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist)) |
53 | 268 |
{ |
269 |
TUint32 albumId = recordset.ColumnInt64(EMusicAlbum); |
|
270 |
iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages); |
|
271 |
} |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
272 |
|
53 | 273 |
// Update Artist table |
274 |
if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ) |
|
275 |
{ |
|
276 |
TUint32 artistId = recordset.ColumnInt64(EMusicArtist); |
|
277 |
iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages); |
|
278 |
} |
|
279 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
280 |
} |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
281 |
iArtNeedUpdated = ETrue; //reset flag |
53 | 282 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
283 |
CleanupStack::PopAndDestroy(&recordset); |
|
284 |
} |
|
285 |
||
286 |
return visible; |
|
287 |
} |
|
288 |
||
289 |
// ---------------------------------------------------------------------------- |
|
290 |
// CMPXDbMusic::DoUpdateSongL |
|
291 |
// ---------------------------------------------------------------------------- |
|
292 |
// |
|
293 |
CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::DoUpdateSongL( |
|
294 |
TUint32 aSongId, |
|
295 |
const CMPXMedia& aMedia, |
|
296 |
TInt aDrive, |
|
297 |
CMPXMessageArray* aItemChangedMessages, |
|
298 |
RSqlStatement& aRecordset) |
|
299 |
{ |
|
300 |
MPX_FUNC("CMPXDbMusic::DoUpdateSongL"); |
|
301 |
||
302 |
CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EMusicFieldCount); |
|
303 |
CleanupStack::PushL(fields); |
|
304 |
CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EMusicFieldCount); |
|
305 |
CleanupStack::PushL(values); |
|
306 |
||
307 |
TInt oldSongId(0); |
|
308 |
oldSongId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2; |
|
309 |
if ( oldSongId <= 0 ) |
|
310 |
{ |
|
311 |
oldSongId = aSongId; |
|
312 |
} |
|
313 |
// process the media parameter and construct the fields and values array |
|
314 |
CMPXDbActiveTask::TChangeVisibility visible(GenerateMusicFieldsValuesL(oldSongId, aMedia, aItemChangedMessages, |
|
315 |
&aRecordset, *fields, *values, aDrive)); |
|
316 |
||
317 |
// construct the SET string |
|
318 |
HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign); |
|
319 |
if (setStr->Length()) |
|
320 |
{ |
|
321 |
// execute the query |
|
322 |
iDbManager.ExecuteQueryL(aDrive, KQueryMusicUpdate, setStr, oldSongId); |
|
323 |
} |
|
324 |
||
325 |
CleanupStack::PopAndDestroy(setStr); |
|
326 |
CleanupStack::PopAndDestroy(values); |
|
327 |
CleanupStack::PopAndDestroy(fields); |
|
328 |
||
329 |
return visible; |
|
330 |
} |
|
331 |
||
332 |
// ---------------------------------------------------------------------------- |
|
333 |
// CMPXDbMusic::DeleteSongL |
|
334 |
// ---------------------------------------------------------------------------- |
|
335 |
// |
|
336 |
void CMPXDbMusic::DeleteSongL( |
|
337 |
TUint32 aSongId, |
|
338 |
TInt aDrive, |
|
339 |
TBool aDeleteRecord /* = EFalse */) |
|
340 |
{ |
|
341 |
MPX_FUNC("CMPXDbMusic::DeleteSongL"); |
|
342 |
||
343 |
TPtrC query(aDeleteRecord ? KQueryMusicDelete() : KQueryMusicDeleteUpdate()); |
|
344 |
iDbManager.ExecuteQueryL(aDrive, query, aSongId); |
|
345 |
} |
|
346 |
||
347 |
// ---------------------------------------------------------------------------- |
|
348 |
// CMPXDbMusic::DeleteCategoryL |
|
349 |
// ---------------------------------------------------------------------------- |
|
350 |
// |
|
351 |
void CMPXDbMusic::DeleteCategoryL( |
|
352 |
TMPXGeneralCategory aCategory, |
|
353 |
TUint32 aCategoryId, |
|
354 |
CDesCArray& /* aUriArray */, |
|
355 |
CMPXMessageArray& /* aItemChangedMessages */, |
|
356 |
TInt aDrive) |
|
357 |
{ |
|
358 |
MPX_FUNC("CMPXDbMusic::DeleteCategoryL"); |
|
359 |
TPtrC ptr(MPXDbUtil::MusicFieldNameForCategoryL(aCategory)); |
|
360 |
iDbManager.ExecuteQueryL(aDrive, KQueryMusicDeleteForCategory, &ptr, aCategoryId); |
|
361 |
} |
|
362 |
||
363 |
// ---------------------------------------------------------------------------- |
|
364 |
// CMPXDbMusic::CleanupL |
|
365 |
// ---------------------------------------------------------------------------- |
|
366 |
// |
|
367 |
void CMPXDbMusic::CleanupL() |
|
368 |
{ |
|
369 |
MPX_FUNC("CMPXDbMusic::CleanupL"); |
|
370 |
iDbManager.ExecuteQueryL(KDbManagerAllDrives, KQueryMusicCleanup); |
|
371 |
} |
|
372 |
||
373 |
// ---------------------------------------------------------------------------- |
|
374 |
// CMPXDbMusic::GetNameL |
|
375 |
// ---------------------------------------------------------------------------- |
|
376 |
// |
|
377 |
HBufC* CMPXDbMusic::GetNameL( |
|
378 |
TUint32 aSongId) |
|
379 |
{ |
|
380 |
MPX_FUNC("CMPXDbMusic::GetNameL"); |
|
381 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetTitle, aSongId)); |
|
382 |
CleanupClosePushL(recordset); |
|
383 |
||
384 |
if (recordset.Next() != KSqlAtRow) |
|
385 |
{ |
|
386 |
User::LeaveIfError(KErrNotFound); |
|
387 |
} |
|
388 |
||
389 |
HBufC* title = MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex).AllocL(); |
|
390 |
CleanupStack::PopAndDestroy(&recordset); |
|
391 |
||
392 |
return title; |
|
393 |
} |
|
394 |
||
395 |
// ---------------------------------------------------------------------------- |
|
396 |
// CMPXDbMusic::GetUriL |
|
397 |
// ---------------------------------------------------------------------------- |
|
398 |
// |
|
399 |
HBufC* CMPXDbMusic::GetUriL( |
|
400 |
TUint32 aSongId) |
|
401 |
{ |
|
402 |
MPX_FUNC("CMPXDbMusic::GetUriL"); |
|
403 |
||
404 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetUri, aSongId)); |
|
405 |
CleanupClosePushL(recordset); |
|
406 |
||
407 |
if (recordset.Next() != KSqlAtRow) |
|
408 |
{ |
|
409 |
User::LeaveIfError(KErrNotFound); |
|
410 |
} |
|
411 |
||
412 |
// query fields |
|
413 |
enum |
|
414 |
{ |
|
415 |
EMusicUriLocation = 0, |
|
416 |
EMusicUriVolId |
|
417 |
}; |
|
418 |
||
419 |
TUint volId(recordset.ColumnInt64(EMusicUriVolId)); |
|
420 |
HBufC* fullUri = MPXDbCommonUtil::CreateFullPathL( |
|
421 |
MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId), |
|
422 |
MPXDbCommonUtil::GetColumnTextL(recordset, EMusicUriLocation)); |
|
423 |
||
424 |
CleanupStack::PopAndDestroy(&recordset); |
|
425 |
||
426 |
return fullUri; |
|
427 |
} |
|
428 |
||
429 |
// ---------------------------------------------------------------------------- |
|
430 |
// CMPXDbMusic::GetDriveL |
|
431 |
// ---------------------------------------------------------------------------- |
|
432 |
// |
|
433 |
TInt CMPXDbMusic::GetDriveL( |
|
434 |
TUint32 aSongId) |
|
435 |
{ |
|
436 |
MPX_FUNC("CMPXDbMusic::GetDriveL"); |
|
437 |
return MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
438 |
ExecuteIntQueryL(KQueryMusicVolume, aSongId)); |
|
439 |
} |
|
440 |
||
441 |
// ---------------------------------------------------------------------------- |
|
442 |
// CMPXDbMusic::GetSongInfoL |
|
443 |
// ---------------------------------------------------------------------------- |
|
444 |
// |
|
445 |
HBufC* CMPXDbMusic::GetSongInfoL( |
|
446 |
TUint32 aSongId, |
|
447 |
TUint32& aArtistId, |
|
448 |
TUint32& aAlbumId, |
|
449 |
TUint32& aGenreId, |
|
450 |
TUint32& aComposerId, |
|
451 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
452 |
TUint32& aAbstractAlbumId, |
|
453 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
454 |
TInt& aDriveId, |
|
455 |
HBufC*& aArt) |
|
456 |
{ |
|
457 |
MPX_FUNC("CMPXDbMusic::GetSongInfoL"); |
|
458 |
||
459 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicInfo, aSongId)); |
|
460 |
CleanupClosePushL(recordset); |
|
461 |
||
462 |
if (recordset.Next() != KSqlAtRow) |
|
463 |
{ |
|
464 |
User::Leave(KErrNotFound); |
|
465 |
} |
|
466 |
||
467 |
aDriveId = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
468 |
recordset.ColumnInt64(EMusicVolumeId)); |
|
469 |
aArtistId = recordset.ColumnInt64(EMusicArtist); |
|
470 |
aAlbumId = recordset.ColumnInt64(EMusicAlbum); |
|
471 |
aGenreId = recordset.ColumnInt64(EMusicGenre); |
|
472 |
aComposerId = recordset.ColumnInt64(EMusicComposer); |
|
473 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
474 |
aAbstractAlbumId = recordset.ColumnInt64(EMusicAbstractAlbum); |
|
475 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
476 |
aArt = MPXDbCommonUtil::GetColumnTextL(recordset, EMusicArt).AllocL(); |
|
477 |
HBufC* uri = ConstructUriL(recordset); |
|
478 |
||
479 |
CleanupStack::PopAndDestroy(&recordset); |
|
480 |
||
481 |
return uri; |
|
482 |
} |
|
483 |
||
484 |
// ---------------------------------------------------------------------------- |
|
485 |
// CMPXDbMusic::GetSongL |
|
486 |
// ---------------------------------------------------------------------------- |
|
487 |
// |
|
488 |
TInt CMPXDbMusic::GetSongL( |
|
489 |
const CMPXMedia& aCriteria, |
|
490 |
CMPXMedia*& aMedia) |
|
491 |
{ |
|
492 |
MPX_FUNC("CMPXDbMusic::GetSongL"); |
|
493 |
||
494 |
TUint32 songId(0); |
|
495 |
||
496 |
// find song Id, title, URI, and general flags from its Id and/or URI. Do not use "aCriteria" |
|
497 |
// because it may contain attributes other than Id and URI. We don't want to search the |
|
498 |
// song by fields other than the ID and URI because other attributes for the song may have |
|
499 |
// been changed in the collection since the song was added |
|
500 |
CMPXMedia* criteria = CMPXMedia::NewL(); |
|
501 |
CleanupStack::PushL(criteria); |
|
502 |
if (aCriteria.IsSupported(KMPXMediaGeneralId)) |
|
503 |
{ |
|
504 |
songId = (aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2; |
|
505 |
criteria->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId); |
|
506 |
} |
|
507 |
else if (aCriteria.IsSupported(KMPXMediaGeneralUri)) |
|
508 |
{ |
|
509 |
criteria->SetTextValueL(KMPXMediaGeneralUri, |
|
510 |
aCriteria.ValueText(KMPXMediaGeneralUri)); |
|
511 |
} |
|
512 |
||
513 |
// get the criteria string |
|
514 |
HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(songId, 0, EMPXItem, *criteria); |
|
515 |
||
516 |
// execute the query |
|
517 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicSong, criteriaStr)); |
|
518 |
CleanupClosePushL(recordset); |
|
519 |
||
520 |
TInt err(KErrNone); |
|
521 |
if ((err = recordset.Next()) == KSqlAtRow) |
|
522 |
{ |
|
523 |
RArray<TMPXAttribute> attributes; |
|
524 |
CleanupClosePushL(attributes); |
|
525 |
attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, |
|
526 |
EMPXMediaGeneralId | EMPXMediaGeneralTitle | EMPXMediaGeneralUri | EMPXMediaGeneralFlags)); |
|
527 |
||
528 |
aMedia = CMPXMedia::NewL(); |
|
529 |
CleanupStack::PushL(aMedia); |
|
530 |
||
531 |
UpdateMediaL(recordset, attributes.Array(), *aMedia); |
|
532 |
||
533 |
CleanupStack::Pop(aMedia); |
|
534 |
CleanupStack::PopAndDestroy(&attributes); |
|
535 |
||
536 |
err = KErrNone; |
|
537 |
} |
|
538 |
else |
|
539 |
{ |
|
540 |
err = KErrNotFound; |
|
541 |
} |
|
542 |
||
543 |
CleanupStack::PopAndDestroy(&recordset); |
|
544 |
CleanupStack::PopAndDestroy(criteriaStr); |
|
545 |
CleanupStack::PopAndDestroy(criteria); |
|
546 |
||
547 |
return err; |
|
548 |
} |
|
549 |
||
550 |
// ---------------------------------------------------------------------------- |
|
551 |
// CMPXDbMusic::GetRecentlyPlayedSongsL |
|
552 |
// ---------------------------------------------------------------------------- |
|
553 |
// |
|
554 |
void CMPXDbMusic::GetRecentlyPlayedSongsL( |
|
555 |
const TArray<TMPXAttribute>& aAttrs, |
|
556 |
CMPXMediaArray& aMediaArray) |
|
557 |
{ |
|
558 |
MPX_FUNC("CMPXDbMusic::GetRecentlyPlayedSongsL"); |
|
559 |
ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetRecentlyPlayed, |
|
560 |
KMPXMaxRecentlyPlayedSongs); |
|
561 |
} |
|
562 |
||
563 |
// ---------------------------------------------------------------------------- |
|
564 |
// CMPXDbMusic::GetMostPlayedSongsL |
|
565 |
// ---------------------------------------------------------------------------- |
|
566 |
// |
|
567 |
void CMPXDbMusic::GetMostPlayedSongsL( |
|
568 |
const TArray<TMPXAttribute>& aAttrs, |
|
569 |
CMPXMediaArray& aMediaArray) |
|
570 |
{ |
|
571 |
MPX_FUNC("CMPXDbMusic::GetMostPlayedSongsL"); |
|
572 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
573 |
KQueryMusicGetMostPlayed() : KQueryMusicGetMostPlayedNoCategories(), |
|
574 |
KMPXMaxMostPlayedSongs); |
|
575 |
} |
|
576 |
||
577 |
// ---------------------------------------------------------------------------- |
|
578 |
// CMPXDbMusic::GetRecentlyAddedSongsL |
|
579 |
// ---------------------------------------------------------------------------- |
|
580 |
// |
|
581 |
void CMPXDbMusic::GetRecentlyAddedSongsL( |
|
582 |
const TArray<TMPXAttribute>& aAttrs, |
|
583 |
CMPXMediaArray& aMediaArray) |
|
584 |
{ |
|
585 |
MPX_FUNC("CMPXDbMusic::GetRecentlyAddedSongsL"); |
|
586 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
587 |
KQueryMusicGetRecentlyAdded() : KQueryMusicGetRecentlyAddedNoCategories()); |
|
588 |
} |
|
589 |
||
590 |
// ---------------------------------------------------------------------------- |
|
591 |
// CMPXDbMusic::CountL |
|
592 |
// ---------------------------------------------------------------------------- |
|
593 |
// |
|
594 |
TInt CMPXDbMusic::CountL() |
|
595 |
{ |
|
596 |
MPX_FUNC("CMPXDbMusic::CountL"); |
|
597 |
return ExecuteSumQueryL(KQueryMusicCount); |
|
598 |
} |
|
599 |
||
600 |
// ---------------------------------------------------------------------------- |
|
601 |
// CMPXDbMusic::GetAlbumsForArtistL |
|
602 |
// ---------------------------------------------------------------------------- |
|
603 |
// |
|
604 |
void CMPXDbMusic::GetAlbumsForArtistL( |
|
605 |
TUint32 aArtistId, |
|
606 |
CMPXMediaArray& aMediaArray) |
|
607 |
{ |
|
608 |
MPX_FUNC("CMPXDbMusic::GetAlbumsForArtistL"); |
|
609 |
||
610 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicAlbum, aArtistId)); |
|
611 |
CleanupClosePushL(recordset); |
|
612 |
||
613 |
TInt err(KErrNone); |
|
614 |
while ((err = recordset.Next()) == KSqlAtRow) |
|
615 |
{ |
|
616 |
TUint32 albumId(recordset.ColumnInt64(KMPXTableDefaultIndex)); |
|
617 |
||
618 |
CMPXMedia* media = CMPXMedia::NewL(); |
|
619 |
CleanupStack::PushL(media); |
|
620 |
||
621 |
media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, albumId); |
|
622 |
media->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem); |
|
623 |
media->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum); |
|
624 |
||
625 |
aMediaArray.AppendL(*media); |
|
626 |
CleanupStack::PopAndDestroy(media); |
|
627 |
} |
|
628 |
||
629 |
CleanupStack::PopAndDestroy(&recordset); |
|
630 |
if (err != KSqlAtEnd) |
|
631 |
{ |
|
632 |
User::LeaveIfError(KErrCorrupt); |
|
633 |
} |
|
634 |
} |
|
635 |
||
636 |
// ---------------------------------------------------------------------------- |
|
637 |
// CMPXDbMusic::GetSongL |
|
638 |
// ---------------------------------------------------------------------------- |
|
639 |
// |
|
640 |
void CMPXDbMusic::GetSongL( |
|
641 |
TInt aSongId, |
|
642 |
const TArray<TMPXAttribute>& aAttrs, |
|
643 |
CMPXMedia& aMedia) |
|
644 |
{ |
|
645 |
MPX_FUNC("CMPXDbMusic::GetSongL"); |
|
646 |
ExecuteMediaQueryL(aAttrs, aMedia, ExtraFieldsRequired(aAttrs) ? |
|
647 |
KQueryMusicGetSong() : KQueryMusicGetSongNoCategories(), aSongId); |
|
648 |
} |
|
649 |
||
650 |
// ---------------------------------------------------------------------------- |
|
651 |
// CMPXDbMusic::GetAllSongsL |
|
652 |
// ---------------------------------------------------------------------------- |
|
653 |
// |
|
654 |
void CMPXDbMusic::GetAllSongsL( |
|
655 |
TInt aDrive, |
|
656 |
TInt aPlaylistId, |
|
657 |
const TArray<TMPXAttribute>& aAttrs, |
|
658 |
CMPXMediaArray& aMediaArray) |
|
659 |
{ |
|
660 |
MPX_FUNC("CMPXDbMusic::GetAllSongsL"); |
|
661 |
ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetAllSongsInfobyPl(), aPlaylistId); |
|
662 |
} |
|
663 |
||
664 |
// ---------------------------------------------------------------------------- |
|
665 |
// CMPXDbMusic::GetAllSongsL |
|
666 |
// ---------------------------------------------------------------------------- |
|
667 |
// |
|
668 |
void CMPXDbMusic::GetAllSongsL( |
|
669 |
const TArray<TMPXAttribute>& aAttrs, |
|
670 |
CMPXMediaArray& aMediaArray) |
|
671 |
{ |
|
672 |
MPX_FUNC("CMPXDbMusic::GetAllSongsL"); |
|
673 |
||
674 |
// do not execute the joins if no category name is required |
|
675 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
676 |
KQueryMusicGetAllSongs() : KQueryMusicGetAllSongsNoCategories()); |
|
677 |
} |
|
678 |
||
679 |
// ---------------------------------------------------------------------------- |
|
680 |
// CMPXDbMusic::GetAllSongsLimitedL |
|
681 |
// ---------------------------------------------------------------------------- |
|
682 |
// |
|
683 |
void CMPXDbMusic::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, |
|
684 |
CMPXMediaArray& aMediaArray, TInt aLimit) |
|
685 |
{ |
|
686 |
MPX_FUNC("CMPXDbMusic::GetAllSongsLimitedL"); |
|
687 |
||
688 |
// Reset and create a cache for the query results. |
|
689 |
if (iAllSongsQueryResult.Count()) |
|
690 |
{ |
|
691 |
iAllSongsQueryResult.ResetAndDestroy(); |
|
692 |
} |
|
693 |
||
694 |
ExecuteQueryAllSongsL(aAttrs); |
|
695 |
||
696 |
TInt limit = aLimit > iAllSongsQueryResult.Count() ? |
|
697 |
iAllSongsQueryResult.Count() : aLimit; |
|
698 |
||
699 |
for ( TInt i=0; i < limit; i++ ) |
|
700 |
{ |
|
701 |
CMPXMedia* m = iAllSongsQueryResult[i]; |
|
702 |
aMediaArray.AppendL(*m); |
|
703 |
} |
|
704 |
} |
|
705 |
||
706 |
// ---------------------------------------------------------------------------- |
|
707 |
// CMPXDbMusic::ExecuteQueryAllSongsL |
|
708 |
// ---------------------------------------------------------------------------- |
|
709 |
// |
|
710 |
void CMPXDbMusic::ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs) |
|
711 |
{ |
|
712 |
// Run query and add result media objects to the cache array. |
|
713 |
MPX_FUNC("CMPXDbMusic::ExecuteQueryAllSongsL"); |
|
714 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
715 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongsMinimum)); |
53 | 716 |
CleanupClosePushL(recordset); |
717 |
||
718 |
TInt err(KErrNone); |
|
719 |
while ((err = recordset.Next()) == KSqlAtRow) |
|
720 |
{ |
|
721 |
CMPXMedia* media = CMPXMedia::NewL(); |
|
722 |
CleanupStack::PushL(media); |
|
723 |
UpdateMediaL(recordset, aAttrs, *media); |
|
724 |
iAllSongsQueryResult.AppendL(media); |
|
725 |
CleanupStack::Pop(media); |
|
726 |
} |
|
727 |
||
728 |
CleanupStack::PopAndDestroy(&recordset); |
|
729 |
if (err!= KSqlAtEnd) |
|
730 |
{ |
|
731 |
User::Leave(KErrCorrupt); |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
||
736 |
// ---------------------------------------------------------------------------- |
|
737 |
// CMPXDbMusic::GetSongsInBlockL |
|
738 |
// ---------------------------------------------------------------------------- |
|
739 |
// |
|
740 |
void CMPXDbMusic::GetSongsInBlockL( |
|
741 |
const TArray<TMPXAttribute>& aAttrs, |
|
742 |
CMPXMediaArray& aMediaArray, |
|
743 |
TPtrC aTitle, |
|
744 |
TUint aNumOfSongs, |
|
745 |
TBool aAsc) |
|
746 |
{ |
|
747 |
MPX_FUNC("CMPXDbMusic::GetSongsInBlockL"); |
|
748 |
||
749 |
if (aAsc) |
|
750 |
{ |
|
751 |
ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockAsc, |
|
752 |
aTitle, aNumOfSongs, ETrue, EAscQuery ); |
|
753 |
} |
|
754 |
else |
|
755 |
{ |
|
756 |
ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsInBlockDsc, |
|
757 |
aTitle, aNumOfSongs, EFalse, EDscQuery ); |
|
758 |
} |
|
759 |
} |
|
760 |
||
761 |
// ---------------------------------------------------------------------------- |
|
762 |
// CMPXDbMusic::GetSongsAtOffsetL |
|
763 |
// ---------------------------------------------------------------------------- |
|
764 |
// |
|
765 |
void CMPXDbMusic::GetSongsAtOffsetL( CMPXMediaArray& aMediaArray, |
|
766 |
const TArray<TMPXAttribute>& aAttrs, |
|
767 |
TInt aOffset, |
|
768 |
TInt aCount ) |
|
769 |
{ |
|
770 |
MPX_DEBUG3("CMPXDbMusic::GetSongsAtOffsetL offset[%d], count[%d]", aOffset, aCount); |
|
771 |
||
772 |
if ( !iAllSongsQueryResult.Count() ) |
|
773 |
{ |
|
774 |
// If there's no cache, create a cache for the query results. |
|
775 |
ExecuteQueryAllSongsL(aAttrs); |
|
776 |
} |
|
777 |
||
778 |
TInt limit = aOffset + aCount > iAllSongsQueryResult.Count() ? |
|
779 |
iAllSongsQueryResult.Count() : aOffset + aCount; |
|
780 |
for ( TInt i = aOffset; i < limit; i++ ) |
|
781 |
{ |
|
782 |
CMPXMedia* m = iAllSongsQueryResult[i]; |
|
783 |
aMediaArray.AppendL(*m); |
|
784 |
} |
|
785 |
||
786 |
MPX_DEBUG1("CMPXDbMusic::GetSongsAtOffsetL() -->"); |
|
787 |
} |
|
788 |
||
789 |
// ---------------------------------------------------------------------------- |
|
790 |
// CMPXDbMusic::GetSongsForArtistL |
|
791 |
// ---------------------------------------------------------------------------- |
|
792 |
// |
|
793 |
void CMPXDbMusic::GetSongsForArtistL( |
|
794 |
TUint aArtistId, |
|
795 |
const TArray<TMPXAttribute>& aAttrs, |
|
796 |
CMPXMediaArray& aMediaArray) |
|
797 |
{ |
|
798 |
MPX_FUNC("CMPXDbMusic::GetSongsForArtistL"); |
|
799 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
800 |
KQueryMusicGetSongsForArtist() : KQueryMusicGetSongsForArtistNoCategories(), |
|
801 |
aArtistId); |
|
802 |
} |
|
803 |
||
804 |
// ---------------------------------------------------------------------------- |
|
805 |
// CMPXDbMusic::GetSongsForAlbumL |
|
806 |
// ---------------------------------------------------------------------------- |
|
807 |
// |
|
808 |
void CMPXDbMusic::GetSongsForAlbumL( |
|
809 |
TUint aAlbumId, |
|
810 |
const TArray<TMPXAttribute>& aAttrs, |
|
811 |
CMPXMediaArray& aMediaArray) |
|
812 |
{ |
|
813 |
MPX_FUNC("CMPXDbMusic::GetSongsForAlbumL"); |
|
814 |
||
815 |
TPtrC query; |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
816 |
if (aAlbumId == KUnknownAlbumID) |
53 | 817 |
{ |
818 |
query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForUnknownAlbum() : |
|
819 |
KQueryMusicGetSongsForUnknownAlbumNoCategories()); |
|
820 |
} |
|
821 |
else |
|
822 |
{ |
|
823 |
query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForAlbum() : |
|
824 |
KQueryMusicGetSongsForAlbumNoCategories()); |
|
825 |
} |
|
826 |
||
827 |
ExecuteMediaQueryL(aAttrs, aMediaArray, query, aAlbumId); |
|
828 |
} |
|
829 |
||
830 |
// ---------------------------------------------------------------------------- |
|
831 |
// CMPXDbMusic::GetSongsForArtistAndAlbumL |
|
832 |
// ---------------------------------------------------------------------------- |
|
833 |
// |
|
834 |
void CMPXDbMusic::GetSongsForArtistAndAlbumL( |
|
835 |
TUint aArtistId, |
|
836 |
TUint aAlbumId, |
|
837 |
const TArray<TMPXAttribute>& aAttrs, |
|
838 |
CMPXMediaArray& aMediaArray) |
|
839 |
{ |
|
840 |
MPX_FUNC("CMPXDbMusic::GetSongsForArtistAndAlbumL"); |
|
841 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
842 |
KQueryMusicGetSongsForArtistAlbum() : KQueryMusicGetSongsForArtistAlbumNoCategories(), |
|
843 |
aArtistId, aAlbumId); |
|
844 |
} |
|
845 |
||
846 |
// ---------------------------------------------------------------------------- |
|
847 |
// CMPXDbMusic::GetSongsForGenreL |
|
848 |
// ---------------------------------------------------------------------------- |
|
849 |
// |
|
850 |
void CMPXDbMusic::GetSongsForGenreL( |
|
851 |
TUint aGenreId, |
|
852 |
const TArray<TMPXAttribute>& aAttrs, |
|
853 |
CMPXMediaArray& aMediaArray) |
|
854 |
{ |
|
855 |
MPX_FUNC("CMPXDbMusic::GetSongsForGenreL"); |
|
856 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
857 |
KQueryMusicGetSongsForGenre() : KQueryMusicGetSongsForGenreNoCategories(), |
|
858 |
aGenreId); |
|
859 |
} |
|
860 |
||
861 |
// ---------------------------------------------------------------------------- |
|
862 |
// CMPXDbMusic::GetSongsForComposerL |
|
863 |
// ---------------------------------------------------------------------------- |
|
864 |
// |
|
865 |
void CMPXDbMusic::GetSongsForComposerL( |
|
866 |
TUint aComposerId, |
|
867 |
const TArray<TMPXAttribute>& aAttrs, |
|
868 |
CMPXMediaArray& aMediaArray) |
|
869 |
{ |
|
870 |
MPX_FUNC("CMPXDbMusic::GetSongsForComposerL"); |
|
871 |
ExecuteMediaQueryL(aAttrs, aMediaArray, ExtraFieldsRequired(aAttrs) ? |
|
872 |
KQueryMusicGetSongsForComposer() : KQueryMusicGetSongsForComposerNoCategories(), |
|
873 |
aComposerId); |
|
874 |
} |
|
875 |
||
876 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
877 |
// ---------------------------------------------------------------------------- |
|
878 |
// CMPXDbMusic::GetAllSongsForAbstractAlbumL |
|
879 |
// ---------------------------------------------------------------------------- |
|
880 |
// |
|
881 |
void CMPXDbMusic::GetAllSongsForAbstractAlbumL( |
|
882 |
TUint aAbstractAlbumId, |
|
883 |
const TArray<TMPXAttribute>& aAttrs, |
|
884 |
CMPXMediaArray& aMediaArray) |
|
885 |
{ |
|
886 |
MPX_FUNC("CMPXDbMusic::GetAllSongsForAbstractAlbumL"); |
|
887 |
ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId); |
|
888 |
} |
|
889 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
890 |
||
891 |
// ---------------------------------------------------------------------------- |
|
892 |
// CMPXDbMusic::AllSongsDurationL |
|
893 |
// ---------------------------------------------------------------------------- |
|
894 |
// |
|
895 |
TInt CMPXDbMusic::AllSongsDurationL() |
|
896 |
{ |
|
897 |
MPX_FUNC("CMPXDbMusic::AllSongsDurationL"); |
|
898 |
return ExecuteSumQueryL(KQueryMusicDurationAll); |
|
899 |
} |
|
900 |
||
901 |
// ---------------------------------------------------------------------------- |
|
902 |
// CMPXDbMusic::ArtistDurationL |
|
903 |
// ---------------------------------------------------------------------------- |
|
904 |
// |
|
905 |
TInt CMPXDbMusic::ArtistDurationL( |
|
906 |
TUint aArtistId) |
|
907 |
{ |
|
908 |
MPX_FUNC("CMPXDbMusic::ArtistDurationL"); |
|
909 |
return ExecuteSumQueryL(KQueryMusicDurationArtist, aArtistId); |
|
910 |
} |
|
911 |
||
912 |
// ---------------------------------------------------------------------------- |
|
913 |
// CMPXDbMusic::AlbumDurationL |
|
914 |
// ---------------------------------------------------------------------------- |
|
915 |
// |
|
916 |
TInt CMPXDbMusic::AlbumDurationL( |
|
917 |
TUint aAlbumId) |
|
918 |
{ |
|
919 |
MPX_FUNC("CMPXDbMusic::AlbumDurationL"); |
|
920 |
return ExecuteSumQueryL(KQueryMusicDurationAlbum, aAlbumId); |
|
921 |
} |
|
922 |
||
923 |
// ---------------------------------------------------------------------------- |
|
924 |
// CMPXDbMusic::ArtistAlbumDurationL |
|
925 |
// ---------------------------------------------------------------------------- |
|
926 |
// |
|
927 |
TInt CMPXDbMusic::ArtistAlbumDurationL( |
|
928 |
TUint aArtistId, |
|
929 |
TUint aAlbumId) |
|
930 |
{ |
|
931 |
MPX_FUNC("CMPXDbMusic::ArtistAlbumDurationL"); |
|
932 |
return ExecuteSumQueryL(KQueryMusicDurationArtistAlbum, aArtistId, aAlbumId); |
|
933 |
} |
|
934 |
||
935 |
// ---------------------------------------------------------------------------- |
|
936 |
// CMPXDbMusic::GenreDurationL |
|
937 |
// ---------------------------------------------------------------------------- |
|
938 |
// |
|
939 |
TInt CMPXDbMusic::GenreDurationL( |
|
940 |
TUint aGenreId) |
|
941 |
{ |
|
942 |
MPX_FUNC("CMPXDbMusic::GenreDurationL"); |
|
943 |
return ExecuteSumQueryL(KQueryMusicDurationGenre, aGenreId); |
|
944 |
} |
|
945 |
||
946 |
// ---------------------------------------------------------------------------- |
|
947 |
// CMPXDbMusic::ComposerDurationL |
|
948 |
// ---------------------------------------------------------------------------- |
|
949 |
// |
|
950 |
TInt CMPXDbMusic::ComposerDurationL( |
|
951 |
TUint aComposerId) |
|
952 |
{ |
|
953 |
MPX_FUNC("CMPXDbMusic::ComposerDurationL"); |
|
954 |
return ExecuteSumQueryL(KQueryMusicDurationComposer, aComposerId); |
|
955 |
} |
|
956 |
||
957 |
// ---------------------------------------------------------------------------- |
|
958 |
// CMPXDbMusic::RecentlyPlayedDurationL |
|
959 |
// ---------------------------------------------------------------------------- |
|
960 |
// |
|
961 |
TInt CMPXDbMusic::RecentlyPlayedDurationL() |
|
962 |
{ |
|
963 |
MPX_FUNC("CMPXDbMusic::RecentlyPlayedDurationL"); |
|
964 |
return ExecuteSumQueryL(KQueryMusicDurationRecentlyPlayed, KMPXMaxRecentlyPlayedSongs); |
|
965 |
} |
|
966 |
||
967 |
// ---------------------------------------------------------------------------- |
|
968 |
// CMPXDbMusic::MostPlayedDurationL |
|
969 |
// ---------------------------------------------------------------------------- |
|
970 |
// |
|
971 |
TInt CMPXDbMusic::MostPlayedDurationL() |
|
972 |
{ |
|
973 |
MPX_FUNC("CMPXDbMusic::MostPlayedDurationL"); |
|
974 |
return ExecuteSumQueryL(KQueryMusicDurationMostPlayed, KMPXMaxMostPlayedSongs); |
|
975 |
} |
|
976 |
||
977 |
// ---------------------------------------------------------------------------- |
|
978 |
// CMPXDbMusic::RecentlyAddedDurationL |
|
979 |
// ---------------------------------------------------------------------------- |
|
980 |
// |
|
981 |
TInt CMPXDbMusic::RecentlyAddedDurationL() |
|
982 |
{ |
|
983 |
MPX_FUNC("CMPXDbMusic::RecentlyAddedDurationL"); |
|
984 |
return ExecuteSumQueryL(KQueryMusicDurationRecentlyAdded); |
|
985 |
} |
|
986 |
||
987 |
// ---------------------------------------------------------------------------- |
|
988 |
// CMPXDbMusic::FindSongsL |
|
989 |
// ---------------------------------------------------------------------------- |
|
990 |
// |
|
991 |
void CMPXDbMusic::FindSongsL( |
|
992 |
TUint32 aGeneralId, |
|
993 |
TUint32 aContainerId, |
|
994 |
TMPXGeneralType aType, |
|
995 |
const CMPXMedia& aCriteria, |
|
996 |
const TArray<TMPXAttribute>& aAttrs, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
997 |
CMPXMediaArray& aMediaArray) |
53 | 998 |
{ |
999 |
MPX_FUNC("CMPXDbMusic::FindSongsL"); |
|
1000 |
||
1001 |
// get the selection criteria string |
|
1002 |
HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(aGeneralId, aContainerId, aType, |
|
1003 |
aCriteria); |
|
1004 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1005 |
// construct the sort order depending on category. Albums are always sorted by track, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1006 |
// then name, except for unknown album. Songs are sorted by name for unknown album. |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1007 |
// NULL track number is stored as KMaxTInt so that they will be sorted to the end |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1008 |
TPtrC sortOrder; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1009 |
if ((aType == EMPXGroup) && (MPX_ITEM_CATEGORY(aGeneralId) == EMPXAlbum) && |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1010 |
(aGeneralId != MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, KNullDesC, EFalse))) |
53 | 1011 |
{ |
1012 |
sortOrder.Set(KQueryMusicFindAllSortOrderTrack); |
|
1013 |
} |
|
1014 |
else |
|
1015 |
{ |
|
1016 |
sortOrder.Set(KQueryMusicFindAllSortOrderTitle); |
|
1017 |
} |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1018 |
|
53 | 1019 |
// construct the query |
1020 |
HBufC* query = HBufC::NewLC(KQueryMusicFindAll().Length() + criteriaStr->Length() + |
|
1021 |
sortOrder.Length()); |
|
1022 |
query->Des().Format(KQueryMusicFindAll, criteriaStr, &sortOrder); |
|
1023 |
||
1024 |
// iterate the results and append media objects to the destination array |
|
1025 |
ExecuteMediaQueryL(aAttrs, aMediaArray, *query); |
|
1026 |
||
1027 |
CleanupStack::PopAndDestroy(query); |
|
1028 |
CleanupStack::PopAndDestroy(criteriaStr); |
|
1029 |
} |
|
1030 |
||
1031 |
// ---------------------------------------------------------------------------- |
|
1032 |
// CMPXDbMusic::GetDriveTrackCount |
|
1033 |
// ---------------------------------------------------------------------------- |
|
1034 |
// |
|
1035 |
TUint CMPXDbMusic::GetDriveTrackCountL(TInt aDrive) |
|
1036 |
{ |
|
1037 |
TUint count(0); |
|
1038 |
||
1039 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryMusicCount)); |
|
1040 |
CleanupClosePushL(recordset); |
|
1041 |
||
1042 |
if (recordset.Next() != KSqlAtRow) |
|
1043 |
{ |
|
1044 |
User::Leave(KErrCorrupt); |
|
1045 |
} |
|
1046 |
||
1047 |
count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex)); |
|
1048 |
CleanupStack::PopAndDestroy(&recordset); |
|
1049 |
||
1050 |
return count; |
|
1051 |
} |
|
1052 |
||
1053 |
// ---------------------------------------------------------------------------- |
|
1054 |
// CMPXDbMusic::GetMusicUriArrayL |
|
1055 |
// ---------------------------------------------------------------------------- |
|
1056 |
// |
|
1057 |
void CMPXDbMusic::GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords, |
|
1058 |
CDesCArray& aUriArr, TInt& aLastID) |
|
1059 |
{ |
|
1060 |
MPX_FUNC("CMPXDbMusic::GetMusicUriArrayL"); |
|
1061 |
||
1062 |
HBufC* query = NULL; |
|
1063 |
if(aFromID == 0) |
|
1064 |
{ |
|
1065 |
query = HBufC::NewLC(KQueryMusicGetMusicUris().Length() + KMCIntegerLen); |
|
1066 |
query->Des().Format(KQueryMusicGetMusicUris, aRecords); |
|
1067 |
} |
|
1068 |
else |
|
1069 |
{ |
|
1070 |
query = HBufC::NewLC(KQueryMusicGetMusicUrisFrom().Length() + 2*KMCIntegerLen); |
|
1071 |
query->Des().Format(KQueryMusicGetMusicUrisFrom, aFromID, aRecords); |
|
1072 |
} |
|
1073 |
||
1074 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,*query)); |
|
1075 |
||
1076 |
CleanupStack::PopAndDestroy(query); |
|
1077 |
||
1078 |
CleanupClosePushL(recordset); |
|
1079 |
||
1080 |
TInt lastID = 0; |
|
1081 |
TInt err(KErrNone); |
|
1082 |
while((err = recordset.Next()) == KSqlAtRow) |
|
1083 |
{ |
|
1084 |
HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive, |
|
1085 |
MPXDbCommonUtil::GetColumnTextL(recordset, KColUri)); |
|
1086 |
CleanupStack::PushL(fullPath); |
|
1087 |
aUriArr.AppendL(*fullPath); |
|
1088 |
CleanupStack::PopAndDestroy(fullPath); |
|
1089 |
||
1090 |
lastID = recordset.ColumnInt(KColUniqueID); |
|
1091 |
} |
|
1092 |
CleanupStack::PopAndDestroy(&recordset); |
|
1093 |
||
1094 |
aLastID = lastID; |
|
1095 |
||
1096 |
if (err!= KSqlAtEnd) |
|
1097 |
{ |
|
1098 |
User::Leave(KErrCorrupt); |
|
1099 |
} |
|
1100 |
} |
|
1101 |
||
1102 |
// ---------------------------------------------------------------------------- |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1103 |
// CMPXDbMusic::ArtistForAlbumL |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1104 |
// ---------------------------------------------------------------------------- |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1105 |
// |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1106 |
TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1107 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1108 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1109 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1110 |
CleanupClosePushL(recordset); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1111 |
if (recordset.Next() != KSqlAtRow) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1112 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1113 |
User::Leave(KErrNotFound); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1114 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1115 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1116 |
TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1117 |
CleanupStack::PopAndDestroy(&recordset); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1118 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1119 |
return artistId; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1120 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1121 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1122 |
// ---------------------------------------------------------------------------- |
53 | 1123 |
// CMPXDbMusic::AlbumartForAlbumL |
1124 |
// ---------------------------------------------------------------------------- |
|
1125 |
// |
|
1126 |
HBufC* CMPXDbMusic::AlbumartForAlbumL(const TUint32 aAlbumId, TPtrC aArt) |
|
1127 |
{ |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1128 |
MPX_FUNC("CMPXDbMusic::AlbumartForAlbumL"); |
53 | 1129 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAlbumartForAlbum, aAlbumId)); |
1130 |
HBufC* albumart(NULL); |
|
1131 |
||
1132 |
CleanupClosePushL(recordset); |
|
1133 |
TInt err(KErrNone); |
|
1134 |
while ((err = recordset.Next()) == KSqlAtRow) |
|
1135 |
{ |
|
1136 |
TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, KMPXTableDefaultIndex)); |
|
1137 |
if (art.Length()>0 && art.Compare(KNullDesC)!=0 && art.CompareF(aArt)!=0 ) |
|
1138 |
{ |
|
1139 |
albumart = art.AllocL(); |
|
1140 |
break; |
|
1141 |
} |
|
1142 |
} |
|
1143 |
||
1144 |
CleanupStack::PopAndDestroy(&recordset); |
|
1145 |
return albumart; |
|
1146 |
} |
|
1147 |
// ---------------------------------------------------------------------------- |
|
1148 |
// CMPXDbMusic::SongExistsL |
|
1149 |
// ---------------------------------------------------------------------------- |
|
1150 |
// |
|
1151 |
TBool CMPXDbMusic::SongExistsL( |
|
1152 |
TUint32 aSongId) |
|
1153 |
{ |
|
1154 |
MPX_FUNC("CMPXDbMusic::SongExistsL"); |
|
1155 |
||
1156 |
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicVolumeAll, aSongId)); |
|
1157 |
TBool found = (recordset.Next() == KSqlAtRow); |
|
1158 |
recordset.Close(); |
|
1159 |
||
1160 |
return found; |
|
1161 |
} |
|
1162 |
||
1163 |
// ---------------------------------------------------------------------------- |
|
1164 |
// CMPXDbMusic::UpdateMediaL |
|
1165 |
// ---------------------------------------------------------------------------- |
|
1166 |
// |
|
1167 |
void CMPXDbMusic::UpdateMediaL( |
|
1168 |
RSqlStatement& aMusicTable, |
|
1169 |
const TArray<TMPXAttribute>& aAttrs, |
|
1170 |
CMPXMedia& aMedia) |
|
1171 |
{ |
|
1172 |
MPX_FUNC("CMPXDbMusic::UpdateMediaL"); |
|
1173 |
||
1174 |
TInt count(aAttrs.Count()); |
|
1175 |
for (TInt i = 0; i < count; ++i) |
|
1176 |
{ |
|
1177 |
switch (aAttrs[i].ContentId()) |
|
1178 |
{ |
|
1179 |
case KMPXMediaIdGeneral: |
|
1180 |
{ |
|
1181 |
UpdateMediaGeneralL(aMusicTable, aAttrs[i].AttributeId(), aMedia); |
|
1182 |
break; |
|
1183 |
} |
|
1184 |
case KMPXMediaIdMusic: |
|
1185 |
{ |
|
1186 |
UpdateMediaMusicL(aMusicTable, aAttrs[i].AttributeId(), aMedia); |
|
1187 |
break; |
|
1188 |
} |
|
1189 |
case KMPXMediaIdDrm: |
|
1190 |
{ |
|
1191 |
// DRM is set by drm helper |
|
1192 |
break; |
|
1193 |
} |
|
1194 |
case KMPXMediaIdMTP: |
|
1195 |
{ |
|
1196 |
// Only attribute stored in db is MTP drm status |
|
1197 |
UpdateMediaMTPL(aMusicTable, aAttrs[i].AttributeId(), aMedia); |
|
1198 |
break; |
|
1199 |
} |
|
1200 |
case KMPXMediaIdAudio: |
|
1201 |
{ |
|
1202 |
UpdateMediaAudioL(aMusicTable, aAttrs[i].AttributeId(), aMedia); |
|
1203 |
break; |
|
1204 |
} |
|
1205 |
default: |
|
1206 |
// Do not leave. If this plugin doesn't support |
|
1207 |
// the content id they want, just return what we have |
|
1208 |
break; |
|
1209 |
} // end switch |
|
1210 |
} // end for |
|
1211 |
} |
|
1212 |
||
1213 |
// ---------------------------------------------------------------------------- |
|
1214 |
// CMPXDbMusic::UpdateMediaGeneralL |
|
1215 |
// ---------------------------------------------------------------------------- |
|
1216 |
// |
|
1217 |
void CMPXDbMusic::UpdateMediaGeneralL( |
|
1218 |
RSqlStatement& aMusicTable, |
|
1219 |
const TUint aAttrId, |
|
1220 |
CMPXMedia& aMedia) |
|
1221 |
{ |
|
1222 |
MPX_DEBUG1("-->CMPXDbMusic::UpdateMediaGeneralL"); |
|
1223 |
MPX_DEBUG2(" aAttrId=%b", aAttrId); |
|
1224 |
||
1225 |
aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem ); |
|
1226 |
aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong ); |
|
1227 |
||
1228 |
// FIX ME, temporary always fetch item ID |
|
1229 |
//if (aAttrId & EMPXMediaGeneralId) |
|
1230 |
if (!aMedia.IsSupported(KMPXMediaGeneralId)) |
|
1231 |
{ |
|
1232 |
MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralId)"); |
|
1233 |
TUint32 songId(aMusicTable.ColumnInt64(EMusicUniqueId)); |
|
1234 |
TInt columnCount(aMusicTable.ColumnCount()); |
|
1235 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1236 |
if(columnCount == 40 && aMusicTable.ColumnIndex(_L("PlUId"))==38) |
|
1237 |
{ |
|
1238 |
TUint32 pListUId(aMusicTable.ColumnInt64(38)); |
|
1239 |
aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId)); |
|
1240 |
} |
|
1241 |
#else |
|
1242 |
if(columnCount == 37 && aMusicTable.ColumnIndex(_L("PlUId"))==35) |
|
1243 |
{ |
|
1244 |
TUint32 pListUId(aMusicTable.ColumnInt64(35)); |
|
1245 |
aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId)); |
|
1246 |
} |
|
1247 |
#endif |
|
1248 |
else |
|
1249 |
{ |
|
1250 |
aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId); |
|
1251 |
} |
|
1252 |
MPX_DEBUG2(" SongId[%d]", songId); |
|
1253 |
} |
|
1254 |
// FIX ME temporary always fetch URI |
|
1255 |
if (aAttrId & EMPXMediaGeneralUri) |
|
1256 |
{ |
|
1257 |
MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
|
1258 |
HBufC* uri = ConstructUriL(aMusicTable); |
|
1259 |
CleanupStack::PushL(uri); |
|
1260 |
aMedia.SetTextValueL(KMPXMediaGeneralUri, *uri); |
|
1261 |
MPX_DEBUG2(" FullPath[%S]", uri); |
|
1262 |
CleanupStack::PopAndDestroy(uri); |
|
1263 |
} |
|
1264 |
if (aAttrId & EMPXMediaGeneralDrive) |
|
1265 |
{ |
|
1266 |
MPX_DEBUG1(" EMPXMediaGeneralDrive"); |
|
1267 |
TDriveUnit driveUnit; |
|
1268 |
if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
|
1269 |
{ |
|
1270 |
MPX_DEBUG1(" aMedia.IsSupported(KMPXMediaGeneralUri)"); |
|
1271 |
driveUnit = aMedia.ValueText(KMPXMediaGeneralUri); |
|
1272 |
MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
|
1273 |
} |
|
1274 |
else |
|
1275 |
{ |
|
1276 |
MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
|
1277 |
driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
1278 |
aMusicTable.ColumnInt64(EMusicVolumeId)); |
|
1279 |
MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
|
1280 |
} |
|
1281 |
||
1282 |
TPtrC driveName(driveUnit.Name()); |
|
1283 |
aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveName); |
|
1284 |
MPX_DEBUG2(" Drive[%S]", &driveName); |
|
1285 |
} |
|
1286 |
if (aAttrId & EMPXMediaGeneralSize) |
|
1287 |
{ |
|
1288 |
MPX_DEBUG1(" EMPXMediaGeneralSize"); |
|
1289 |
// to-do: store this in the DB |
|
1290 |
} |
|
1291 |
if (aAttrId & EMPXMediaGeneralDuration) |
|
1292 |
{ |
|
1293 |
MPX_DEBUG1(" EMPXMediaGeneralDuration"); |
|
1294 |
TInt32 duration(aMusicTable.ColumnInt(EMusicDuration)); |
|
1295 |
aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration); |
|
1296 |
MPX_DEBUG2(" Duration[%d]", duration); |
|
1297 |
} |
|
1298 |
if ((aAttrId & EMPXMediaGeneralTitle) && !aMedia.IsSupported(KMPXMediaGeneralTitle)) |
|
1299 |
{ |
|
1300 |
MPX_DEBUG1(" EMPXMediaGeneralTitle"); |
|
1301 |
TPtrC title(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicTitle)); |
|
1302 |
aMedia.SetTextValueL(KMPXMediaGeneralTitle, title); |
|
1303 |
MPX_DEBUG2(" Title[%S]", &title); |
|
1304 |
} |
|
1305 |
if ( aAttrId & EMPXMediaGeneralDate) |
|
1306 |
{ |
|
1307 |
MPX_DEBUG1(" EMPXMediaGeneralDate"); |
|
1308 |
const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
|
1309 |
EMusicTimeAdded)); |
|
1310 |
if ( dateStr.Compare (KNullDesC)!= 0) |
|
1311 |
{ |
|
1312 |
TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
|
1313 |
aMedia.SetTObjectValueL<TInt64> (KMPXMediaGeneralDate, |
|
1314 |
dateTime.Int64 ()); |
|
1315 |
} |
|
1316 |
MPX_DEBUG2(" Date[%S]", &dateStr); |
|
1317 |
} |
|
1318 |
if (aAttrId & EMPXMediaGeneralComment) |
|
1319 |
{ |
|
1320 |
MPX_DEBUG1(" EMPXMediaGeneralComment"); |
|
1321 |
TPtrC comment(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComment)); |
|
1322 |
aMedia.SetTextValueL(KMPXMediaGeneralComment, comment); |
|
1323 |
MPX_DEBUG2(" Comment[%S]", &comment); |
|
1324 |
} |
|
1325 |
if (aAttrId & EMPXMediaGeneralMimeType) |
|
1326 |
{ |
|
1327 |
MPX_DEBUG1(" EMPXMediaGeneralMimeType"); |
|
1328 |
TPtrC mimeType(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicMimeType)); |
|
1329 |
aMedia.SetTextValueL(KMPXMediaGeneralMimeType, mimeType); |
|
1330 |
MPX_DEBUG2(" MimeType[%S]", &mimeType); |
|
1331 |
} |
|
1332 |
if (aAttrId & EMPXMediaGeneralSynchronized) |
|
1333 |
{ |
|
1334 |
MPX_DEBUG1(" EMPXMediaGeneralSynchronized"); |
|
1335 |
TInt sync(aMusicTable.ColumnInt(EMusicSync)); |
|
1336 |
aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, sync); |
|
1337 |
MPX_DEBUG2(" Synchronized[%d]", sync); |
|
1338 |
} |
|
1339 |
if (aAttrId & EMPXMediaGeneralDeleted) |
|
1340 |
{ |
|
1341 |
MPX_DEBUG1(" EMPXMediaGeneralDeleted"); |
|
1342 |
TInt del(aMusicTable.ColumnInt(EMusicDeleted)); |
|
1343 |
aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralDeleted, del); |
|
1344 |
MPX_DEBUG2(" Deleted[%d]", del); |
|
1345 |
} |
|
1346 |
if (aAttrId & EMPXMediaGeneralModified) |
|
1347 |
{ |
|
1348 |
MPX_DEBUG1(" EMPXMediaGeneralModified"); |
|
1349 |
TInt mod(aMusicTable.ColumnInt(EMusicModified)); |
|
1350 |
aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralModified, mod); |
|
1351 |
MPX_DEBUG2(" Modified[%d]", mod); |
|
1352 |
} |
|
1353 |
if (aAttrId & EMPXMediaGeneralCount) |
|
1354 |
{ |
|
1355 |
MPX_DEBUG1(" EMPXMediaGeneralCount"); |
|
1356 |
aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
1357 |
} |
|
1358 |
if (aAttrId & EMPXMediaGeneralCollectionId) |
|
1359 |
{ |
|
1360 |
MPX_DEBUG1(" EMPXMediaGeneralCollectionId"); |
|
1361 |
aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, |
|
1362 |
TUid::Uid(KDBPluginUid)); |
|
1363 |
} |
|
1364 |
if(aAttrId & EMPXMediaGeneralCopyright) |
|
1365 |
{ |
|
1366 |
MPX_DEBUG1(" EMPXMediaGeneralCopyright"); |
|
1367 |
TPtrC copyright(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicCopyright)); |
|
1368 |
aMedia.SetTextValueL(KMPXMediaGeneralCopyright, copyright); |
|
1369 |
MPX_DEBUG2(" Copyright[%S]", ©right); |
|
1370 |
} |
|
1371 |
if (aAttrId & EMPXMediaGeneralFlags) |
|
1372 |
{ |
|
1373 |
MPX_DEBUG1(" EMPXMediaGeneralFlags"); |
|
1374 |
TUint32 dbFlags(aMusicTable.ColumnInt64(EMusicDbFlag)); |
|
1375 |
MPX_DEBUG2(" dbFlags=%b", dbFlags); |
|
1376 |
TDriveUnit driveUnit; |
|
1377 |
if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
|
1378 |
{ |
|
1379 |
MPX_DEBUG1(" aMedia.IsSupported(KMPXMediaGeneralUri)"); |
|
1380 |
TParsePtrC parse( aMedia.ValueText(KMPXMediaGeneralUri) ); |
|
1381 |
if( parse.DrivePresent() ) |
|
1382 |
{ |
|
1383 |
driveUnit = parse.Drive(); |
|
1384 |
} |
|
1385 |
else |
|
1386 |
{ |
|
1387 |
driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
1388 |
aMusicTable.ColumnInt64(EMusicVolumeId)); |
|
1389 |
} |
|
1390 |
MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
|
1391 |
} |
|
1392 |
else |
|
1393 |
{ |
|
1394 |
MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
|
1395 |
driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
|
1396 |
aMusicTable.ColumnInt64(EMusicVolumeId)); |
|
1397 |
MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
|
1398 |
} |
|
1399 |
||
1400 |
TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo; // 5 bits |
|
1401 |
aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId); |
|
1402 |
||
1403 |
MPX_DEBUG2(" GeneralFlags[%b]", dbFlags | driveId); |
|
1404 |
MPX_DEBUG2(" DriveId[%u]", driveId); |
|
1405 |
} |
|
1406 |
if (aAttrId & EMPXMediaGeneralPlayCount) |
|
1407 |
{ |
|
1408 |
MPX_DEBUG1(" EMPXMediaGeneralPlayCount"); |
|
1409 |
TUint32 playcount(aMusicTable.ColumnInt(EMusicPlayCount)); |
|
1410 |
aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralPlayCount, playcount); |
|
1411 |
MPX_DEBUG2(" PlayCount[%d]", playcount); |
|
1412 |
} |
|
1413 |
||
1414 |
MPX_DEBUG1("<--CMPXDbMusic::UpdateMediaGeneralL"); |
|
1415 |
} |
|
1416 |
||
1417 |
// ---------------------------------------------------------------------------- |
|
1418 |
// CMPXDbMusic::UpdateMediaMusicL |
|
1419 |
// ---------------------------------------------------------------------------- |
|
1420 |
// |
|
1421 |
void CMPXDbMusic::UpdateMediaMusicL( |
|
1422 |
RSqlStatement& aMusicTable, |
|
1423 |
const TUint aAttrId, |
|
1424 |
CMPXMedia& aMedia) |
|
1425 |
{ |
|
1426 |
MPX_FUNC("CMPXDbMusic::UpdateMediaMusicL"); |
|
1427 |
||
1428 |
if (aAttrId & EMPXMediaMusicAlbumArtFileName) |
|
1429 |
{ |
|
1430 |
TPtrC art(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArt)); |
|
1431 |
aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art); |
|
1432 |
MPX_DEBUG2(" Album Art File Name[%S]", &art); |
|
1433 |
} |
|
1434 |
if (aAttrId & EMPXMediaMusicArtist) |
|
1435 |
{ |
|
1436 |
TPtrC artist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicArtistName)); |
|
1437 |
aMedia.SetTextValueL(KMPXMediaMusicArtist, artist); |
|
1438 |
MPX_DEBUG2(" Artist[%S]", &artist); |
|
1439 |
} |
|
1440 |
if (aAttrId & EMPXMediaMusicAlbum) |
|
1441 |
{ |
|
1442 |
TPtrC album(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumName)); |
|
1443 |
aMedia.SetTextValueL(KMPXMediaMusicAlbum, album); |
|
1444 |
MPX_DEBUG2(" Album[%S]", &album); |
|
1445 |
} |
|
1446 |
if ( aAttrId & EMPXMediaMusicYear) |
|
1447 |
{ |
|
1448 |
const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
|
1449 |
EMusicReleaseDate)); |
|
1450 |
if ( dateStr.Compare (KNullDesC)!= 0) |
|
1451 |
{ |
|
1452 |
TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
|
1453 |
aMedia.SetTObjectValueL<TInt64> (KMPXMediaMusicYear, |
|
1454 |
dateTime.Int64 ()); |
|
1455 |
MPX_DEBUG2(" Year[%d]", dateTime.Int64()); |
|
1456 |
} |
|
1457 |
MPX_DEBUG2(" ReleaseDate[%S]", &dateStr); |
|
1458 |
} |
|
1459 |
if (aAttrId & EMPXMediaMusicAlbumTrack) |
|
1460 |
{ |
|
1461 |
TInt32 track(aMusicTable.ColumnInt(EMusicAlbumTrack)); |
|
1462 |
HBufC* hbuf = HBufC::NewLC(KMCIntegerLen); |
|
1463 |
if (track != KMaxTInt) |
|
1464 |
{ |
|
1465 |
hbuf->Des().AppendFormat(_L("%d"), track); |
|
1466 |
} |
|
1467 |
aMedia.SetTextValueL(KMPXMediaMusicAlbumTrack, *hbuf); |
|
1468 |
MPX_DEBUG3(" Album Track[%S][%d]", hbuf, track); |
|
1469 |
CleanupStack::PopAndDestroy(hbuf); |
|
1470 |
} |
|
1471 |
if (aAttrId & EMPXMediaMusicGenre) |
|
1472 |
{ |
|
1473 |
TPtrC genre(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicGenreName)); |
|
1474 |
aMedia.SetTextValueL(KMPXMediaMusicGenre, genre); |
|
1475 |
MPX_DEBUG2(" Music Genre[%S]", &genre); |
|
1476 |
} |
|
1477 |
if (aAttrId & EMPXMediaMusicComposer) |
|
1478 |
{ |
|
1479 |
TPtrC composer(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComposerName)); |
|
1480 |
aMedia.SetTextValueL(KMPXMediaMusicComposer, composer); |
|
1481 |
MPX_DEBUG2(" Music Composer[%S]", &composer); |
|
1482 |
} |
|
1483 |
if (aAttrId & EMPXMediaMusicRating) |
|
1484 |
{ |
|
1485 |
TUint32 rating(aMusicTable.ColumnInt(EMusicRating)); |
|
1486 |
aMedia.SetTObjectValueL<TUint32>(KMPXMediaMusicRating, rating); |
|
1487 |
MPX_DEBUG2(" Music Rating[%d]", rating); |
|
1488 |
} |
|
1489 |
if (aAttrId & EMPXMediaMusicURL) |
|
1490 |
{ |
|
1491 |
TPtrC url(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicUrl)); |
|
1492 |
aMedia.SetTextValueL(KMPXMediaMusicURL, url); |
|
1493 |
MPX_DEBUG2(" Music URL[%S]", &url); |
|
1494 |
} |
|
1495 |
if (aAttrId & EMPXMediaMusicOriginalAlbumArtFileName) |
|
1496 |
{ |
|
1497 |
// Always set original album art to be file path |
|
1498 |
// Maybe add a new column to db for future if services like rhapsody pushes jpgs to us |
|
1499 |
if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
|
1500 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1501 |
{ |
|
1502 |
TUint32 abstractAlbumId(aMusicTable.ColumnInt64(EMusicAbstractAlbum)); |
|
1503 |
TInt containEmbeddedArt = aMusicTable.ColumnInt( EMusicContainEmbeddedArt); |
|
1504 |
//embedded with art, no art |
|
1505 |
if (containEmbeddedArt || (!containEmbeddedArt && !abstractAlbumId)) //embedded with art case, no art |
|
1506 |
{ |
|
1507 |
const TDesC& art(aMedia.ValueText(KMPXMediaGeneralUri)); |
|
1508 |
aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, art); |
|
1509 |
MPX_DEBUG2(" Music Original Album Art FullPath[%S]", &art); |
|
1510 |
} |
|
1511 |
//for abstractalbum case, originalAlbumArt from AbstractAlbum table |
|
1512 |
else if ( abstractAlbumId ) |
|
1513 |
{ |
|
1514 |
HBufC* art = iObserver.HandleGetAlbumNameFromIdL(abstractAlbumId); |
|
1515 |
CleanupStack::PushL(art); |
|
1516 |
aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, *art); |
|
1517 |
MPX_DEBUG2(" Music Original Album Art FullPath[%S]", art); |
|
1518 |
CleanupStack::PopAndDestroy(art); |
|
1519 |
} |
|
1520 |
} |
|
1521 |
#else |
|
1522 |
{ |
|
1523 |
const TDesC& uri(aMedia.ValueText(KMPXMediaGeneralUri)); |
|
1524 |
aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, uri); |
|
1525 |
MPX_DEBUG2(" Music Original Album Art FullPath[%S]", &uri); |
|
1526 |
} |
|
1527 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1528 |
else |
|
1529 |
{ |
|
1530 |
HBufC* fullPath = ConstructUriL(aMusicTable); |
|
1531 |
CleanupStack::PushL(fullPath); |
|
1532 |
aMedia.SetTextValueL(KMPXMediaMusicOriginalAlbumArtFileName, *fullPath); |
|
1533 |
MPX_DEBUG2(" Music Original Album Art FullPath[%S]", fullPath); |
|
1534 |
CleanupStack::PopAndDestroy(fullPath); |
|
1535 |
} |
|
1536 |
} |
|
1537 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1538 |
if (aAttrId & EMPXMediaMusicAlbumArtist) |
|
1539 |
{ |
|
1540 |
TPtrC albumartist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumArtist)); |
|
1541 |
aMedia.SetTextValueL(KMPXMediaMusicAlbumArtist, albumartist); |
|
1542 |
MPX_DEBUG2(" Music AlbumArtist[%S]", &albumartist); |
|
1543 |
} |
|
1544 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1545 |
} |
|
1546 |
||
1547 |
// ---------------------------------------------------------------------------- |
|
1548 |
// CMPXDbMusic::UpdateMediaAudioL |
|
1549 |
// ---------------------------------------------------------------------------- |
|
1550 |
// |
|
1551 |
void CMPXDbMusic::UpdateMediaAudioL( |
|
1552 |
RSqlStatement& aMusicTable, |
|
1553 |
const TUint aAttrId, |
|
1554 |
CMPXMedia& aMedia) |
|
1555 |
{ |
|
1556 |
MPX_FUNC("CMPXDbMusic::UpdateMediaAudioL"); |
|
1557 |
||
1558 |
if (aAttrId & EMPXMediaAudioBitrate) |
|
1559 |
{ |
|
1560 |
TUint32 bitrate(aMusicTable.ColumnInt(EMusicBitRate)); |
|
1561 |
aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioBitrate, bitrate); |
|
1562 |
MPX_DEBUG2(" Bitrate[%d]", bitrate); |
|
1563 |
} |
|
1564 |
if (aAttrId & EMPXMediaAudioSamplerate) |
|
1565 |
{ |
|
1566 |
TUint32 samplerate(aMusicTable.ColumnInt(EMusicSampleRate)); |
|
1567 |
aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioSamplerate, samplerate); |
|
1568 |
MPX_DEBUG2(" SampleRate[%d]", samplerate); |
|
1569 |
} |
|
1570 |
if (aAttrId & EMPXMediaAudioNumberOfChannels) |
|
1571 |
{ |
|
1572 |
TUint32 numchannels(aMusicTable.ColumnInt(EMusicNumChannels)); |
|
1573 |
aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioNumberOfChannels, numchannels); |
|
1574 |
MPX_DEBUG2(" Num of Channels[%d]", numchannels); |
|
1575 |
} |
|
1576 |
if (aAttrId & EMPXMediaAudioCodec) |
|
1577 |
{ |
|
1578 |
TUint32 codec(aMusicTable.ColumnInt(EMusicCodec)); |
|
1579 |
aMedia.SetTObjectValueL<TUint32>(KMPXMediaAudioAudioCodec, codec); |
|
1580 |
MPX_DEBUG2(" Audio Codec[%d]", codec); |
|
1581 |
} |
|
1582 |
} |
|
1583 |
||
1584 |
// ---------------------------------------------------------------------------- |
|
1585 |
// CMPXDbMusic::UpdateMediaMTPL |
|
1586 |
// ---------------------------------------------------------------------------- |
|
1587 |
// |
|
1588 |
void CMPXDbMusic::UpdateMediaMTPL( |
|
1589 |
RSqlStatement& aMusicTable, |
|
1590 |
const TUint aAttrId, |
|
1591 |
CMPXMedia& aMedia) |
|
1592 |
{ |
|
1593 |
MPX_FUNC("CMPXDbMusic::UpdateMediaMTPL"); |
|
1594 |
||
1595 |
if (aAttrId & KMPXMediaMTPDrmStatus.iAttributeId) |
|
1596 |
{ |
|
1597 |
TUint32 val(aMusicTable.ColumnInt(EMusicMTPDrmStatus)); |
|
1598 |
aMedia.SetTObjectValueL<TUint16>(KMPXMediaMTPDrmStatus, val); |
|
1599 |
} |
|
1600 |
} |
|
1601 |
||
1602 |
// ---------------------------------------------------------------------------- |
|
1603 |
// CMPXDbMusic::GenerateMusicFieldsValuesL |
|
1604 |
// ---------------------------------------------------------------------------- |
|
1605 |
// |
|
1606 |
CMPXDbActiveTask::TChangeVisibility CMPXDbMusic::GenerateMusicFieldsValuesL( |
|
1607 |
TUint32 aSongId, |
|
1608 |
const CMPXMedia& aMedia, |
|
1609 |
CMPXMessageArray* aItemChangedMessages, |
|
1610 |
RSqlStatement* aMusicTable, |
|
1611 |
CDesCArray& aFields, |
|
1612 |
CDesCArray& aValues, |
|
1613 |
TInt aDrive) |
|
1614 |
{ |
|
1615 |
MPX_FUNC("CMPXDbMusic::GenerateMusicFieldsValuesL"); |
|
1616 |
||
1617 |
CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile); |
|
1618 |
TBool metaDataModified(EFalse); |
|
1619 |
const TArray<TMPXAttribute> attributes = aMedia.Attributes(); |
|
1620 |
||
1621 |
TBool addSongChangedMessage(ETrue); |
|
1622 |
CMPXMessage* songChangedMessage(NULL); |
|
1623 |
if (aItemChangedMessages) |
|
1624 |
{ |
|
1625 |
songChangedMessage = CMPXMedia::NewL(); |
|
1626 |
CleanupStack::PushL(songChangedMessage); |
|
1627 |
MPXDbCommonUtil::FillItemChangedMessageL(*songChangedMessage, aSongId, |
|
1628 |
aMusicTable ? EMPXItemModified : EMPXItemInserted, EMPXSong, KDBPluginUid); |
|
1629 |
} |
|
1630 |
||
1631 |
// NOTE: Attributes being processed here should be listed in IsSupported() |
|
1632 |
TInt attrCount(attributes.Count()); |
|
1633 |
for (TInt i = 0; i < attrCount; ++i) |
|
1634 |
{ |
|
1635 |
TUint attributeId(attributes[i].AttributeId()); |
|
1636 |
||
1637 |
switch (attributes[i].ContentId()) |
|
1638 |
{ |
|
1639 |
case KMPXMediaIdGeneral: |
|
1640 |
{ |
|
1641 |
if (attributeId & EMPXMediaGeneralDeleted) |
|
1642 |
{ |
|
1643 |
TBool deleted(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted)); |
|
1644 |
if (!aMusicTable || (deleted != aMusicTable->ColumnInt(EMusicDeleted))) |
|
1645 |
{ |
|
1646 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDel, deleted); |
|
1647 |
} |
|
1648 |
MPX_DEBUG2(" Deleted[%d]", deleted); |
|
1649 |
} |
|
1650 |
||
1651 |
if (attributeId & EMPXMediaGeneralFlags) |
|
1652 |
{ |
|
1653 |
TUint flag(aMedia.ValueTObjectL<TUint>(KMPXMediaGeneralFlags)); |
|
1654 |
TUint32 curFlag(0); |
|
1655 |
if (aMusicTable) |
|
1656 |
{ |
|
1657 |
curFlag = aMusicTable->ColumnInt64(EMusicDbFlag); |
|
1658 |
} |
|
1659 |
TUint32 oldFlag(curFlag); |
|
1660 |
||
1661 |
if (flag & KMPXMediaGeneralFlagsSetOrUnsetBit) |
|
1662 |
{ |
|
1663 |
// Set bits |
|
1664 |
curFlag |= flag; |
|
1665 |
} |
|
1666 |
else |
|
1667 |
{ |
|
1668 |
// Clear bits |
|
1669 |
curFlag &= (~flag); |
|
1670 |
} |
|
1671 |
||
1672 |
// The field is written ONLY if the flag value is changing |
|
1673 |
if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0) |
|
1674 |
{ |
|
1675 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag); |
|
1676 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1677 |
} |
|
1678 |
MPX_DEBUG2(" GeneralFlags[%b]", curFlag); |
|
1679 |
} |
|
1680 |
||
1681 |
if (attributeId & EMPXMediaGeneralTitle) |
|
1682 |
{ |
|
1683 |
TBool titleChanged(NULL == aMusicTable); |
|
1684 |
||
1685 |
const TDesC& title = aMedia.ValueText(KMPXMediaGeneralTitle); |
|
1686 |
TPtrC truncatedTitle(title.Left(KMCMaxTextLen)); |
|
1687 |
if (aMusicTable) |
|
1688 |
{ |
|
1689 |
// Title of the song has been changed |
|
1690 |
if (truncatedTitle.Compare(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTitle)) != 0) |
|
1691 |
{ |
|
1692 |
titleChanged = ETrue; |
|
1693 |
} |
|
1694 |
} |
|
1695 |
||
1696 |
if (titleChanged) |
|
1697 |
{ |
|
1698 |
if ( title.Length() == 0 ) |
|
1699 |
{ |
|
1700 |
const TDesC& path = aMedia.ValueText( KMPXMediaGeneralUri ); |
|
1701 |
TParsePtrC parse( path ); |
|
1702 |
TPtrC truncatedParse( parse.Name().Left( KMCMaxTextLen ) ); |
|
1703 |
||
1704 |
MPXDbCommonUtil::AppendValueL( aFields, aValues, KMCMusicName, truncatedParse ); |
|
1705 |
} |
|
1706 |
else |
|
1707 |
{ |
|
1708 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, truncatedTitle); |
|
1709 |
} |
|
1710 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1711 |
metaDataModified = ETrue; |
|
1712 |
||
1713 |
MPX_DEBUG2(" Title[%S]", &truncatedTitle); |
|
1714 |
} |
|
1715 |
} |
|
1716 |
||
1717 |
if (attributeId & EMPXMediaGeneralMimeType) |
|
1718 |
{ |
|
1719 |
const TDesC& mimeTypeText( aMedia.ValueText(KMPXMediaGeneralMimeType) ); |
|
1720 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMimeType, mimeTypeText); |
|
1721 |
MPX_DEBUG2(" MimeType[%S]", &mimeTypeText); |
|
1722 |
} |
|
1723 |
||
1724 |
if (attributeId & EMPXMediaGeneralUri) |
|
1725 |
{ |
|
1726 |
const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri); |
|
1727 |
const TDesC& uriTrunc(uri.Mid(KMCPathStartPos)); |
|
1728 |
||
1729 |
TDriveUnit driveUnit(uri); |
|
1730 |
TUint volId(MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
|
1731 |
||
1732 |
if (!aMusicTable || ((uriTrunc != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicLocation)) || |
|
1733 |
(volId != aMusicTable->ColumnInt64(EMusicVolumeId)))) |
|
1734 |
{ |
|
1735 |
// only do the update something changed |
|
1736 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicVolumeId, volId); |
|
1737 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicLocation, |
|
1738 |
uri.Mid(KMCPathStartPos)); |
|
1739 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, DRMTypeL(uri)); |
|
1740 |
MPX_DEBUG3(" VolumeId[%u] Location[%S]", volId, &uri); |
|
1741 |
||
1742 |
if (!aMedia.IsSupported(KMPXMediaGeneralMimeType)) |
|
1743 |
{ |
|
1744 |
TBuf< KMaxDataTypeLength > mimeTypeText(MPXDbCommonUtil::GetMimeTypeForUriL(uri).Des()); |
|
1745 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMimeType, mimeTypeText); |
|
1746 |
MPX_DEBUG2(" MimeType[%S]", &mimeTypeText); |
|
1747 |
} |
|
1748 |
||
1749 |
if (!aMusicTable && !aMedia.IsSupported(KMPXMediaGeneralTitle)) |
|
1750 |
{ |
|
1751 |
TParsePtrC parser(uri); |
|
1752 |
TPtrC title = parser.Name(); |
|
1753 |
// use file name as song name |
|
1754 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicName, title); |
|
1755 |
||
1756 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1757 |
MPX_DEBUG2(" Title[%S]", &title); |
|
1758 |
} |
|
1759 |
||
1760 |
// URI of the song has been changed. This changes the Id of the song |
|
1761 |
if (aMusicTable) |
|
1762 |
{ |
|
1763 |
TUint32 newSongId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, uri, EFalse); |
|
1764 |
if (aSongId != newSongId) |
|
1765 |
{ |
|
1766 |
MPX_DEBUG3(" CurrentSongId[0x%x] changed to [0x%x]", aSongId, newSongId); |
|
1767 |
if (songChangedMessage) |
|
1768 |
{ |
|
1769 |
songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, newSongId); |
|
1770 |
songChangedMessage->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, aSongId); |
|
1771 |
} |
|
1772 |
||
1773 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUniqueId, newSongId); |
|
1774 |
} |
|
1775 |
} |
|
1776 |
} |
|
1777 |
} |
|
1778 |
||
1779 |
if (attributeId & EMPXMediaGeneralPlayCount) |
|
1780 |
{ |
|
1781 |
TInt increment(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralPlayCount)); |
|
1782 |
TUint32 curCount(increment); |
|
1783 |
if (aMusicTable) |
|
1784 |
{ |
|
1785 |
curCount += aMusicTable->ColumnInt(EMusicPlayCount); |
|
1786 |
} |
|
1787 |
||
1788 |
if (!aMusicTable || (curCount != aMusicTable->ColumnInt(EMusicPlayCount))) |
|
1789 |
{ |
|
1790 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicPlayCount, curCount); |
|
1791 |
||
1792 |
// this needs to be visible in order for Recently Played and Most Played |
|
1793 |
// playlists will be updated |
|
1794 |
visibleChange = CMPXDbActiveTask::ESingleVisible; |
|
1795 |
||
1796 |
if (aItemChangedMessages) |
|
1797 |
{ |
|
1798 |
iObserver.HandlePlayCountModifiedL(*aItemChangedMessages); |
|
1799 |
} |
|
1800 |
addSongChangedMessage = EFalse; |
|
1801 |
} |
|
1802 |
||
1803 |
MPX_DEBUG2(" PlayCount[%d]", curCount); |
|
1804 |
} |
|
1805 |
||
1806 |
if (attributeId & EMPXMediaGeneralLastPlaybackTime) |
|
1807 |
{ |
|
1808 |
HBufC* time = MPXDbCommonUtil::TTimeToDesLC( |
|
1809 |
TTime(aMedia.ValueTObjectL<TInt64>(KMPXMediaGeneralLastPlaybackTime))); |
|
1810 |
if (!aMusicTable || (*time != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicTimePlayed))) |
|
1811 |
{ |
|
1812 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTimePlayed, *time); |
|
1813 |
// this needs to be visible in order for Recently Played playlist to be updated |
|
1814 |
visibleChange = CMPXDbActiveTask::ESingleVisible; |
|
1815 |
||
1816 |
if (aItemChangedMessages) |
|
1817 |
{ |
|
1818 |
iObserver.HandlePlaybackTimeModifiedL(*aItemChangedMessages); |
|
1819 |
} |
|
1820 |
addSongChangedMessage = EFalse; |
|
1821 |
} |
|
1822 |
MPX_DEBUG2(" PlaybackTime[%S]", time); |
|
1823 |
CleanupStack::PopAndDestroy(time); |
|
1824 |
} |
|
1825 |
||
1826 |
if (attributeId & EMPXMediaGeneralDuration) |
|
1827 |
{ |
|
1828 |
TInt duration(aMedia.ValueTObjectL<TInt>(KMPXMediaGeneralDuration)); |
|
1829 |
if (!aMusicTable || (duration != aMusicTable->ColumnInt(EMusicDuration))) |
|
1830 |
{ |
|
1831 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDuration, duration); |
|
1832 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1833 |
metaDataModified = ETrue; |
|
1834 |
} |
|
1835 |
MPX_DEBUG2(" Duration[%d]", duration); |
|
1836 |
} |
|
1837 |
||
1838 |
if (attributeId & EMPXMediaGeneralSynchronized) |
|
1839 |
{ |
|
1840 |
TBool synced(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized)); |
|
1841 |
if (!aMusicTable || (synced != aMusicTable->ColumnInt(EMusicSync))) |
|
1842 |
{ |
|
1843 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSync, synced); |
|
1844 |
} |
|
1845 |
MPX_DEBUG2(" Synchronized[%d]", synced); |
|
1846 |
} |
|
1847 |
||
1848 |
if (attributeId & EMPXMediaGeneralModified) |
|
1849 |
{ |
|
1850 |
TBool modified(aMedia.ValueTObjectL<TBool>(KMPXMediaGeneralModified)); |
|
1851 |
if (!aMusicTable || (modified != aMusicTable->ColumnInt(EMusicModified))) |
|
1852 |
{ |
|
1853 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, modified); |
|
1854 |
} |
|
1855 |
MPX_DEBUG2(" Modified[%d]", modified); |
|
1856 |
} |
|
1857 |
||
1858 |
if (attributeId & EMPXMediaGeneralComment) |
|
1859 |
{ |
|
1860 |
TPtrC comment = aMedia.ValueText(KMPXMediaGeneralComment).Left(KMCMaxTextLen); |
|
1861 |
if (!aMusicTable || (comment != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicComment))) |
|
1862 |
{ |
|
1863 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComment, comment); |
|
1864 |
metaDataModified = ETrue; |
|
1865 |
} |
|
1866 |
MPX_DEBUG2(" Comment[%S]", &comment); |
|
1867 |
} |
|
1868 |
||
1869 |
if (attributeId & EMPXMediaGeneralCopyright) |
|
1870 |
{ |
|
1871 |
const TDesC& copyright = aMedia.ValueText(KMPXMediaGeneralCopyright). |
|
1872 |
Left(KMCMaxTextLen); |
|
1873 |
if (!aMusicTable || (copyright != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicCopyright))) |
|
1874 |
{ |
|
1875 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicCopyright, copyright); |
|
1876 |
metaDataModified = ETrue; |
|
1877 |
} |
|
1878 |
MPX_DEBUG2(" Copyright[%S]", ©right); |
|
1879 |
} |
|
1880 |
} |
|
1881 |
break; |
|
1882 |
||
1883 |
case KMPXMediaIdMusic: |
|
1884 |
{ |
|
1885 |
if (attributeId & EMPXMediaMusicAlbumTrack) |
|
1886 |
{ |
|
1887 |
const TDesC& trackNumber = aMedia.ValueText(KMPXMediaMusicAlbumTrack); |
|
1888 |
||
1889 |
// KMaxTInt is used to represent null album track |
|
1890 |
TInt track(KMaxTInt); |
|
1891 |
if (trackNumber.Length()) |
|
1892 |
{ |
|
1893 |
TLex stringParser(trackNumber); |
|
1894 |
||
1895 |
if ((stringParser.Val(track) != KErrNone) || |
|
1896 |
(track == 0) || (track > 999)) // Limit track number to 3 characters |
|
1897 |
{ |
|
1898 |
track = KMaxTInt; |
|
1899 |
} |
|
1900 |
} |
|
1901 |
||
1902 |
if (!aMusicTable || (track != aMusicTable->ColumnInt(EMusicAlbumTrack))) |
|
1903 |
{ |
|
1904 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicTrackNumber, track); |
|
1905 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1906 |
metaDataModified = ETrue; |
|
1907 |
} |
|
1908 |
MPX_DEBUG3(" Album Track[%S][%d]", &trackNumber, track); |
|
1909 |
} |
|
1910 |
||
1911 |
if (attributeId & EMPXMediaMusicYear) |
|
1912 |
{ |
|
1913 |
TInt64 int64(aMedia.ValueTObjectL<TInt64>(KMPXMediaMusicYear)); |
|
1914 |
||
1915 |
TTime maxTime(0); |
|
1916 |
maxTime += TTimeIntervalYears(9999); // Limit years to 4 characters |
|
1917 |
TTime time(int64); |
|
1918 |
||
1919 |
if (time > maxTime) |
|
1920 |
{ |
|
1921 |
time = Time::NullTTime(); |
|
1922 |
} |
|
1923 |
||
1924 |
HBufC* timeStr = MPXDbCommonUtil::TTimeToDesLC(time); |
|
1925 |
if (!aMusicTable || (*timeStr != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicReleaseDate))) |
|
1926 |
{ |
|
1927 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicReleaseDate, *timeStr); |
|
1928 |
metaDataModified = ETrue; |
|
1929 |
} |
|
1930 |
MPX_DEBUG2(" Music Year[%S]", timeStr); |
|
1931 |
CleanupStack::PopAndDestroy(timeStr); |
|
1932 |
} |
|
1933 |
||
1934 |
if (attributeId & EMPXMediaMusicRating) |
|
1935 |
{ |
|
1936 |
TInt rating(aMedia.ValueTObjectL<TInt>(KMPXMediaMusicRating)); |
|
1937 |
if (!aMusicTable || (rating != aMusicTable->ColumnInt(EMusicRating))) |
|
1938 |
{ |
|
1939 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicRating, rating); |
|
1940 |
metaDataModified = ETrue; |
|
1941 |
} |
|
1942 |
MPX_DEBUG2(" Rating[%d]", rating); |
|
1943 |
} |
|
1944 |
||
1945 |
if (attributeId & EMPXMediaMusicAlbumArtFileName) |
|
1946 |
{ |
|
1947 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1948 |
TInt containEmbeddedArt(0); |
|
1949 |
if (aMusicTable ) |
|
1950 |
{ |
|
1951 |
containEmbeddedArt = aMusicTable->ColumnInt(EMusicContainEmbeddedArt); |
|
1952 |
} |
|
1953 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1954 |
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
|
1955 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1956 |
TParsePtrC parse(albumArtFilename); |
|
1957 |
TPtrC ext(parse.Ext()); |
|
1958 |
//set flag to false, so .alb will not overwrite art field in album, artist table |
|
1959 |
// when song with embedded art |
|
1960 |
if ((ext.CompareF(KAbstractAlbumExt)== 0) && containEmbeddedArt) |
|
1961 |
{ |
|
1962 |
iArtNeedUpdated = EFalse; |
|
1963 |
} |
|
1964 |
||
1965 |
if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0)) |
|
1966 |
{ |
|
1967 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1968 |
if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt))) |
|
1969 |
{ |
|
1970 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename); |
|
1971 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
1972 |
metaDataModified = ETrue; |
|
1973 |
} |
|
1974 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1975 |
} |
|
1976 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1977 |
MPX_DEBUG2(" Album Art Filename[%S]", &albumArtFilename); |
|
1978 |
} |
|
1979 |
||
1980 |
if (attributeId & EMPXMediaMusicURL) |
|
1981 |
{ |
|
1982 |
const TDesC& url = aMedia.ValueText(KMPXMediaMusicURL).Left(KMCMaxTextLen); |
|
1983 |
if (!aMusicTable || (url != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicUrl))) |
|
1984 |
{ |
|
1985 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicUrl, url); |
|
1986 |
metaDataModified = ETrue; |
|
1987 |
} |
|
1988 |
||
1989 |
MPX_DEBUG2(" Music URL[%S]", &url); |
|
1990 |
} |
|
1991 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1992 |
if (attributeId & EMPXMediaMusicAlbumArtist) |
|
1993 |
{ |
|
1994 |
const TDesC& albumartist = aMedia.ValueText(KMPXMediaMusicAlbumArtist); |
|
1995 |
TPtrC truncatedAlbumartist(albumartist.Left(KMCMaxTextLen)); |
|
1996 |
||
1997 |
if (!aMusicTable || (truncatedAlbumartist.Compare(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicAlbumArtist)) != 0)) |
|
1998 |
{ |
|
1999 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbumArtist, truncatedAlbumartist); |
|
2000 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2001 |
metaDataModified = ETrue; |
|
2002 |
} |
|
2003 |
} |
|
2004 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2005 |
} |
|
2006 |
break; |
|
2007 |
||
2008 |
case KMPXMediaIdAudio: |
|
2009 |
{ |
|
2010 |
if (attributeId & EMPXMediaAudioSamplerate) |
|
2011 |
{ |
|
2012 |
TInt samplerate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioSamplerate)); |
|
2013 |
if (!aMusicTable || (samplerate != aMusicTable->ColumnInt(EMusicSampleRate))) |
|
2014 |
{ |
|
2015 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicSampleRate, samplerate); |
|
2016 |
metaDataModified = ETrue; |
|
2017 |
} |
|
2018 |
||
2019 |
MPX_DEBUG2(" Sample Rate[%d]", samplerate); |
|
2020 |
} |
|
2021 |
||
2022 |
if (attributeId & EMPXMediaAudioBitrate) |
|
2023 |
{ |
|
2024 |
TInt bitrate(aMedia.ValueTObjectL<TInt>(KMPXMediaAudioBitrate)); |
|
2025 |
if (!aMusicTable || (bitrate != aMusicTable->ColumnInt(EMusicBitRate))) |
|
2026 |
{ |
|
2027 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicBitRate, bitrate); |
|
2028 |
metaDataModified = ETrue; |
|
2029 |
} |
|
2030 |
MPX_DEBUG2(" Bitrate[%d]", bitrate); |
|
2031 |
} |
|
2032 |
||
2033 |
if (attributeId & EMPXMediaAudioNumberOfChannels) |
|
2034 |
{ |
|
2035 |
TUint32 val = aMedia.ValueTObjectL<TUint32>(KMPXMediaAudioNumberOfChannels); |
|
2036 |
if (!aMusicTable || (val != aMusicTable->ColumnInt(EMusicNumChannels))) |
|
2037 |
{ |
|
2038 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicNumChannels, val); |
|
2039 |
} |
|
2040 |
MPX_DEBUG2(" Num of Channels[%d]", val); |
|
2041 |
} |
|
2042 |
} |
|
2043 |
break; |
|
2044 |
||
2045 |
case KMPXMediaIdDrm: |
|
2046 |
{ |
|
2047 |
if (attributeId & EMPXMediaDrmType) |
|
2048 |
{ |
|
2049 |
TInt drmType(aMedia.ValueTObjectL<TInt>(KMPXMediaDrmType)); |
|
2050 |
if (!aMusicTable || (drmType != aMusicTable->ColumnInt(EMusicDRM))) |
|
2051 |
{ |
|
2052 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, drmType); |
|
2053 |
} |
|
2054 |
MPX_DEBUG2(" DRM type[%d]", drmType); |
|
2055 |
} |
|
2056 |
||
2057 |
if (attributeId & KMPXMediaDrmRightsStatus.iAttributeId) |
|
2058 |
{ |
|
2059 |
if (aMusicTable) |
|
2060 |
{ |
|
2061 |
TMPXMediaDrmRightsStatus status = |
|
2062 |
aMedia.ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus); |
|
2063 |
||
2064 |
//.Set the db flag |
|
2065 |
TUint32 curFlag(aMusicTable->ColumnInt64(EMusicDbFlag)); |
|
2066 |
TUint32 oldFlag(curFlag); |
|
2067 |
||
2068 |
if ((status != EMPXDrmRightsFull) && (status != EMPXDrmRightsRestricted)) |
|
2069 |
{ |
|
2070 |
// No rights |
|
2071 |
curFlag |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid; |
|
2072 |
} |
|
2073 |
else |
|
2074 |
{ |
|
2075 |
// Rights valid |
|
2076 |
curFlag &= (KMPXMediaGeneralFlagsIsDrmLicenceInvalid ^ 0xFFFFFFFF); |
|
2077 |
} |
|
2078 |
||
2079 |
// The field is written ONLY if the flag value is changing |
|
2080 |
if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0) |
|
2081 |
{ |
|
2082 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag); |
|
2083 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2084 |
} |
|
2085 |
||
2086 |
MPX_DEBUG2(" Rights Status[%d]", curFlag); |
|
2087 |
} |
|
2088 |
} |
|
2089 |
||
2090 |
break; |
|
2091 |
} |
|
2092 |
||
2093 |
case KMPXMediaIdMTP: |
|
2094 |
{ |
|
2095 |
if (attributeId & KMPXMediaMTPDrmStatus.iAttributeId) |
|
2096 |
{ |
|
2097 |
TUint16 drmStatus(aMedia.ValueTObjectL<TUint16>(KMPXMediaMTPDrmStatus)); |
|
2098 |
if (!aMusicTable || (drmStatus != aMusicTable->ColumnInt(EMusicMTPDrmStatus))) |
|
2099 |
{ |
|
2100 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMTPDrmStatus, drmStatus); |
|
2101 |
} |
|
2102 |
MPX_DEBUG2(" MTP Drm Status[%d]", drmStatus); |
|
2103 |
} |
|
2104 |
} |
|
2105 |
break; |
|
2106 |
||
2107 |
default: |
|
2108 |
break; |
|
2109 |
} // end switch |
|
2110 |
} // end for |
|
2111 |
||
2112 |
// get the current artist/album/genre/composer/abstractalbum |
|
2113 |
// this is required because the recordset may be reused by the code below |
|
2114 |
TUint32 artistId(0); |
|
2115 |
TUint32 albumId(0); |
|
2116 |
TUint32 genreId(0); |
|
2117 |
TUint32 composerId(0); |
|
2118 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2119 |
TUint32 abstractAlbumId(0); |
|
2120 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2121 |
if (aMusicTable) |
|
2122 |
{ |
|
2123 |
artistId = aMusicTable->ColumnInt64(EMusicArtist); |
|
2124 |
albumId = aMusicTable->ColumnInt64(EMusicAlbum); |
|
2125 |
genreId = aMusicTable->ColumnInt64(EMusicGenre); |
|
2126 |
composerId = aMusicTable->ColumnInt64(EMusicComposer); |
|
2127 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2128 |
abstractAlbumId = aMusicTable->ColumnInt64(EMusicAbstractAlbum); |
|
2129 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2130 |
} |
|
2131 |
||
2132 |
// update the artist field |
|
2133 |
TUint32 id(0); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2134 |
TUint32 artistIdForAlbum(artistId); |
53 | 2135 |
if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId, |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2136 |
aDrive, aItemChangedMessages, id)) |
53 | 2137 |
{ |
2138 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id); |
|
2139 |
metaDataModified = (aMusicTable != NULL); |
|
2140 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2141 |
artistIdForAlbum = id; |
53 | 2142 |
} |
2143 |
||
2144 |
// update the album field |
|
2145 |
if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2146 |
aDrive, aItemChangedMessages, id)) |
53 | 2147 |
{ |
2148 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id); |
|
2149 |
metaDataModified = (aMusicTable != NULL); |
|
2150 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2151 |
||
2152 |
// |
|
2153 |
// added to handle error EALU-73WDJN. If the album name of the last song |
|
2154 |
// in the album for the artist is changed to an existing album name from |
|
2155 |
// artist view, a change message needs to be sent in order for UI to |
|
2156 |
// correctly refresh. |
|
2157 |
// |
|
2158 |
// Fix for EDXU-7BBALS, remove check for HasOtherSongsInArtistAlbumL |
|
2159 |
// Always send a Album Inserted message when Album change to get Artist updated |
|
2160 |
if (aItemChangedMessages) |
|
2161 |
{ |
|
2162 |
// send album added m essage instead of album deleted or modified |
|
2163 |
// to avoid collection paths of other clients being modified |
|
2164 |
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId, |
|
2165 |
EMPXItemInserted, EMPXAlbum, KDBPluginUid); |
|
2166 |
} |
|
2167 |
} |
|
2168 |
||
2169 |
// update the genre field |
|
2170 |
if (UpdateCategoryFieldL(EMPXGenre, aMedia, KMPXMediaMusicGenre, genreId, |
|
2171 |
aDrive, aItemChangedMessages, id)) |
|
2172 |
{ |
|
2173 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicGenre, id); |
|
2174 |
metaDataModified = (aMusicTable != NULL); |
|
2175 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2176 |
} |
|
2177 |
||
2178 |
// update the composer field |
|
2179 |
if (UpdateCategoryFieldL(EMPXComposer, aMedia, KMPXMediaMusicComposer, composerId, |
|
2180 |
aDrive, aItemChangedMessages, id)) |
|
2181 |
{ |
|
2182 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicComposer, id); |
|
2183 |
metaDataModified = (aMusicTable != NULL); |
|
2184 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2185 |
} |
|
2186 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2187 |
if ( aMedia.IsSupported (KMPXMediaMusicAlbumArtFileName)) |
|
2188 |
{ |
|
2189 |
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
|
2190 |
TParsePtrC parse( albumArtFilename ); |
|
2191 |
TPtrC ext( parse.Ext() ); |
|
2192 |
if (ext.CompareF(KAbstractAlbumExt)== 0) |
|
2193 |
{ |
|
2194 |
if (UpdateCategoryFieldL(EMPXAbstractAlbum, aMedia, KMPXMediaMusicAlbumArtFileName, abstractAlbumId, |
|
2195 |
aDrive, aItemChangedMessages, id)) |
|
2196 |
{ |
|
2197 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAbstractAlbum, id); |
|
2198 |
metaDataModified = (aMusicTable != NULL); |
|
2199 |
visibleChange = CMPXDbActiveTask::EAllVisible; |
|
2200 |
} |
|
2201 |
} |
|
2202 |
} |
|
2203 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2204 |
#if defined (__MTP_PROTOCOL_SUPPORT) |
|
2205 |
// Set Mod bit to ETrue if metadata has been updated and caller hasn't explicitly |
|
2206 |
// set/reset it |
|
2207 |
if (aMusicTable && |
|
2208 |
!aMedia.IsSupported(KMPXMediaGeneralModified) && |
|
2209 |
metaDataModified) |
|
2210 |
{ |
|
2211 |
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicMod, 1); |
|
2212 |
MPX_DEBUG1(" Modified[1]"); |
|
2213 |
} |
|
2214 |
#endif |
|
2215 |
||
2216 |
if (aItemChangedMessages) |
|
2217 |
{ |
|
2218 |
if (aFields.Count() && addSongChangedMessage) |
|
2219 |
{ |
|
2220 |
aItemChangedMessages->AppendL(*songChangedMessage); |
|
2221 |
} |
|
2222 |
CleanupStack::PopAndDestroy(songChangedMessage); |
|
2223 |
} |
|
2224 |
||
2225 |
return visibleChange; |
|
2226 |
} |
|
2227 |
||
2228 |
// ---------------------------------------------------------------------------- |
|
2229 |
// CMPXDbMusic::DRMTypeL |
|
2230 |
// ---------------------------------------------------------------------------- |
|
2231 |
// |
|
2232 |
TMCDrmType CMPXDbMusic::DRMTypeL( |
|
2233 |
const TDesC& aFile) |
|
2234 |
{ |
|
2235 |
MPX_FUNC("CMPXDbMusic::DRMTypeL"); |
|
2236 |
||
2237 |
TMCDrmType drm(EMCDrmNone); |
|
2238 |
TInt pos(0); |
|
2239 |
TParsePtrC fullEntry(aFile); |
|
2240 |
TPtrC theExt = fullEntry.Ext(); |
|
2241 |
||
2242 |
if (iExtensionsDrm->Find(theExt, pos) == 0) |
|
2243 |
{ |
|
2244 |
drm = MPXDbCommonUtil::GetDRMTypeL(aFile); |
|
2245 |
} |
|
2246 |
||
2247 |
return drm; |
|
2248 |
} |
|
2249 |
||
2250 |
// ---------------------------------------------------------------------------- |
|
2251 |
// CMPXDbMusic::GenerateMusicMatchingCriteriaLC |
|
2252 |
// ---------------------------------------------------------------------------- |
|
2253 |
// |
|
2254 |
HBufC* CMPXDbMusic::GenerateMusicMatchingCriteriaLC( |
|
2255 |
TUint32 aGeneralId, |
|
2256 |
TUint32 aContainerId, |
|
2257 |
TMPXGeneralType aType, |
|
2258 |
const CMPXMedia& aCriteria) |
|
2259 |
{ |
|
2260 |
MPX_FUNC("CMPXDbMusic::GenerateMusicMatchingCriteriaLC"); |
|
2261 |
||
2262 |
const TArray<TMPXAttribute> criteria = aCriteria.Attributes(); |
|
2263 |
TInt criteriaCount(criteria.Count()); |
|
2264 |
||
2265 |
// construct an array of criteria strings |
|
2266 |
CDesCArrayFlat* sqlCriteria = new (ELeave) CDesCArrayFlat(criteriaCount); |
|
2267 |
CleanupStack::PushL(sqlCriteria); |
|
2268 |
||
2269 |
// If EMPXMediaGeneralDeleted is not defined, always unset the deleted bit for matching |
|
2270 |
if (!aCriteria.IsSupported(KMPXMediaGeneralDeleted)) |
|
2271 |
{ |
|
2272 |
sqlCriteria->AppendL(KCriterionMusicNotDeleted); |
|
2273 |
} |
|
2274 |
||
2275 |
TBool volumeAdded(EFalse); |
|
2276 |
for (TInt i = 0; i < criteriaCount; ++i) |
|
2277 |
{ |
|
2278 |
const TMPXAttribute& criterion = criteria[i]; |
|
2279 |
||
2280 |
if (criterion == KMPXMediaGeneralId) |
|
2281 |
{ |
|
2282 |
// Set the type if no type is specified |
|
2283 |
TInt category(MPX_ITEM_CATEGORY(aGeneralId)); |
|
2284 |
||
2285 |
if( aType == EMPXNoType ) |
|
2286 |
{ |
|
2287 |
aType = (category == EMPXCollection) ? EMPXItem : EMPXGroup; |
|
2288 |
} |
|
2289 |
||
2290 |
TPtrC ptr; |
|
2291 |
if (aType == EMPXItem && (category == EMPXCollection)) |
|
2292 |
{ |
|
2293 |
ptr.Set(KCriterionMusicUniqueId); |
|
2294 |
} |
|
2295 |
else if (aType == EMPXGroup && (category == EMPXArtist)) |
|
2296 |
{ |
|
2297 |
ptr.Set(KCriterionMusicArtist); |
|
2298 |
} |
|
2299 |
else if (aType == EMPXGroup && (category == EMPXAlbum)) |
|
2300 |
{ |
|
2301 |
ptr.Set(KCriterionMusicAlbum); |
|
2302 |
} |
|
2303 |
else if (aType == EMPXGroup && (category == EMPXGenre)) |
|
2304 |
{ |
|
2305 |
ptr.Set(KCriterionMusicGenre); |
|
2306 |
} |
|
2307 |
else if (aType == EMPXGroup && (category == EMPXComposer)) |
|
2308 |
{ |
|
2309 |
ptr.Set(KCriterionMusicComposer); |
|
2310 |
} |
|
2311 |
else |
|
2312 |
{ |
|
2313 |
User::Leave(KErrNotSupported); |
|
2314 |
} |
|
2315 |
||
2316 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, ptr, aGeneralId); |
|
2317 |
} |
|
2318 |
else if (criterion == KMPXMediaGeneralContainerId) |
|
2319 |
{ |
|
2320 |
TInt containerCategory(MPX_ITEM_CATEGORY(aContainerId)); |
|
2321 |
||
2322 |
if (aType == EMPXGroup && (containerCategory == EMPXArtist)) |
|
2323 |
{ |
|
2324 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, |
|
2325 |
KCriterionMusicArtist, aContainerId); |
|
2326 |
} |
|
2327 |
else if (aType == EMPXGroup && (containerCategory == EMPXAlbum)) |
|
2328 |
{ |
|
2329 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, |
|
2330 |
KCriterionMusicAlbum, aContainerId); |
|
2331 |
} |
|
2332 |
else |
|
2333 |
{ |
|
2334 |
//User::Leave(KErrNotSupported); |
|
2335 |
} |
|
2336 |
} |
|
2337 |
else if (criterion == KMPXMediaGeneralTitle) |
|
2338 |
{ |
|
2339 |
HBufC* title = MPXDbCommonUtil::ProcessPatternCharsLC( |
|
2340 |
aCriteria.ValueText(KMPXMediaGeneralTitle)); |
|
2341 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicTitle, *title); |
|
2342 |
CleanupStack::PopAndDestroy(title); |
|
2343 |
} |
|
2344 |
else if (criterion == KMPXMediaGeneralUri) |
|
2345 |
{ |
|
2346 |
// full URI from criteria |
|
2347 |
const TDesC& uri = aCriteria.ValueText(KMPXMediaGeneralUri); |
|
2348 |
TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, |
|
2349 |
uri, EFalse); |
|
2350 |
||
2351 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicUniqueId, itemId); |
|
2352 |
} |
|
2353 |
else if (criterion == KMPXMediaGeneralDrive) |
|
2354 |
{ |
|
2355 |
if (!volumeAdded) |
|
2356 |
{ |
|
2357 |
// validate the drive letter, TDriveUnit panics if given drive isn't between |
|
2358 |
// 'A' to 'Z' |
|
2359 |
const TDesC& drive = aCriteria.ValueText(KMPXMediaGeneralDrive); |
|
2360 |
TInt driveInt = 0; |
|
2361 |
if( drive == KNullDesC || RFs::CharToDrive( drive[0], driveInt )!= KErrNone ) |
|
2362 |
{ |
|
2363 |
User::Leave(KErrArgument); |
|
2364 |
} |
|
2365 |
TDriveUnit driveUnit(drive); |
|
2366 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume, |
|
2367 |
MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
|
2368 |
volumeAdded = ETrue; |
|
2369 |
} |
|
2370 |
} |
|
2371 |
else if (criterion == KMPXMediaGeneralSynchronized) |
|
2372 |
{ |
|
2373 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicSync, |
|
2374 |
aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralSynchronized)); |
|
2375 |
} |
|
2376 |
else if (criterion == KMPXMediaGeneralDeleted) |
|
2377 |
{ |
|
2378 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicDeleted, |
|
2379 |
aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralDeleted)); |
|
2380 |
} |
|
2381 |
else if (criterion == KMPXMediaGeneralModified) |
|
2382 |
{ |
|
2383 |
MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicModified, |
|
2384 |
aCriteria.ValueTObjectL<TBool>(KMPXMediaGeneralModified)); |
|
2385 |
} |
|
2386 |
else |
|
2387 |
{ |
|
2388 |
// to-do: provide searching ability on the rest of the fields |
|
2389 |
} |
|
2390 |
} |
|
2391 |
||
2392 |
// construct the final criteria string |
|
2393 |
HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*sqlCriteria, KMCAndKeyword); |
|
2394 |
||
2395 |
CleanupStack::Pop(criteriaStr); |
|
2396 |
CleanupStack::PopAndDestroy(sqlCriteria); |
|
2397 |
CleanupStack::PushL(criteriaStr); |
|
2398 |
||
2399 |
return criteriaStr; |
|
2400 |
} |
|
2401 |
||
2402 |
// ---------------------------------------------------------------------------- |
|
2403 |
// CMPXDbMusic::ConstructUriL |
|
2404 |
// ---------------------------------------------------------------------------- |
|
2405 |
// |
|
2406 |
HBufC* CMPXDbMusic::ConstructUriL( |
|
2407 |
RSqlStatement& aMusicTable) |
|
2408 |
{ |
|
2409 |
MPX_FUNC("CMPXDbMusic::ConstructUriL"); |
|
2410 |
||
2411 |
TUint volId(aMusicTable.ColumnInt64(EMusicVolumeId)); |
|
2412 |
TPtrC location(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicLocation)); |
|
2413 |
return MPXDbCommonUtil::CreateFullPathL( |
|
2414 |
MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), volId), location); |
|
2415 |
} |
|
2416 |
||
2417 |
// ---------------------------------------------------------------------------- |
|
2418 |
// CMPXDbMusic::CreateTableL |
|
2419 |
// ---------------------------------------------------------------------------- |
|
2420 |
// |
|
2421 |
void CMPXDbMusic::CreateTableL( |
|
2422 |
RSqlDatabase& aDatabase, |
|
2423 |
TBool /* aCorruptTable */) |
|
2424 |
{ |
|
2425 |
MPX_FUNC("CMPXDbMusic::CreateTableL"); |
|
2426 |
||
2427 |
// Create the table |
|
2428 |
User::LeaveIfError(aDatabase.Exec(KMusicCreateTable)); |
|
2429 |
||
2430 |
// Do not create any other indexes than the one on UniqueId |
|
2431 |
// as they only slow down the database overall |
|
2432 |
User::LeaveIfError(aDatabase.Exec(KMusicDeletedTitleIndex)); |
|
2433 |
} |
|
2434 |
||
2435 |
// ---------------------------------------------------------------------------- |
|
2436 |
// CMPXDbMusic::DropTableL |
|
2437 |
// ---------------------------------------------------------------------------- |
|
2438 |
// |
|
2439 |
void CMPXDbMusic::DropTableL( |
|
2440 |
RSqlDatabase& aDatabase) |
|
2441 |
{ |
|
2442 |
MPX_FUNC("CMPXDbMusic::DropTableL"); |
|
2443 |
User::LeaveIfError(aDatabase.Exec(KMusicDropTable)); |
|
2444 |
} |
|
2445 |
||
2446 |
// ---------------------------------------------------------------------------- |
|
2447 |
// CMPXDbMusic::CheckTableL |
|
2448 |
// ---------------------------------------------------------------------------- |
|
2449 |
// |
|
2450 |
TBool CMPXDbMusic::CheckTableL( |
|
2451 |
RSqlDatabase& aDatabase) |
|
2452 |
{ |
|
2453 |
MPX_FUNC("CMPXDbMusic::CheckTableL"); |
|
2454 |
return DoCheckTable(aDatabase, KMusicCheckTable); |
|
2455 |
} |
|
2456 |
||
2457 |
// ---------------------------------------------------------------------------- |
|
2458 |
// CMPXDbMusic::UpdateCategoryFieldL |
|
2459 |
// ---------------------------------------------------------------------------- |
|
2460 |
// |
|
2461 |
TBool CMPXDbMusic::UpdateCategoryFieldL( |
|
2462 |
TMPXGeneralCategory aCategory, |
|
2463 |
const CMPXMedia& aMedia, |
|
2464 |
const TMPXAttribute& aAttribute, |
|
2465 |
TUint32 aOldId, |
|
2466 |
TInt aDriveId, |
|
2467 |
CMPXMessageArray* aItemChangedMessages, |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2468 |
TUint32& aItemId) |
53 | 2469 |
{ |
2470 |
TBool updated(EFalse); |
|
2471 |
TBool itemNotRemoved( EFalse ); |
|
2472 |
TBool itemAdded( EFalse ); |
|
2473 |
||
2474 |
// update category table and add category Id to the music table |
|
2475 |
if (!aOldId || aMedia.IsSupported(aAttribute)) |
|
2476 |
{ |
|
2477 |
TInt changeMsgCount( 0 ); |
|
2478 |
if( aItemChangedMessages ) |
|
2479 |
{ |
|
2480 |
changeMsgCount = aItemChangedMessages->Count(); |
|
2481 |
} |
|
2482 |
||
2483 |
if (aMedia.IsSupported(aAttribute)) |
|
2484 |
{ |
|
2485 |
TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen)); |
|
2486 |
||
2487 |
// construct the new ID for the category record |
|
2488 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2489 |
// genre and abstractalbum are not case sensitive |
|
2490 |
TBool caseSensitive = ETrue; |
|
2491 |
if ((aCategory == EMPXGenre) || (aCategory == EMPXAbstractAlbum)) |
|
2492 |
caseSensitive = EFalse; |
|
2493 |
||
2494 |
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
|
2495 |
name, caseSensitive); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2496 |
|
53 | 2497 |
#else |
2498 |
// only genre is not case sensitive |
|
2499 |
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
|
2500 |
name, (aCategory != EMPXGenre)); |
|
2501 |
#endif |
|
2502 |
if (!aOldId || (aOldId != aItemId)) |
|
2503 |
{ |
|
2504 |
// only add if the ID changed, |
|
2505 |
// otherwise the song was updated but the artist name was not |
|
2506 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2507 |
if(aCategory == EMPXAbstractAlbum) |
|
2508 |
{ |
|
2509 |
if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong ) |
|
2510 |
{ |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2511 |
iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2512 |
aItemChangedMessages, itemAdded, name, KNullDesC); |
53 | 2513 |
} |
2514 |
else |
|
2515 |
{ |
|
2516 |
TPtrC albumartist(KNullDesC); |
|
2517 |
TPtrC abstractAlbumName(KNullDesC); |
|
2518 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist) ) |
|
2519 |
{ |
|
2520 |
albumartist.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
|
2521 |
//get AlbumArt AbstractAlbum |
|
2522 |
MPX_DEBUG2(" albumartist[%S]", &albumartist); |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2523 |
} |
53 | 2524 |
if (aMedia.IsSupported(KMPXMediaGeneralTitle) ) |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2525 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2526 |
abstractAlbumName.Set(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2527 |
MPX_DEBUG2(" abstractAlbumName[%S]", &abstractAlbumName); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2528 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2529 |
// ignore the return value |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2530 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2531 |
iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2532 |
aItemChangedMessages, itemAdded, name, albumartist); |
53 | 2533 |
} |
2534 |
} |
|
2535 |
else |
|
2536 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2537 |
if (aCategory == EMPXArtist || aCategory == EMPXAlbum) |
53 | 2538 |
{ |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2539 |
TPtrC art(KNullDesC); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2540 |
TPtrC artistname(KNullDesC); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2541 |
|
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2542 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
53 | 2543 |
{ |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2544 |
art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
53 | 2545 |
} |
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2546 |
if (aCategory == EMPXAlbum) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2547 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2548 |
if (aMedia.IsSupported(KMPXMediaMusicArtist)) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2549 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2550 |
artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2551 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2552 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2553 |
iObserver.AddCategoryItemL(aCategory, name, artistname, art, aDriveId, aItemChangedMessages, itemAdded); |
53 | 2554 |
} |
2555 |
else |
|
2556 |
{ |
|
2557 |
// ignore the return value |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2558 |
iObserver.AddCategoryItemL(aCategory, name, aDriveId, |
53 | 2559 |
aItemChangedMessages, itemAdded); |
2560 |
} |
|
2561 |
updated = ETrue; |
|
2562 |
} |
|
2563 |
} |
|
2564 |
else |
|
2565 |
{ |
|
2566 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2567 |
// genre and abstractalbum are not case sensitive |
|
2568 |
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2569 |
(aCategory != EMPXGenre)&&(aCategory != EMPXAbstractAlbum)); |
|
2570 |
#else |
|
2571 |
// only genre is not case sensitive |
|
2572 |
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2573 |
(aCategory != EMPXGenre)); |
|
2574 |
#endif |
|
2575 |
if (!aOldId || (aOldId != aItemId)) |
|
2576 |
{ |
|
2577 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2578 |
if(aCategory == EMPXAbstractAlbum) |
|
2579 |
{ |
|
2580 |
//get AlbumArt for AbstractAlbum |
|
2581 |
TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
|
2582 |
MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
|
2583 |
TPtrC abstractAlbumName(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
|
2584 |
MPX_DEBUG2(" Music abstractAlbumName[%S]", &abstractAlbumName); |
|
2585 |
// ignore the return value |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2586 |
iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2587 |
aItemChangedMessages, itemAdded, KNullDesC, albumartist); |
53 | 2588 |
} |
2589 |
else |
|
2590 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2591 |
if (aCategory == EMPXArtist || aCategory == EMPXAlbum) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2592 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2593 |
TPtrC art(KNullDesC); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2594 |
TPtrC artistname(KNullDesC); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2595 |
if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2596 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2597 |
art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2598 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2599 |
if (aCategory == EMPXAlbum) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2600 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2601 |
if (aMedia.IsSupported(KMPXMediaMusicArtist)) |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2602 |
{ |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2603 |
artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen)); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2604 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2605 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2606 |
iObserver.AddCategoryItemL(aCategory, KNullDesC, artistname, art, aDriveId, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2607 |
aItemChangedMessages, itemAdded); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2608 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2609 |
else |
53 | 2610 |
{ |
2611 |
// ignore the return value |
|
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2612 |
iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2613 |
aItemChangedMessages, itemAdded); |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2614 |
} |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2615 |
updated = ETrue; |
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2616 |
} |
53 | 2617 |
} |
2618 |
||
2619 |
if (aOldId && (aOldId != aItemId)) |
|
2620 |
{ |
|
2621 |
iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
|
2622 |
aItemChangedMessages, itemNotRemoved); |
|
2623 |
updated = ETrue; |
|
2624 |
} |
|
2625 |
||
2626 |
// Special case where the item(s) has been renamed. |
|
2627 |
// In this case, a new category is created +1 change msg |
|
2628 |
// a old category is removed +1 change msg |
|
2629 |
// We merge these 2 change messages into one using the deprecated ID |
|
2630 |
// |
|
2631 |
if( aItemChangedMessages ) |
|
2632 |
{ |
|
2633 |
TInt newChangeMsgCount( aItemChangedMessages->Count() ); |
|
2634 |
if( newChangeMsgCount - changeMsgCount > 0 ) |
|
2635 |
{ |
|
2636 |
TInt oldId = KErrNotFound; |
|
2637 |
TInt newId = KErrNotFound; |
|
2638 |
for( TInt i=0; i<newChangeMsgCount; ++i ) |
|
2639 |
{ |
|
2640 |
CMPXMessage& msg = *(*aItemChangedMessages)[i]; |
|
2641 |
||
2642 |
TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
|
2643 |
TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
|
2644 |
||
2645 |
// Look for the added and deleted category IDs |
|
2646 |
// |
|
2647 |
if( id == aOldId && changeType == EMPXItemDeleted ) |
|
2648 |
{ |
|
2649 |
oldId = i; |
|
2650 |
} |
|
2651 |
else if( id == aItemId && changeType == EMPXItemInserted ) |
|
2652 |
{ |
|
2653 |
newId = i; |
|
2654 |
} |
|
2655 |
} |
|
2656 |
||
2657 |
if( oldId != KErrNotFound && |
|
2658 |
newId != KErrNotFound ) |
|
2659 |
{ |
|
2660 |
aItemChangedMessages->Remove(oldId); // category removed |
|
2661 |
aItemChangedMessages->Remove(newId); // category added |
|
2662 |
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified, |
|
2663 |
aCategory, KDBPluginUid, aOldId ); |
|
2664 |
} |
|
2665 |
else if ( oldId !=KErrNotFound && itemAdded ) // old item removed, new item already exist |
|
2666 |
{ |
|
2667 |
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified, |
|
2668 |
aCategory, KDBPluginUid, aOldId ); |
|
2669 |
} |
|
2670 |
else if ( newId !=KErrNotFound && itemNotRemoved ) // new item added, old item still exist |
|
2671 |
{ |
|
2672 |
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aOldId, EMPXItemModified, |
|
2673 |
aCategory, KDBPluginUid, aItemId ); |
|
2674 |
} |
|
2675 |
} |
|
2676 |
} |
|
2677 |
} |
|
2678 |
||
2679 |
return updated; |
|
2680 |
} |
|
2681 |
||
66
1f1dad4af8f8
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
2682 |
|
53 | 2683 |
// ---------------------------------------------------------------------------- |
2684 |
// CMPXDbMusic::ExtraFieldsRequired |
|
2685 |
// ---------------------------------------------------------------------------- |
|
2686 |
// |
|
2687 |
TBool CMPXDbMusic::ExtraFieldsRequired( |
|
2688 |
const TArray<TMPXAttribute>& aAttrs) |
|
2689 |
{ |
|
2690 |
MPX_DEBUG1("-->CMPXDbMusic::ExtraFieldsRequired"); |
|
2691 |
||
2692 |
// check if any extra fields are required |
|
2693 |
TUint defaultFields(EMPXMediaGeneralId | |
|
2694 |
EMPXMediaGeneralType | |
|
2695 |
EMPXMediaGeneralCategory | |
|
2696 |
EMPXMediaGeneralTitle | |
|
2697 |
EMPXMediaGeneralUri | |
|
2698 |
EMPXMediaGeneralFlags); |
|
2699 |
||
2700 |
TBool extraRequired(EFalse); |
|
2701 |
TInt count(aAttrs.Count()); |
|
2702 |
for (TInt i = 0; i < count; ++i) |
|
2703 |
{ |
|
2704 |
TUint attributeId(aAttrs[i].AttributeId()|defaultFields); |
|
2705 |
MPX_DEBUG2(" attribute content id 0x%x", aAttrs[i].ContentId()); |
|
2706 |
MPX_DEBUG3(" attribute id %b, original attribute id %b", attributeId, aAttrs[i].AttributeId()); |
|
2707 |
||
2708 |
if (KMPXMediaIdGeneral != aAttrs[i].ContentId() || |
|
2709 |
attributeId != defaultFields) |
|
2710 |
{ |
|
2711 |
MPX_DEBUG1(" extraRequired YES"); |
|
2712 |
extraRequired = ETrue; |
|
2713 |
break; |
|
2714 |
} |
|
2715 |
} |
|
2716 |
||
2717 |
MPX_DEBUG2("<--CMPXDbMusic::ExtraFieldsRequired returns %d", extraRequired); |
|
2718 |
return extraRequired; |
|
2719 |
} |
|
2720 |
||
2721 |
// ---------------------------------------------------------------------------------------------------------- |
|
2722 |
// Test if the given media contains supported attributes |
|
2723 |
// ---------------------------------------------------------------------------------------------------------- |
|
2724 |
// |
|
2725 |
TBool CMPXDbMusic::IsSupported( |
|
2726 |
const CMPXMedia& aMedia) |
|
2727 |
{ |
|
2728 |
MPX_FUNC("CMPXDbMusic::IsSupported"); |
|
2729 |
||
2730 |
// this checklist should match the attributes processed in DoFillInDatabaseInfoL |
|
2731 |
return aMedia.IsSupported(KMPXMediaGeneralTitle) || |
|
2732 |
aMedia.IsSupported(KMPXMediaGeneralUri) || |
|
2733 |
aMedia.IsSupported(KMPXMediaGeneralComment) || |
|
2734 |
aMedia.IsSupported(KMPXMediaGeneralSynchronized) || |
|
2735 |
aMedia.IsSupported(KMPXMediaGeneralDeleted) || |
|
2736 |
aMedia.IsSupported(KMPXMediaGeneralModified) || |
|
2737 |
aMedia.IsSupported(KMPXMediaGeneralCopyright) || |
|
2738 |
aMedia.IsSupported(KMPXMediaGeneralDuration) || |
|
2739 |
aMedia.IsSupported(KMPXMediaGeneralFlags) || |
|
2740 |
aMedia.IsSupported(KMPXMediaGeneralPlayCount) || |
|
2741 |
aMedia.IsSupported(KMPXMediaGeneralLastPlaybackTime) || |
|
2742 |
aMedia.IsSupported(KMPXMediaMusicAlbumTrack) || |
|
2743 |
aMedia.IsSupported(KMPXMediaMusicYear) || |
|
2744 |
aMedia.IsSupported(KMPXMediaMusicRating) || |
|
2745 |
aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || |
|
2746 |
aMedia.IsSupported(KMPXMediaMusicURL) || |
|
2747 |
aMedia.IsSupported(KMPXMediaMusicArtist) || |
|
2748 |
aMedia.IsSupported(KMPXMediaMusicAlbum) || |
|
2749 |
aMedia.IsSupported(KMPXMediaMusicGenre) || |
|
2750 |
aMedia.IsSupported(KMPXMediaMusicComposer) || |
|
2751 |
aMedia.IsSupported(KMPXMediaAudioSamplerate) || |
|
2752 |
aMedia.IsSupported(KMPXMediaAudioBitrate) || |
|
2753 |
aMedia.IsSupported(KMPXMediaAudioNumberOfChannels) || |
|
2754 |
aMedia.IsSupported(KMPXMediaDrmType) || |
|
2755 |
aMedia.IsSupported(KMPXMediaDrmRightsStatus) || |
|
2756 |
aMedia.IsSupported(KMPXMediaMTPDrmStatus) |
|
2757 |
#ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2758 |
||aMedia.IsSupported(KMPXMediaMusicAlbumArtist) |
|
2759 |
#endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2760 |
; |
|
2761 |
} |
|
2762 |
||
2763 |
// End of File |