harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp
changeset 43 c5e73110f733
parent 40 910a23996aa0
child 60 79f826a55db2
equal deleted inserted replaced
40:910a23996aa0 43:c5e73110f733
    35 
    35 
    36 const TInt KMimeLength( 10 );
    36 const TInt KMimeLength( 10 );
    37 const TUid KHarvesterRepoUid = { 0x200009FE };
    37 const TUid KHarvesterRepoUid = { 0x200009FE };
    38 const TUint32 KEnableAlbumArtHarvest = 0x00090001;
    38 const TUint32 KEnableAlbumArtHarvest = 0x00090001;
    39 
    39 
    40 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase()
    40 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase(),
       
    41     iCreationDatePropertyDef( NULL )
    41 	{
    42 	{
    42 	}
    43 	}
    43 
    44 
    44 void CHarvesterAudioPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    45 void CHarvesterAudioPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    45 	{
    46 	{
    46 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    47     SetByObjectDefL( aObjectDef );
    47 
    48 	}
    48 	// Common property definitions
    49 
    49 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    50 CHarvesterAudioPluginPropertyDefs* CHarvesterAudioPluginPropertyDefs::NewL()
    50 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
    51     {
    51 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    52     CHarvesterAudioPluginPropertyDefs* self = 
    52 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    53         new (ELeave) CHarvesterAudioPluginPropertyDefs();
    53 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    54     return self;
    54 	iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
    55     }
       
    56 
       
    57 void CHarvesterAudioPluginPropertyDefs::SetByObjectDefL(CMdEObjectDef& aObjectDef)
       
    58     {
       
    59     CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
       
    60 
       
    61     // Common property definitions
       
    62     CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
       
    63     iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
       
    64     iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
       
    65     iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
       
    66     iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
       
    67     iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
    55     iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTimeOffsetProperty );
    68     iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTimeOffsetProperty );
    56     iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KInDefaultFolder );
    69     iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KInDefaultFolder );
    57 
    70 
    58 	// Media property definitions
    71     // Media property definitions
    59 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    72     CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    60 	iRatingPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KRatingProperty );
    73     iRatingPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KRatingProperty );
    61 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    74     iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    62 	iArtistPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KArtistProperty );
    75     iArtistPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KArtistProperty );
    63 	iDurationPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDurationProperty );
    76     iDurationPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDurationProperty );
    64 	iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KCopyrightProperty );
    77     iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KCopyrightProperty );
    65 	iTrackPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KTrackProperty );
    78     iTrackPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KTrackProperty );
    66 	iThumbnailPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KThumbnailPresentProperty );
    79     iThumbnailPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KThumbnailPresentProperty );
    67 	iDatePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KReleaseDateProperty );
    80     iDatePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KReleaseDateProperty );
    68     iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty );
    81     iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty );
    69 
    82 
    70 	// Audio property definitions
    83     // Audio property definitions
    71 	CMdEObjectDef& audioDef = nsDef.GetObjectDefL( MdeConstants::Audio::KAudioObject );
    84     CMdEObjectDef& audioDef = nsDef.GetObjectDefL( MdeConstants::Audio::KAudioObject );
    72 	iAlbumPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty );
    85     iAlbumPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty );
    73 	iComposerPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty );
    86     iComposerPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty );
    74 	iOriginalArtistPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KOriginalArtistProperty );
    87     iOriginalArtistPropertyDef = &audioDef.GetPropertyDefL( MdeConstants::Audio::KOriginalArtistProperty );
    75 	}
    88     }
    76 
       
    77 CHarvesterAudioPluginPropertyDefs* CHarvesterAudioPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
       
    78 	{
       
    79 	CHarvesterAudioPluginPropertyDefs* self = 
       
    80 		new (ELeave) CHarvesterAudioPluginPropertyDefs();
       
    81 	CleanupStack::PushL( self );
       
    82 	self->ConstructL( aObjectDef );
       
    83 	CleanupStack::Pop( self );
       
    84 	return self;
       
    85 	}
       
    86 
    89 
    87 using namespace MdeConstants;
    90 using namespace MdeConstants;
    88 
    91 
    89 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    90 // CHarvesterAudioPlugin::CHarvesterAudioPlugin
    93 // CHarvesterAudioPlugin::CHarvesterAudioPlugin
   148     
   151     
   149     if( iHarvestAlbumArt )
   152     if( iHarvestAlbumArt )
   150         {
   153         {
   151         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   154         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   152         }
   155         }
       
   156 		
       
   157     iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL();
   153     
   158     
   154     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
   159     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
   155 	
   160 	
   156     TFileName sounds = PathInfo::SoundsPath();
   161     TFileName sounds = PathInfo::SoundsPath();
   157     
   162     
   292         }
   297         }
   293     
   298     
   294     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   299     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   295     TTime localModifiedDate = entry.iModified + timeOffsetSeconds;
   300     TTime localModifiedDate = entry.iModified + timeOffsetSeconds;
   296 	
   301 	
   297 	if( !iPropDefs )
   302 	InitPropDefsL( mdeObject.Def() );
   298 		{
       
   299 		CMdEObjectDef& objectDef = mdeObject.Def();
       
   300 		iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( objectDef );
       
   301 		// Prefetch max text lengt for validity checking
       
   302 		iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   303 		}
       
   304 	
   303 	
   305 	CMdeObjectWrapper::HandleObjectPropertyL(
   304 	CMdeObjectWrapper::HandleObjectPropertyL(
   306                  mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd );
   305                  mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd );
   307 
   306 
   308 	CMdeObjectWrapper::HandleObjectPropertyL(
   307 	CMdeObjectWrapper::HandleObjectPropertyL(
   327     const TMimeTypeMapping<TAudioMetadataHandling>* mapping = 
   326     const TMimeTypeMapping<TAudioMetadataHandling>* mapping = 
   328     	iAudioParser->ParseMimeType( mdeObject.Uri() );
   327     	iAudioParser->ParseMimeType( mdeObject.Uri() );
   329     
   328     
   330     if ( mapping && !mdeObject.Placeholder() )
   329     if ( mapping && !mdeObject.Placeholder() )
   331         {
   330         {
   332     	if( !iPropDefs )
   331         InitPropDefsL( mdeObject.Def() );
   333     		{
       
   334     		CMdEObjectDef& objectDef = mdeObject.Def();
       
   335     		iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( objectDef );
       
   336     		// Prefetch max text lengt for validity checking
       
   337     		iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   338     		}
       
   339         
   332         
   340     	CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   333     	CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   341     			*iPropDefs->iItemTypePropertyDef, (TAny*)&(mapping->iMimeType), aIsAdd );
   334     			*iPropDefs->iItemTypePropertyDef, (TAny*)&(mapping->iMimeType), aIsAdd );
   342         }
   335         }
   343     
   336     
   359 #endif
   352 #endif
   360     
   353     
   361     CMdEObject& mdeObject = aHD->MdeObject();
   354     CMdEObject& mdeObject = aHD->MdeObject();
   362     const TDesC& uri = mdeObject.Uri();
   355     const TDesC& uri = mdeObject.Uri();
   363  
   356  
   364     if( !iPropDefs )
   357     InitPropDefsL( mdeObject.Def() );
   365         {
       
   366         CMdEObjectDef& audioObjectDef = mdeObject.Def();
       
   367         iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef );
       
   368         // Prefetch max text lengt for validity checking
       
   369         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   370         }
       
   371 
   358 
   372     TBool possiblyProtectedContent( EFalse );
   359     TBool possiblyProtectedContent( EFalse );
   373     if( aMimeType.Length() > 0 )
   360     if( aMimeType.Length() > 0 )
   374         {
   361         {
   375         if( aMimeType == KMimeTypeWma )
   362         if( aMimeType == KMimeTypeWma )
   559     dStop.UniversalTime();
   546     dStop.UniversalTime();
   560     WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
   547     WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
   561 #endif   
   548 #endif   
   562     }
   549     }
   563 
   550 
       
   551 void CHarvesterAudioPlugin::InitPropDefsL(CMdEObjectDef& aObjectDef)
       
   552     {
       
   553     if( !iPropDefs->iCreationDatePropertyDef )
       
   554         {
       
   555         iPropDefs->SetByObjectDefL( aObjectDef );
       
   556         // Prefetch max text lengt for validity checking
       
   557         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   558         }
       
   559     }
       
   560 
   564 // End of file
   561 // End of file
   565 
   562