20 #include <harvesterdata.h> |
20 #include <harvesterdata.h> |
21 #include <mdenamespacedef.h> |
21 #include <mdenamespacedef.h> |
22 #include <mdeobjectdef.h> |
22 #include <mdeobjectdef.h> |
23 #include <mdeobject.h> |
23 #include <mdeobject.h> |
24 #include <centralrepository.h> |
24 #include <centralrepository.h> |
|
25 #include <caf/caf.h> |
25 |
26 |
26 #include "harvestercommon.h" |
27 #include "harvestercommon.h" |
27 #include "harvesteraudioplugin.h" |
28 #include "harvesteraudioplugin.h" |
28 #include "harvesteraudiopluginutils.h" |
29 #include "harvesteraudiopluginutils.h" |
29 #include "mdsutils.h" |
30 #include "mdsutils.h" |
31 #include "harvesterlog.h" |
32 #include "harvesterlog.h" |
32 |
33 |
33 const TInt KMimeLength( 10 ); |
34 const TInt KMimeLength( 10 ); |
34 const TUid KHarvesterRepoUid = { 0x200009FE }; |
35 const TUid KHarvesterRepoUid = { 0x200009FE }; |
35 const TUint32 KEnableAlbumArtHarvest = 0x00090001; |
36 const TUint32 KEnableAlbumArtHarvest = 0x00090001; |
|
37 |
|
38 _LIT( KExtensionWma, "wma" ); |
36 |
39 |
37 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase() |
40 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase() |
38 { |
41 { |
39 } |
42 } |
40 |
43 |
59 iDurationPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDurationProperty ); |
62 iDurationPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDurationProperty ); |
60 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KCopyrightProperty ); |
63 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KCopyrightProperty ); |
61 iTrackPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KTrackProperty ); |
64 iTrackPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KTrackProperty ); |
62 iThumbnailPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KThumbnailPresentProperty ); |
65 iThumbnailPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KThumbnailPresentProperty ); |
63 iDatePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KReleaseDateProperty ); |
66 iDatePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KReleaseDateProperty ); |
|
67 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty ); |
64 |
68 |
65 // Audio property definitions |
69 // Audio property definitions |
66 CMdEObjectDef& audioDef = nsDef.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
70 CMdEObjectDef& audioDef = nsDef.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
67 iAlbumPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty ); |
71 iAlbumPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty ); |
68 iComposerPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty ); |
72 iComposerPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty ); |
125 void CHarvesterAudioPlugin::ConstructL() |
129 void CHarvesterAudioPlugin::ConstructL() |
126 { |
130 { |
127 WRITELOG( "CHarvesterAudioPlugin::ConstructL()" ); |
131 WRITELOG( "CHarvesterAudioPlugin::ConstructL()" ); |
128 |
132 |
129 CRepository* rep = CRepository::NewLC( KHarvesterRepoUid ); |
133 CRepository* rep = CRepository::NewLC( KHarvesterRepoUid ); |
|
134 // If data could not be fetched, default to non-album art mode |
130 rep->Get( KEnableAlbumArtHarvest, iHarvestAlbumArt ); |
135 rep->Get( KEnableAlbumArtHarvest, iHarvestAlbumArt ); |
131 CleanupStack::PopAndDestroy( rep ); |
136 CleanupStack::PopAndDestroy( rep ); |
132 |
137 |
133 iAudioParser = CAudioMDParser::NewL( iHarvestAlbumArt ); |
138 iAudioParser = CAudioMDParser::NewL( iHarvestAlbumArt ); |
134 |
139 |
330 WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() ); |
335 WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() ); |
331 #endif |
336 #endif |
332 |
337 |
333 CMdEObject& mdeObject = aHD->MdeObject(); |
338 CMdEObject& mdeObject = aHD->MdeObject(); |
334 const TDesC& uri = mdeObject.Uri(); |
339 const TDesC& uri = mdeObject.Uri(); |
|
340 |
|
341 if( !iPropDefs ) |
|
342 { |
|
343 CMdEObjectDef& audioObjectDef = mdeObject.Def(); |
|
344 iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef ); |
|
345 } |
|
346 |
|
347 TPtrC ext; |
|
348 MdsUtils::GetExt( uri, ext ); |
|
349 |
|
350 // Check for possibly protected content |
|
351 if( ext.CompareF( KExtensionWma ) == 0 ) |
|
352 { |
|
353 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
|
354 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
|
355 |
|
356 TBool protectedContent( EFalse ); |
|
357 TInt err = data->GetAttribute( ContentAccess::EIsProtected, protectedContent ); |
|
358 if( err == KErrNone && protectedContent ) |
|
359 { |
|
360 CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, |
|
361 *iPropDefs->iDrmPropertyDef, &protectedContent, aIsAdd ); |
|
362 } |
|
363 CleanupStack::PopAndDestroy( 2 ); // content, data |
|
364 } |
335 |
365 |
336 TBool parsed( EFalse ); |
366 TBool parsed( EFalse ); |
337 TRAPD( parseError, parsed = iAudioParser->ParseL( uri ) ); |
367 TRAPD( parseError, parsed = iAudioParser->ParseL( uri ) ); |
338 |
368 |
339 if( !parsed || (parseError != KErrNone) ) |
369 if( !parsed || (parseError != KErrNone) ) |
350 TPtrC composer = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldComposer ); |
380 TPtrC composer = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldComposer ); |
351 TPtrC rating = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldRating ); |
381 TPtrC rating = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldRating ); |
352 TPtrC orgArtist = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldOriginalArtist ); |
382 TPtrC orgArtist = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldOriginalArtist ); |
353 TPtrC track = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldTrack ); |
383 TPtrC track = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldTrack ); |
354 TPtrC duration = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldDuration ); |
384 TPtrC duration = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldDuration ); |
355 TPtrC copyright = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldCopyright); |
385 TPtrC copyright = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldCopyright ); |
356 TPtrC date = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldDate ); |
386 TPtrC date = iAudioParser->MetaDataFieldL( CAudioMDParser::EAudioMDFieldDate ); |
357 |
387 |
358 TPtrC8 jpeg = iAudioParser->MetaDataField8L( CAudioMDParser::EAudioMDFieldJpeg ); |
388 TPtrC8 jpeg = iAudioParser->MetaDataField8L( CAudioMDParser::EAudioMDFieldJpeg ); |
359 |
|
360 if( !iPropDefs ) |
|
361 { |
|
362 CMdEObjectDef& audioObjectDef = mdeObject.Def(); |
|
363 iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef ); |
|
364 } |
|
365 |
389 |
366 // Time offset |
390 // Time offset |
367 TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset(); |
391 TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset(); |
368 TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60; |
392 TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60; |
369 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd ); |
393 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd ); |