251 TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
254 TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
252 recordset.ColumnInt64(EMusicVolumeId))); |
255 recordset.ColumnInt64(EMusicVolumeId))); |
253 visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages, |
256 visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages, |
254 recordset); |
257 recordset); |
255 |
258 |
256 // Update Album table |
259 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
257 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist)) |
260 if(iArtNeedUpdated) |
258 { |
261 { |
259 TUint32 albumId = recordset.ColumnInt64(EMusicAlbum); |
262 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
260 iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages); |
263 // Update Album table |
261 } |
264 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist)) |
262 |
265 { |
263 // Update Artist table |
266 TUint32 albumId = recordset.ColumnInt64(EMusicAlbum); |
264 if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ) |
267 iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages); |
265 { |
268 } |
266 TUint32 artistId = recordset.ColumnInt64(EMusicArtist); |
269 |
267 iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages); |
270 // Update Artist table |
268 } |
271 if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ) |
269 |
272 { |
|
273 TUint32 artistId = recordset.ColumnInt64(EMusicArtist); |
|
274 iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages); |
|
275 } |
|
276 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
277 } |
|
278 iArtNeedUpdated = ETrue; //reset flag |
|
279 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
270 CleanupStack::PopAndDestroy(&recordset); |
280 CleanupStack::PopAndDestroy(&recordset); |
271 } |
281 } |
272 |
282 |
273 return visible; |
283 return visible; |
274 } |
284 } |
663 |
673 |
664 // ---------------------------------------------------------------------------- |
674 // ---------------------------------------------------------------------------- |
665 // CMPXDbMusic::GetAllSongsLimitedL |
675 // CMPXDbMusic::GetAllSongsLimitedL |
666 // ---------------------------------------------------------------------------- |
676 // ---------------------------------------------------------------------------- |
667 // |
677 // |
668 void CMPXDbMusic::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, |
678 void CMPXDbMusic::GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, |
669 CMPXMediaArray& aMediaArray, TInt aLimit) |
679 CMPXMediaArray& aMediaArray, TInt aLimit) |
670 { |
680 { |
671 MPX_FUNC("CMPXDbMusic::GetAllSongsLimitedL"); |
681 MPX_FUNC("CMPXDbMusic::GetAllSongsLimitedL"); |
672 |
682 |
673 // Gets a subset of the data from all songs ordered by title |
683 // Gets a subset of the data from all songs ordered by title |
674 HBufC* query = HBufC::NewLC( KQueryMusicGetSongsLimited().Length() + KMCIntegerLen ); |
684 HBufC* query = HBufC::NewLC( KQueryMusicGetSongsLimited().Length() + KMCIntegerLen ); |
675 query->Des().Format( KQueryMusicGetSongsLimited, aLimit ); |
685 query->Des().Format( KQueryMusicGetSongsLimited, aLimit ); |
676 ExecuteMediaQueryL(aAttrs, aMediaArray, *query); |
686 ExecuteMediaQueryL(aAttrs, aMediaArray, *query); |
677 CleanupStack::PopAndDestroy( query ); |
687 CleanupStack::PopAndDestroy( query ); |
810 // ---------------------------------------------------------------------------- |
820 // ---------------------------------------------------------------------------- |
811 // CMPXDbMusic::GetAllSongsForAbstractAlbumL |
821 // CMPXDbMusic::GetAllSongsForAbstractAlbumL |
812 // ---------------------------------------------------------------------------- |
822 // ---------------------------------------------------------------------------- |
813 // |
823 // |
814 void CMPXDbMusic::GetAllSongsForAbstractAlbumL( |
824 void CMPXDbMusic::GetAllSongsForAbstractAlbumL( |
815 TInt aDrive, |
825 TUint aAbstractAlbumId, |
816 TInt aAbstractAlbumId, |
|
817 const TArray<TMPXAttribute>& aAttrs, |
826 const TArray<TMPXAttribute>& aAttrs, |
818 CMPXMediaArray& aMediaArray) |
827 CMPXMediaArray& aMediaArray) |
819 { |
828 { |
820 MPX_FUNC("CMPXDbMusic::GetAllSongsL"); |
829 MPX_FUNC("CMPXDbMusic::GetAllSongsForAbstractAlbumL"); |
821 ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId); |
830 ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId); |
822 } |
831 } |
823 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
832 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
824 |
833 |
825 // ---------------------------------------------------------------------------- |
834 // ---------------------------------------------------------------------------- |
826 // CMPXDbMusic::AllSongsDurationL |
835 // CMPXDbMusic::AllSongsDurationL |
967 // ---------------------------------------------------------------------------- |
976 // ---------------------------------------------------------------------------- |
968 // |
977 // |
969 TUint CMPXDbMusic::GetDriveTrackCountL(TInt aDrive) |
978 TUint CMPXDbMusic::GetDriveTrackCountL(TInt aDrive) |
970 { |
979 { |
971 TUint count(0); |
980 TUint count(0); |
972 |
981 |
973 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryMusicCount)); |
982 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,KQueryMusicCount)); |
974 CleanupClosePushL(recordset); |
983 CleanupClosePushL(recordset); |
975 |
984 |
976 if (recordset.Next() != KSqlAtRow) |
985 if (recordset.Next() != KSqlAtRow) |
977 { |
986 { |
978 User::Leave(KErrCorrupt); |
987 User::Leave(KErrCorrupt); |
979 } |
988 } |
980 |
989 |
981 count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex)); |
990 count = TUint(recordset.ColumnInt64(KMPXTableDefaultIndex)); |
982 CleanupStack::PopAndDestroy(&recordset); |
991 CleanupStack::PopAndDestroy(&recordset); |
983 |
992 |
984 return count; |
993 return count; |
985 } |
994 } |
986 |
995 |
987 // ---------------------------------------------------------------------------- |
996 // ---------------------------------------------------------------------------- |
988 // CMPXDbMusic::GetMusicUriArrayL |
997 // CMPXDbMusic::GetMusicUriArrayL |
1004 query = HBufC::NewLC(KQueryMusicGetMusicUrisFrom().Length() + 2*KMCIntegerLen); |
1013 query = HBufC::NewLC(KQueryMusicGetMusicUrisFrom().Length() + 2*KMCIntegerLen); |
1005 query->Des().Format(KQueryMusicGetMusicUrisFrom, aFromID, aRecords); |
1014 query->Des().Format(KQueryMusicGetMusicUrisFrom, aFromID, aRecords); |
1006 } |
1015 } |
1007 |
1016 |
1008 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,*query)); |
1017 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDrive,*query)); |
1009 |
1018 |
1010 CleanupStack::PopAndDestroy(query); |
1019 CleanupStack::PopAndDestroy(query); |
1011 |
1020 |
1012 CleanupClosePushL(recordset); |
1021 CleanupClosePushL(recordset); |
1013 |
1022 |
1014 TInt lastID = 0; |
1023 TInt lastID = 0; |
1015 TInt err(KErrNone); |
1024 TInt err(KErrNone); |
1016 while((err = recordset.Next()) == KSqlAtRow) |
1025 while((err = recordset.Next()) == KSqlAtRow) |
1017 { |
1026 { |
1018 HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive, |
1027 HBufC* fullPath = MPXDbCommonUtil::CreateFullPathL(aDrive, |
1038 // ---------------------------------------------------------------------------- |
1047 // ---------------------------------------------------------------------------- |
1039 // |
1048 // |
1040 TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId) |
1049 TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId) |
1041 { |
1050 { |
1042 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId)); |
1051 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId)); |
1043 |
1052 |
1044 CleanupClosePushL(recordset); |
1053 CleanupClosePushL(recordset); |
1045 if (recordset.Next() != KSqlAtRow) |
1054 if (recordset.Next() != KSqlAtRow) |
1046 { |
1055 { |
1047 User::Leave(KErrNotFound); |
1056 User::Leave(KErrNotFound); |
1048 } |
1057 } |
1049 |
1058 |
1050 TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex); |
1059 TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex); |
1051 CleanupStack::PopAndDestroy(&recordset); |
1060 CleanupStack::PopAndDestroy(&recordset); |
1052 |
1061 |
1053 return artistId; |
1062 return artistId; |
1054 } |
|
1055 |
|
1056 // ---------------------------------------------------------------------------- |
|
1057 // CMPXDbMusic::RefreshStartL |
|
1058 // ---------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CMPXDbMusic::RefreshStartL() |
|
1061 { |
|
1062 iRefresh = ETrue; |
|
1063 MPX_FUNC("CMPXDbMusic::RefreshStartL"); |
|
1064 } |
|
1065 |
|
1066 // ---------------------------------------------------------------------------- |
|
1067 // CMPXDbMusic::RefreshEndL |
|
1068 // ---------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CMPXDbMusic::RefreshEndL() |
|
1071 { |
|
1072 MPX_FUNC("CMPXDbMusic::RefreshEndL"); |
|
1073 iRefresh = EFalse; |
|
1074 } |
1063 } |
1075 |
1064 |
1076 // ---------------------------------------------------------------------------- |
1065 // ---------------------------------------------------------------------------- |
1077 // CMPXDbMusic::SongExistsL |
1066 // CMPXDbMusic::SongExistsL |
1078 // ---------------------------------------------------------------------------- |
1067 // ---------------------------------------------------------------------------- |
1159 if (!aMedia.IsSupported(KMPXMediaGeneralId)) |
1148 if (!aMedia.IsSupported(KMPXMediaGeneralId)) |
1160 { |
1149 { |
1161 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralId)"); |
1150 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralId)"); |
1162 TUint32 songId(aMusicTable.ColumnInt64(EMusicUniqueId)); |
1151 TUint32 songId(aMusicTable.ColumnInt64(EMusicUniqueId)); |
1163 TInt columnCount(aMusicTable.ColumnCount()); |
1152 TInt columnCount(aMusicTable.ColumnCount()); |
|
1153 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1154 if(columnCount == 40 && aMusicTable.ColumnIndex(_L("PlUId"))==38) |
|
1155 { |
|
1156 TUint32 pListUId(aMusicTable.ColumnInt64(38)); |
|
1157 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId)); |
|
1158 } |
|
1159 #else |
1164 if(columnCount == 37 && aMusicTable.ColumnIndex(_L("PlUId"))==35) |
1160 if(columnCount == 37 && aMusicTable.ColumnIndex(_L("PlUId"))==35) |
1165 { |
1161 { |
1166 TUint32 pListUId(aMusicTable.ColumnInt64(35)); |
1162 TUint32 pListUId(aMusicTable.ColumnInt64(35)); |
1167 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId)); |
1163 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, TMPXItemId(pListUId, songId)); |
1168 } |
1164 } |
|
1165 #endif |
1169 else |
1166 else |
1170 { |
1167 { |
1171 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId); |
1168 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, songId); |
1172 } |
1169 } |
1173 MPX_DEBUG2(" SongId[%d]", songId); |
1170 MPX_DEBUG2(" SongId[%d]", songId); |
1174 } |
1171 } |
1175 // FIX ME temporary always fetch URI |
1172 // FIX ME temporary always fetch URI |
1176 if (aAttrId & EMPXMediaGeneralUri) |
1173 if (aAttrId & EMPXMediaGeneralUri) |
1177 { |
1174 { |
1182 MPX_DEBUG2(" FullPath[%S]", uri); |
1179 MPX_DEBUG2(" FullPath[%S]", uri); |
1183 CleanupStack::PopAndDestroy(uri); |
1180 CleanupStack::PopAndDestroy(uri); |
1184 } |
1181 } |
1185 if (aAttrId & EMPXMediaGeneralDrive) |
1182 if (aAttrId & EMPXMediaGeneralDrive) |
1186 { |
1183 { |
1187 MPX_DEBUG1(" EMPXMediaGeneralDrive"); |
1184 MPX_DEBUG1(" EMPXMediaGeneralDrive"); |
1188 TDriveUnit driveUnit; |
1185 TDriveUnit driveUnit; |
1189 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
1186 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
1190 { |
1187 { |
1191 MPX_DEBUG1(" aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1188 MPX_DEBUG1(" aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1192 driveUnit = aMedia.ValueText(KMPXMediaGeneralUri); |
1189 driveUnit = aMedia.ValueText(KMPXMediaGeneralUri); |
1193 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1190 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1194 } |
1191 } |
1195 else |
1192 else |
1196 { |
1193 { |
1197 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1194 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1198 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1195 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1199 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1196 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1200 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1197 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1201 } |
1198 } |
1202 |
1199 |
1203 TPtrC driveName(driveUnit.Name()); |
1200 TPtrC driveName(driveUnit.Name()); |
1204 aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveName); |
1201 aMedia.SetTextValueL(KMPXMediaGeneralDrive, driveName); |
1205 MPX_DEBUG2(" Drive[%S]", &driveName); |
1202 MPX_DEBUG2(" Drive[%S]", &driveName); |
1206 } |
1203 } |
1207 if (aAttrId & EMPXMediaGeneralSize) |
1204 if (aAttrId & EMPXMediaGeneralSize) |
1208 { |
1205 { |
1209 MPX_DEBUG1(" EMPXMediaGeneralSize"); |
1206 MPX_DEBUG1(" EMPXMediaGeneralSize"); |
1210 // to-do: store this in the DB |
1207 // to-do: store this in the DB |
1211 } |
1208 } |
1212 if (aAttrId & EMPXMediaGeneralDuration) |
1209 if (aAttrId & EMPXMediaGeneralDuration) |
1213 { |
1210 { |
1214 MPX_DEBUG1(" EMPXMediaGeneralDuration"); |
1211 MPX_DEBUG1(" EMPXMediaGeneralDuration"); |
1215 TInt32 duration(aMusicTable.ColumnInt(EMusicDuration)); |
1212 TInt32 duration(aMusicTable.ColumnInt(EMusicDuration)); |
1216 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration); |
1213 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, duration); |
1217 MPX_DEBUG2(" Duration[%d]", duration); |
1214 MPX_DEBUG2(" Duration[%d]", duration); |
1218 } |
1215 } |
1219 if ((aAttrId & EMPXMediaGeneralTitle) && !aMedia.IsSupported(KMPXMediaGeneralTitle)) |
1216 if ((aAttrId & EMPXMediaGeneralTitle) && !aMedia.IsSupported(KMPXMediaGeneralTitle)) |
1222 TPtrC title(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicTitle)); |
1219 TPtrC title(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicTitle)); |
1223 aMedia.SetTextValueL(KMPXMediaGeneralTitle, title); |
1220 aMedia.SetTextValueL(KMPXMediaGeneralTitle, title); |
1224 MPX_DEBUG2(" Title[%S]", &title); |
1221 MPX_DEBUG2(" Title[%S]", &title); |
1225 } |
1222 } |
1226 if ( aAttrId & EMPXMediaGeneralDate) |
1223 if ( aAttrId & EMPXMediaGeneralDate) |
1227 { |
1224 { |
1228 MPX_DEBUG1(" EMPXMediaGeneralDate"); |
1225 MPX_DEBUG1(" EMPXMediaGeneralDate"); |
1229 const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
1226 const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
1230 EMusicTimeAdded)); |
1227 EMusicTimeAdded)); |
1231 if ( dateStr.Compare (KNullDesC)!= 0) |
1228 if ( dateStr.Compare (KNullDesC)!= 0) |
1232 { |
1229 { |
1233 TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
1230 TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
1234 aMedia.SetTObjectValueL<TInt64> (KMPXMediaGeneralDate, |
1231 aMedia.SetTObjectValueL<TInt64> (KMPXMediaGeneralDate, |
1235 dateTime.Int64 ()); |
1232 dateTime.Int64 ()); |
1236 } |
1233 } |
1237 MPX_DEBUG2(" Date[%S]", &dateStr); |
1234 MPX_DEBUG2(" Date[%S]", &dateStr); |
1238 } |
1235 } |
1239 if (aAttrId & EMPXMediaGeneralComment) |
1236 if (aAttrId & EMPXMediaGeneralComment) |
1240 { |
1237 { |
1241 MPX_DEBUG1(" EMPXMediaGeneralComment"); |
1238 MPX_DEBUG1(" EMPXMediaGeneralComment"); |
1242 TPtrC comment(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComment)); |
1239 TPtrC comment(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicComment)); |
1243 aMedia.SetTextValueL(KMPXMediaGeneralComment, comment); |
1240 aMedia.SetTextValueL(KMPXMediaGeneralComment, comment); |
1244 MPX_DEBUG2(" Comment[%S]", &comment); |
1241 MPX_DEBUG2(" Comment[%S]", &comment); |
1245 } |
1242 } |
1246 if (aAttrId & EMPXMediaGeneralMimeType) |
1243 if (aAttrId & EMPXMediaGeneralMimeType) |
1247 { |
1244 { |
1248 MPX_DEBUG1(" EMPXMediaGeneralMimeType"); |
1245 MPX_DEBUG1(" EMPXMediaGeneralMimeType"); |
1249 TPtrC mimeType(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicMimeType)); |
1246 TPtrC mimeType(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicMimeType)); |
1250 aMedia.SetTextValueL(KMPXMediaGeneralMimeType, mimeType); |
1247 aMedia.SetTextValueL(KMPXMediaGeneralMimeType, mimeType); |
1251 MPX_DEBUG2(" MimeType[%S]", &mimeType); |
1248 MPX_DEBUG2(" MimeType[%S]", &mimeType); |
1252 } |
1249 } |
1253 if (aAttrId & EMPXMediaGeneralSynchronized) |
1250 if (aAttrId & EMPXMediaGeneralSynchronized) |
1254 { |
1251 { |
1255 MPX_DEBUG1(" EMPXMediaGeneralSynchronized"); |
1252 MPX_DEBUG1(" EMPXMediaGeneralSynchronized"); |
1256 TInt sync(aMusicTable.ColumnInt(EMusicSync)); |
1253 TInt sync(aMusicTable.ColumnInt(EMusicSync)); |
1257 aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, sync); |
1254 aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralSynchronized, sync); |
1258 MPX_DEBUG2(" Synchronized[%d]", sync); |
1255 MPX_DEBUG2(" Synchronized[%d]", sync); |
1259 } |
1256 } |
1260 if (aAttrId & EMPXMediaGeneralDeleted) |
1257 if (aAttrId & EMPXMediaGeneralDeleted) |
1261 { |
1258 { |
1262 MPX_DEBUG1(" EMPXMediaGeneralDeleted"); |
1259 MPX_DEBUG1(" EMPXMediaGeneralDeleted"); |
1263 TInt del(aMusicTable.ColumnInt(EMusicDeleted)); |
1260 TInt del(aMusicTable.ColumnInt(EMusicDeleted)); |
1264 aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralDeleted, del); |
1261 aMedia.SetTObjectValueL<TBool>(KMPXMediaGeneralDeleted, del); |
1265 MPX_DEBUG2(" Deleted[%d]", del); |
1262 MPX_DEBUG2(" Deleted[%d]", del); |
1266 } |
1263 } |
1267 if (aAttrId & EMPXMediaGeneralModified) |
1264 if (aAttrId & EMPXMediaGeneralModified) |
1276 MPX_DEBUG1(" EMPXMediaGeneralCount"); |
1273 MPX_DEBUG1(" EMPXMediaGeneralCount"); |
1277 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
1274 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
1278 } |
1275 } |
1279 if (aAttrId & EMPXMediaGeneralCollectionId) |
1276 if (aAttrId & EMPXMediaGeneralCollectionId) |
1280 { |
1277 { |
1281 MPX_DEBUG1(" EMPXMediaGeneralCollectionId"); |
1278 MPX_DEBUG1(" EMPXMediaGeneralCollectionId"); |
1282 aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, |
1279 aMedia.SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, |
1283 TUid::Uid(KDBPluginUid)); |
1280 TUid::Uid(KDBPluginUid)); |
1284 } |
1281 } |
1285 if(aAttrId & EMPXMediaGeneralCopyright) |
1282 if(aAttrId & EMPXMediaGeneralCopyright) |
1286 { |
1283 { |
1287 MPX_DEBUG1(" EMPXMediaGeneralCopyright"); |
1284 MPX_DEBUG1(" EMPXMediaGeneralCopyright"); |
1288 TPtrC copyright(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicCopyright)); |
1285 TPtrC copyright(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicCopyright)); |
1289 aMedia.SetTextValueL(KMPXMediaGeneralCopyright, copyright); |
1286 aMedia.SetTextValueL(KMPXMediaGeneralCopyright, copyright); |
1290 MPX_DEBUG2(" Copyright[%S]", ©right); |
1287 MPX_DEBUG2(" Copyright[%S]", ©right); |
1291 } |
1288 } |
1292 if (aAttrId & EMPXMediaGeneralFlags) |
1289 if (aAttrId & EMPXMediaGeneralFlags) |
1293 { |
1290 { |
1294 MPX_DEBUG1(" EMPXMediaGeneralFlags"); |
1291 MPX_DEBUG1(" EMPXMediaGeneralFlags"); |
1295 TUint32 dbFlags(aMusicTable.ColumnInt64(EMusicDbFlag)); |
1292 TUint32 dbFlags(aMusicTable.ColumnInt64(EMusicDbFlag)); |
1296 MPX_DEBUG2(" dbFlags=%b", dbFlags); |
1293 MPX_DEBUG2(" dbFlags=%b", dbFlags); |
1297 TDriveUnit driveUnit; |
1294 TDriveUnit driveUnit; |
1298 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
1295 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
1299 { |
1296 { |
1304 driveUnit = parse.Drive(); |
1301 driveUnit = parse.Drive(); |
1305 } |
1302 } |
1306 else |
1303 else |
1307 { |
1304 { |
1308 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1305 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1309 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1306 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1310 } |
1307 } |
1311 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1308 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1312 } |
1309 } |
1313 else |
1310 else |
1314 { |
1311 { |
1315 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1312 MPX_DEBUG1(" !aMedia.IsSupported(KMPXMediaGeneralUri)"); |
1316 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1313 driveUnit = MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(), |
1317 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1314 aMusicTable.ColumnInt64(EMusicVolumeId)); |
1318 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1315 MPX_DEBUG2(" driveUnit=%d", (TInt)driveUnit); |
1319 } |
1316 } |
1320 |
1317 |
1321 TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo; // 5 bits |
1318 TInt driveId = driveUnit & KMPXMediaGeneralFlagsDriveInfo; // 5 bits |
1322 aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId); |
1319 aMedia.SetTObjectValueL<TUint>(KMPXMediaGeneralFlags, dbFlags | driveId); |
1323 |
1320 |
1324 MPX_DEBUG2(" GeneralFlags[%b]", dbFlags | driveId); |
1321 MPX_DEBUG2(" GeneralFlags[%b]", dbFlags | driveId); |
1325 MPX_DEBUG2(" DriveId[%u]", driveId); |
1322 MPX_DEBUG2(" DriveId[%u]", driveId); |
1326 } |
1323 } |
1327 if (aAttrId & EMPXMediaGeneralPlayCount) |
1324 if (aAttrId & EMPXMediaGeneralPlayCount) |
1328 { |
1325 { |
1329 MPX_DEBUG1(" EMPXMediaGeneralPlayCount"); |
1326 MPX_DEBUG1(" EMPXMediaGeneralPlayCount"); |
1330 TUint32 playcount(aMusicTable.ColumnInt(EMusicPlayCount)); |
1327 TUint32 playcount(aMusicTable.ColumnInt(EMusicPlayCount)); |
1331 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralPlayCount, playcount); |
1328 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralPlayCount, playcount); |
1332 MPX_DEBUG2(" PlayCount[%d]", playcount); |
1329 MPX_DEBUG2(" PlayCount[%d]", playcount); |
1333 } |
1330 } |
1334 |
1331 |
1335 MPX_DEBUG1("<--CMPXDbMusic::UpdateMediaGeneralL"); |
1332 MPX_DEBUG1("<--CMPXDbMusic::UpdateMediaGeneralL"); |
1336 } |
1333 } |
1337 |
1334 |
1338 // ---------------------------------------------------------------------------- |
1335 // ---------------------------------------------------------------------------- |
1339 // CMPXDbMusic::UpdateMediaMusicL |
1336 // CMPXDbMusic::UpdateMediaMusicL |
1363 TPtrC album(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumName)); |
1360 TPtrC album(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumName)); |
1364 aMedia.SetTextValueL(KMPXMediaMusicAlbum, album); |
1361 aMedia.SetTextValueL(KMPXMediaMusicAlbum, album); |
1365 MPX_DEBUG2(" Album[%S]", &album); |
1362 MPX_DEBUG2(" Album[%S]", &album); |
1366 } |
1363 } |
1367 if ( aAttrId & EMPXMediaMusicYear) |
1364 if ( aAttrId & EMPXMediaMusicYear) |
1368 { |
1365 { |
1369 const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
1366 const TDesC& dateStr(MPXDbCommonUtil::GetColumnTextL (aMusicTable, |
1370 EMusicReleaseDate)); |
1367 EMusicReleaseDate)); |
1371 if ( dateStr.Compare (KNullDesC)!= 0) |
1368 if ( dateStr.Compare (KNullDesC)!= 0) |
1372 { |
1369 { |
1373 TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
1370 TTime dateTime(MPXDbCommonUtil::DesToTTimeL (dateStr)); |
1374 aMedia.SetTObjectValueL<TInt64> (KMPXMediaMusicYear, |
1371 aMedia.SetTObjectValueL<TInt64> (KMPXMediaMusicYear, |
1375 dateTime.Int64 ()); |
1372 dateTime.Int64 ()); |
1376 MPX_DEBUG2(" Year[%d]", dateTime.Int64()); |
1373 MPX_DEBUG2(" Year[%d]", dateTime.Int64()); |
1377 } |
1374 } |
1378 MPX_DEBUG2(" ReleaseDate[%S]", &dateStr); |
1375 MPX_DEBUG2(" ReleaseDate[%S]", &dateStr); |
1379 } |
1376 } |
1380 if (aAttrId & EMPXMediaMusicAlbumTrack) |
1377 if (aAttrId & EMPXMediaMusicAlbumTrack) |
1381 { |
1378 { |
1382 TInt32 track(aMusicTable.ColumnInt(EMusicAlbumTrack)); |
1379 TInt32 track(aMusicTable.ColumnInt(EMusicAlbumTrack)); |
1383 HBufC* hbuf = HBufC::NewLC(KMCIntegerLen); |
1380 HBufC* hbuf = HBufC::NewLC(KMCIntegerLen); |
1384 if (track != KMaxTInt) |
1381 if (track != KMaxTInt) |
1454 MPX_DEBUG2(" Music Original Album Art FullPath[%S]", fullPath); |
1451 MPX_DEBUG2(" Music Original Album Art FullPath[%S]", fullPath); |
1455 CleanupStack::PopAndDestroy(fullPath); |
1452 CleanupStack::PopAndDestroy(fullPath); |
1456 } |
1453 } |
1457 } |
1454 } |
1458 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1455 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1459 if (aAttrId & EMPXMediaMusicAlbumArtist) |
1456 if (aAttrId & EMPXMediaMusicAlbumArtist) |
1460 { |
1457 { |
1461 TPtrC albumartist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumArtist)); |
1458 TPtrC albumartist(MPXDbCommonUtil::GetColumnTextL(aMusicTable, EMusicAlbumArtist)); |
1462 aMedia.SetTextValueL(KMPXMediaMusicAlbumArtist, albumartist); |
1459 aMedia.SetTextValueL(KMPXMediaMusicAlbumArtist, albumartist); |
1463 MPX_DEBUG2(" Music AlbumArtist[%S]", &albumartist); |
1460 MPX_DEBUG2(" Music AlbumArtist[%S]", &albumartist); |
1464 } |
1461 } |
1465 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1462 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
1463 if (aAttrId & EMPXMediaMusicAlbumId) |
|
1464 { |
|
1465 TUint32 albumId(aMusicTable.ColumnInt64(EMusicAlbum)); |
|
1466 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaMusicAlbumId, albumId); |
|
1467 MPX_DEBUG2(" AlbumId[%d]", albumId); |
|
1468 } |
1466 } |
1469 } |
1467 |
1470 |
1468 // ---------------------------------------------------------------------------- |
1471 // ---------------------------------------------------------------------------- |
1469 // CMPXDbMusic::UpdateMediaAudioL |
1472 // CMPXDbMusic::UpdateMediaAudioL |
1470 // ---------------------------------------------------------------------------- |
1473 // ---------------------------------------------------------------------------- |
1544 if (aItemChangedMessages) |
1547 if (aItemChangedMessages) |
1545 { |
1548 { |
1546 songChangedMessage = CMPXMedia::NewL(); |
1549 songChangedMessage = CMPXMedia::NewL(); |
1547 CleanupStack::PushL(songChangedMessage); |
1550 CleanupStack::PushL(songChangedMessage); |
1548 MPXDbCommonUtil::FillItemChangedMessageL(*songChangedMessage, aSongId, |
1551 MPXDbCommonUtil::FillItemChangedMessageL(*songChangedMessage, aSongId, |
1549 aMusicTable ? EMPXItemModified : EMPXItemInserted, EMPXSong, KDBPluginUid); |
1552 aMusicTable ? EMPXItemModified : EMPXItemInserted, EMPXSong, KDBPluginUid); |
1550 } |
1553 } |
1551 |
1554 |
1552 // NOTE: Attributes being processed here should be listed in IsSupported() |
1555 // NOTE: Attributes being processed here should be listed in IsSupported() |
1553 TInt attrCount(attributes.Count()); |
1556 TInt attrCount(attributes.Count()); |
1554 for (TInt i = 0; i < attrCount; ++i) |
1557 for (TInt i = 0; i < attrCount; ++i) |
1874 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1877 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1875 const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
1878 const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
1876 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1879 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1877 TParsePtrC parse(albumArtFilename); |
1880 TParsePtrC parse(albumArtFilename); |
1878 TPtrC ext(parse.Ext()); |
1881 TPtrC ext(parse.Ext()); |
|
1882 //set flag to false, so .alb will not overwrite art field in album, artist table |
|
1883 // when song with embedded art |
|
1884 if ((ext.CompareF(KAbstractAlbumExt)== 0) && containEmbeddedArt) |
|
1885 { |
|
1886 iArtNeedUpdated = EFalse; |
|
1887 } |
1879 |
1888 |
1880 if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0)) |
1889 if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0)) |
1881 { |
1890 { |
1882 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1891 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1883 if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt))) |
1892 if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt))) |
1966 { |
1975 { |
1967 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, drmType); |
1976 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDRM, drmType); |
1968 } |
1977 } |
1969 MPX_DEBUG2(" DRM type[%d]", drmType); |
1978 MPX_DEBUG2(" DRM type[%d]", drmType); |
1970 } |
1979 } |
1971 |
1980 |
1972 if (attributeId & KMPXMediaDrmRightsStatus.iAttributeId) |
1981 if (attributeId & KMPXMediaDrmRightsStatus.iAttributeId) |
1973 { |
1982 { |
1974 if (aMusicTable) |
1983 if (aMusicTable) |
1975 { |
1984 { |
1976 TMPXMediaDrmRightsStatus status = |
1985 TMPXMediaDrmRightsStatus status = |
1977 aMedia.ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus); |
1986 aMedia.ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus); |
1978 |
1987 |
1979 //.Set the db flag |
1988 //.Set the db flag |
1980 TUint32 curFlag(aMusicTable->ColumnInt64(EMusicDbFlag)); |
1989 TUint32 curFlag(aMusicTable->ColumnInt64(EMusicDbFlag)); |
1981 TUint32 oldFlag(curFlag); |
1990 TUint32 oldFlag(curFlag); |
1982 |
1991 |
1983 if ((status != EMPXDrmRightsFull) && (status != EMPXDrmRightsRestricted)) |
1992 if ((status != EMPXDrmRightsFull) && (status != EMPXDrmRightsRestricted)) |
1984 { |
1993 { |
1985 // No rights |
1994 // No rights |
1986 curFlag |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid; |
1995 curFlag |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid; |
1987 } |
1996 } |
1988 else |
1997 else |
1989 { |
1998 { |
1990 // Rights valid |
1999 // Rights valid |
1991 curFlag &= (KMPXMediaGeneralFlagsIsDrmLicenceInvalid ^ 0xFFFFFFFF); |
2000 curFlag &= (KMPXMediaGeneralFlagsIsDrmLicenceInvalid ^ 0xFFFFFFFF); |
1992 } |
2001 } |
1993 |
2002 |
1994 // The field is written ONLY if the flag value is changing |
2003 // The field is written ONLY if the flag value is changing |
1995 if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0) |
2004 if (((curFlag ^ oldFlag) & 0x7FFFFFFF) != 0) |
1996 { |
2005 { |
1997 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag); |
2006 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicDbFlag, curFlag); |
1998 visibleChange = CMPXDbActiveTask::EAllVisible; |
2007 visibleChange = CMPXDbActiveTask::EAllVisible; |
1999 } |
2008 } |
2000 |
2009 |
2001 MPX_DEBUG2(" Rights Status[%d]", curFlag); |
2010 MPX_DEBUG2(" Rights Status[%d]", curFlag); |
2002 } |
2011 } |
2003 } |
2012 } |
2004 |
2013 |
2005 break; |
2014 break; |
2006 } |
2015 } |
2007 |
2016 |
2008 case KMPXMediaIdMTP: |
2017 case KMPXMediaIdMTP: |
2009 { |
2018 { |
2055 visibleChange = CMPXDbActiveTask::EAllVisible; |
2064 visibleChange = CMPXDbActiveTask::EAllVisible; |
2056 artistIdForAlbum = id; |
2065 artistIdForAlbum = id; |
2057 } |
2066 } |
2058 |
2067 |
2059 // update the album field |
2068 // update the album field |
2060 if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId, |
2069 if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId, |
2061 aDrive, aItemChangedMessages, id, artistIdForAlbum)) |
2070 aDrive, aItemChangedMessages, id, artistIdForAlbum)) |
2062 { |
2071 { |
2063 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id); |
2072 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id); |
2064 metaDataModified = (aMusicTable != NULL); |
2073 metaDataModified = (aMusicTable != NULL); |
2065 visibleChange = CMPXDbActiveTask::EAllVisible; |
2074 visibleChange = CMPXDbActiveTask::EAllVisible; |
2066 |
2075 |
2067 // |
2076 // |
2068 // added to handle error EALU-73WDJN. If the album name of the last song |
2077 // added to handle error EALU-73WDJN. If the album name of the last song |
2069 // in the album for the artist is changed to an existing album name from |
2078 // in the album for the artist is changed to an existing album name from |
2070 // artist view, a change message needs to be sent in order for UI to |
2079 // artist view, a change message needs to be sent in order for UI to |
2071 // correctly refresh. |
2080 // correctly refresh. |
2072 // |
2081 // |
2073 // Fix for EDXU-7BBALS, remove check for HasOtherSongsInArtistAlbumL |
2082 // Fix for EDXU-7BBALS, remove check for HasOtherSongsInArtistAlbumL |
2074 // Always send a Album Inserted message when Album change to get Artist updated |
2083 // Always send a Album Inserted message when Album change to get Artist updated |
2075 if (aItemChangedMessages) |
2084 if (aItemChangedMessages) |
2076 { |
2085 { |
2077 // send album added m essage instead of album deleted or modified |
2086 // send album added m essage instead of album deleted or modified |
2078 // to avoid collection paths of other clients being modified |
2087 // to avoid collection paths of other clients being modified |
2079 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId, |
2088 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId, |
2080 EMPXItemInserted, EMPXAlbum, KDBPluginUid); |
2089 EMPXItemInserted, EMPXAlbum, KDBPluginUid); |
2081 } |
2090 } |
2082 } |
2091 } |
2083 |
2092 |
2084 // update the genre field |
2093 // update the genre field |
2260 { |
2269 { |
2261 // full URI from criteria |
2270 // full URI from criteria |
2262 const TDesC& uri = aCriteria.ValueText(KMPXMediaGeneralUri); |
2271 const TDesC& uri = aCriteria.ValueText(KMPXMediaGeneralUri); |
2263 TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, |
2272 TUint32 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXCollection, |
2264 uri, EFalse); |
2273 uri, EFalse); |
2265 |
2274 |
2266 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicUniqueId, itemId); |
2275 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicUniqueId, itemId); |
2267 } |
2276 } |
2268 else if (criterion == KMPXMediaGeneralDrive) |
2277 else if (criterion == KMPXMediaGeneralDrive) |
2269 { |
2278 { |
2270 if (!volumeAdded) |
2279 if (!volumeAdded) |
2271 { |
2280 { |
2272 // validate the drive letter, TDriveUnit panics if given drive isn't between |
2281 // validate the drive letter, TDriveUnit panics if given drive isn't between |
2273 // 'A' to 'Z' |
2282 // 'A' to 'Z' |
2274 TDriveUnit driveUnit(aCriteria.ValueText(KMPXMediaGeneralDrive)); |
2283 const TDesC& drive = aCriteria.ValueText(KMPXMediaGeneralDrive); |
|
2284 TInt driveInt = 0; |
|
2285 if( drive == KNullDesC || RFs::CharToDrive( drive[0], driveInt )!= KErrNone ) |
|
2286 { |
|
2287 User::Leave(KErrArgument); |
|
2288 } |
|
2289 TDriveUnit driveUnit(drive); |
2275 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume, |
2290 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume, |
2276 MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
2291 MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
2277 volumeAdded = ETrue; |
2292 volumeAdded = ETrue; |
2278 } |
2293 } |
2279 } |
2294 } |
2388 if (!aOldId || aMedia.IsSupported(aAttribute)) |
2403 if (!aOldId || aMedia.IsSupported(aAttribute)) |
2389 { |
2404 { |
2390 TInt changeMsgCount( 0 ); |
2405 TInt changeMsgCount( 0 ); |
2391 if( aItemChangedMessages ) |
2406 if( aItemChangedMessages ) |
2392 { |
2407 { |
2393 changeMsgCount = aItemChangedMessages->Count(); |
2408 changeMsgCount = aItemChangedMessages->Count(); |
2394 } |
2409 } |
2395 |
2410 |
2396 if (aMedia.IsSupported(aAttribute)) |
2411 if (aMedia.IsSupported(aAttribute)) |
2397 { |
2412 { |
2398 TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen)); |
2413 TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen)); |
2399 |
2414 |
2400 // construct the new ID for the category record |
2415 // construct the new ID for the category record |
|
2416 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2417 // genre and abstractalbum are not case sensitive |
|
2418 TBool caseSensitive = ETrue; |
|
2419 if ((aCategory == EMPXGenre) || (aCategory == EMPXAbstractAlbum)) |
|
2420 caseSensitive = EFalse; |
|
2421 |
|
2422 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
|
2423 name, caseSensitive); |
|
2424 |
|
2425 #else |
2401 // only genre is not case sensitive |
2426 // only genre is not case sensitive |
2402 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
2427 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
2403 name, (aCategory != EMPXGenre)); |
2428 name, (aCategory != EMPXGenre)); |
|
2429 #endif |
2404 if (!aOldId || (aOldId != aItemId)) |
2430 if (!aOldId || (aOldId != aItemId)) |
2405 { |
2431 { |
2406 // only add if the ID changed, |
2432 // only add if the ID changed, |
2407 // otherwise the song was updated but the artist name was not |
2433 // otherwise the song was updated but the artist name was not |
2408 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2434 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2409 if(aCategory == EMPXAbstractAlbum) |
2435 if(aCategory == EMPXAbstractAlbum) |
2410 { |
2436 { |
2411 if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong ) |
2437 if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong ) |
2412 { |
2438 { |
2413 iObserver.AddCategoryItemL(aCategory, name, aDriveId, |
2439 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2414 aItemChangedMessages, itemAdded, KNullDesC, KNullDesC); |
2440 aItemChangedMessages, itemAdded, name, KNullDesC); |
2415 } |
2441 } |
2416 else |
2442 else |
2417 { |
2443 { |
2418 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2444 TPtrC albumartist(KNullDesC); |
2419 //get AlbumArt, Genre for AbstractAlbum |
2445 TPtrC abstractAlbumName(KNullDesC); |
2420 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2446 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist) ) |
2421 TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen)); |
2447 { |
2422 MPX_DEBUG2(" Music Genre[%S]", &genre); |
2448 albumartist.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2423 |
2449 //get AlbumArt AbstractAlbum |
2424 // ignore the return value |
2450 MPX_DEBUG2(" albumartist[%S]", &albumartist); |
2425 iObserver.AddCategoryItemL(aCategory, name, aDriveId, |
2451 } |
2426 aItemChangedMessages, itemAdded, albumartist, genre); |
2452 if (aMedia.IsSupported(KMPXMediaGeneralTitle) ) |
|
2453 { |
|
2454 abstractAlbumName.Set(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
|
2455 MPX_DEBUG2(" abstractAlbumName[%S]", &abstractAlbumName); |
|
2456 } |
|
2457 // ignore the return value |
|
2458 |
|
2459 iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
|
2460 aItemChangedMessages, itemAdded, name, albumartist); |
2427 } |
2461 } |
2428 } |
2462 } |
2429 else |
2463 else |
2430 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2464 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2431 { |
2465 { |
2436 updated = ETrue; |
2470 updated = ETrue; |
2437 } |
2471 } |
2438 } |
2472 } |
2439 else |
2473 else |
2440 { |
2474 { |
|
2475 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2476 // genre and abstractalbum are not case sensitive |
|
2477 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2478 (aCategory != EMPXGenre)&&(aCategory != EMPXAbstractAlbum)); |
|
2479 #else |
2441 // only genre is not case sensitive |
2480 // only genre is not case sensitive |
2442 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
2481 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
2443 (aCategory != EMPXGenre)); |
2482 (aCategory != EMPXGenre)); |
|
2483 #endif |
2444 if (!aOldId || (aOldId != aItemId)) |
2484 if (!aOldId || (aOldId != aItemId)) |
2445 { |
2485 { |
2446 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2486 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2447 if(aCategory == EMPXAbstractAlbum) |
2487 if(aCategory == EMPXAbstractAlbum) |
2448 { |
2488 { |
2449 //get AlbumArt, Genre for AbstractAlbum |
2489 //get AlbumArt for AbstractAlbum |
2450 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2490 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2451 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2491 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2452 TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen)); |
2492 TPtrC abstractAlbumName(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
2453 MPX_DEBUG2(" Music Genre[%S]", &genre); |
2493 MPX_DEBUG2(" Music abstractAlbumName[%S]", &abstractAlbumName); |
2454 |
|
2455 // ignore the return value |
2494 // ignore the return value |
2456 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2495 iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
2457 aItemChangedMessages, itemAdded, albumartist, genre); |
2496 aItemChangedMessages, itemAdded, KNullDesC, albumartist); |
2458 } |
2497 } |
2459 else |
2498 else |
2460 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2499 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2461 { |
2500 { |
2462 // ignore the return value |
2501 // ignore the return value |
2463 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2502 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2464 aItemChangedMessages, itemAdded); |
2503 aItemChangedMessages, itemAdded); |
2465 } |
2504 } |
2466 updated = ETrue; |
2505 updated = ETrue; |
2467 } |
2506 } |
2468 } |
2507 } |
2469 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2508 |
2470 //no need to delete old item for abstractalbum |
2509 if (aOldId && (aOldId != aItemId)) |
2471 if (aOldId && (aOldId != aItemId) && (aCategory != EMPXAbstractAlbum)) |
2510 { |
2472 #else |
2511 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
2473 if (aOldId && (aOldId != aItemId)) |
|
2474 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2475 { |
|
2476 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
|
2477 aItemChangedMessages, itemNotRemoved); |
2512 aItemChangedMessages, itemNotRemoved); |
2478 updated = ETrue; |
2513 updated = ETrue; |
2479 } |
2514 } |
2480 |
2515 |
2481 // Special case where the item(s) has been renamed. |
2516 // Special case where the item(s) has been renamed. |
2482 // In this case, a new category is created +1 change msg |
2517 // In this case, a new category is created +1 change msg |
2483 // a old category is removed +1 change msg |
2518 // a old category is removed +1 change msg |
2484 // We merge these 2 change messages into one using the deprecated ID |
2519 // We merge these 2 change messages into one using the deprecated ID |
2485 // |
2520 // |
2491 TInt oldId = KErrNotFound; |
2526 TInt oldId = KErrNotFound; |
2492 TInt newId = KErrNotFound; |
2527 TInt newId = KErrNotFound; |
2493 for( TInt i=0; i<newChangeMsgCount; ++i ) |
2528 for( TInt i=0; i<newChangeMsgCount; ++i ) |
2494 { |
2529 { |
2495 CMPXMessage& msg = *(*aItemChangedMessages)[i]; |
2530 CMPXMessage& msg = *(*aItemChangedMessages)[i]; |
2496 |
2531 |
2497 TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
2532 TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
2498 TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
2533 TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
2499 |
2534 |
2500 // Look for the added and deleted category IDs |
2535 // Look for the added and deleted category IDs |
2501 // |
2536 // |
2502 if( id == aOldId && changeType == EMPXItemDeleted ) |
2537 if( id == aOldId && changeType == EMPXItemDeleted ) |
2503 { |
2538 { |
2504 oldId = i; |
2539 oldId = i; |
2567 name, (aCategory != EMPXGenre)); |
2602 name, (aCategory != EMPXGenre)); |
2568 if (!aOldId || (aOldId != aItemId)) |
2603 if (!aOldId || (aOldId != aItemId)) |
2569 { |
2604 { |
2570 // only add if the ID changed, |
2605 // only add if the ID changed, |
2571 // otherwise the song was updated but the artist name was not |
2606 // otherwise the song was updated but the artist name was not |
|
2607 TPtrC art(KNullDesC); |
|
2608 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
2609 { |
|
2610 art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
|
2611 } |
|
2612 |
|
2613 iObserver.AddCategoryItemL(aCategory, name, aArtistId, art, aDriveId, aItemChangedMessages, itemAdded); |
|
2614 updated = ETrue; |
|
2615 } |
|
2616 } |
|
2617 else |
|
2618 { |
|
2619 // only genre is not case sensitive |
|
2620 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2621 (aCategory != EMPXGenre)); |
|
2622 if (!aOldId || (aOldId != aItemId)) |
|
2623 { |
2572 TPtrC art(KNullDesC); |
2624 TPtrC art(KNullDesC); |
2573 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
2625 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
2574 { |
2626 { |
2575 art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
2627 art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
2576 } |
2628 } |
2577 |
2629 |
2578 iObserver.AddCategoryItemL(aCategory, name, aArtistId, art, aDriveId, aItemChangedMessages, itemAdded); |
2630 iObserver.AddCategoryItemL(aCategory, KNullDesC, aArtistId, art, aDriveId, |
2579 updated = ETrue; |
|
2580 } |
|
2581 } |
|
2582 else |
|
2583 { |
|
2584 // only genre is not case sensitive |
|
2585 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2586 (aCategory != EMPXGenre)); |
|
2587 if (!aOldId || (aOldId != aItemId)) |
|
2588 { |
|
2589 TPtrC art(KNullDesC); |
|
2590 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
2591 { |
|
2592 art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
|
2593 } |
|
2594 |
|
2595 iObserver.AddCategoryItemL(aCategory, KNullDesC, aArtistId, art, aDriveId, |
|
2596 aItemChangedMessages, itemAdded); |
2631 aItemChangedMessages, itemAdded); |
2597 updated = ETrue; |
2632 updated = ETrue; |
2598 } |
2633 } |
2599 } |
2634 } |
2600 |
2635 |
2601 if (aOldId && (aOldId != aItemId)) |
2636 if (aOldId && (aOldId != aItemId)) |
2602 { |
2637 { |
2603 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
2638 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
2604 aItemChangedMessages, itemNotRemoved); |
2639 aItemChangedMessages, itemNotRemoved); |
2605 updated = ETrue; |
2640 updated = ETrue; |
2606 } |
2641 } |
2607 |
2642 |
2608 // Special case where the item(s) has been renamed. |
2643 // Special case where the item(s) has been renamed. |
2609 // In this case, a new category is created +1 change msg |
2644 // In this case, a new category is created +1 change msg |
2610 // a old category is removed +1 change msg |
2645 // a old category is removed +1 change msg |
2611 // We merge these 2 change messages into one using the deprecated ID |
2646 // We merge these 2 change messages into one using the deprecated ID |
2612 // |
2647 // |
2618 TInt oldId = KErrNotFound; |
2653 TInt oldId = KErrNotFound; |
2619 TInt newId = KErrNotFound; |
2654 TInt newId = KErrNotFound; |
2620 for( TInt i=0; i<newChangeMsgCount; ++i ) |
2655 for( TInt i=0; i<newChangeMsgCount; ++i ) |
2621 { |
2656 { |
2622 CMPXMessage& msg = *(*aItemChangedMessages)[i]; |
2657 CMPXMessage& msg = *(*aItemChangedMessages)[i]; |
2623 |
2658 |
2624 TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
2659 TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId); |
2625 TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
2660 TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType); |
2626 |
2661 |
2627 // Look for the added and deleted category IDs |
2662 // Look for the added and deleted category IDs |
2628 // |
2663 // |
2629 if( id == aOldId && changeType == EMPXItemDeleted ) |
2664 if( id == aOldId && changeType == EMPXItemDeleted ) |
2630 { |
2665 { |
2631 oldId = i; |
2666 oldId = i; |
2674 EMPXMediaGeneralType | |
2709 EMPXMediaGeneralType | |
2675 EMPXMediaGeneralCategory | |
2710 EMPXMediaGeneralCategory | |
2676 EMPXMediaGeneralTitle | |
2711 EMPXMediaGeneralTitle | |
2677 EMPXMediaGeneralUri | |
2712 EMPXMediaGeneralUri | |
2678 EMPXMediaGeneralFlags); |
2713 EMPXMediaGeneralFlags); |
2679 |
2714 |
2680 TBool extraRequired(EFalse); |
2715 TBool extraRequired(EFalse); |
2681 TInt count(aAttrs.Count()); |
2716 TInt count(aAttrs.Count()); |
2682 for (TInt i = 0; i < count; ++i) |
2717 for (TInt i = 0; i < count; ++i) |
2683 { |
2718 { |
2684 TUint attributeId(aAttrs[i].AttributeId()|defaultFields); |
2719 TUint attributeId(aAttrs[i].AttributeId()|defaultFields); |
2703 // ---------------------------------------------------------------------------------------------------------- |
2738 // ---------------------------------------------------------------------------------------------------------- |
2704 // |
2739 // |
2705 TBool CMPXDbMusic::IsSupported( |
2740 TBool CMPXDbMusic::IsSupported( |
2706 const CMPXMedia& aMedia) |
2741 const CMPXMedia& aMedia) |
2707 { |
2742 { |
2708 MPX_FUNC("CMPXDbMusic::IsSupported"); |
2743 MPX_FUNC("CMPXDbMusic::IsSupported"); |
2709 |
2744 |
2710 // this checklist should match the attributes processed in DoFillInDatabaseInfoL |
2745 // this checklist should match the attributes processed in DoFillInDatabaseInfoL |
2711 return aMedia.IsSupported(KMPXMediaGeneralTitle) || |
2746 return aMedia.IsSupported(KMPXMediaGeneralTitle) || |
2712 aMedia.IsSupported(KMPXMediaGeneralUri) || |
2747 aMedia.IsSupported(KMPXMediaGeneralUri) || |
2713 aMedia.IsSupported(KMPXMediaGeneralComment) || |
2748 aMedia.IsSupported(KMPXMediaGeneralComment) || |