harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp
branchRCL_3
changeset 19 b73252188534
parent 13 4a4892eec172
equal deleted inserted replaced
18:63c982fb92f2 19:b73252188534
    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
   117 CHarvesterAudioPlugin::~CHarvesterAudioPlugin()
   120 CHarvesterAudioPlugin::~CHarvesterAudioPlugin()
   118 	{
   121 	{
   119 	WRITELOG( "CHarvesterAudioPlugin::~CHarvesterAudioPlugin()" );
   122 	WRITELOG( "CHarvesterAudioPlugin::~CHarvesterAudioPlugin()" );
   120 	
   123 	
   121 	delete iAudioParser;
   124 	delete iAudioParser;
       
   125 	iAudioParser = NULL;
   122 	delete iPropDefs;
   126 	delete iPropDefs;
       
   127 	iPropDefs = NULL;
   123 	delete iTNM;
   128 	delete iTNM;
       
   129 	iTNM = NULL;
   124 	
   130 	
   125 	delete iPhoneSoundsPath;
   131 	delete iPhoneSoundsPath;
       
   132 	iPhoneSoundsPath = NULL;
   126 	delete iMmcSoundsPath;
   133 	delete iMmcSoundsPath;
       
   134 	iMmcSoundsPath = NULL;
   127 	}
   135 	}
   128 
   136 
   129 // ---------------------------------------------------------------------------
   137 // ---------------------------------------------------------------------------
   130 // CHarvesterAudioPlugin::ConstructL
   138 // CHarvesterAudioPlugin::ConstructL
   131 // ---------------------------------------------------------------------------
   139 // ---------------------------------------------------------------------------
   143     
   151     
   144     if( iHarvestAlbumArt )
   152     if( iHarvestAlbumArt )
   145         {
   153         {
   146         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   154         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   147         }
   155         }
       
   156 		
       
   157     iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL();
   148     
   158     
   149     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
   159     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
   150 	
   160 	
   151     TFileName sounds = PathInfo::SoundsPath();
   161     TFileName sounds = PathInfo::SoundsPath();
   152     
   162     
   287         }
   297         }
   288     
   298     
   289     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   299     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   290     TTime localModifiedDate = entry.iModified + timeOffsetSeconds;
   300     TTime localModifiedDate = entry.iModified + timeOffsetSeconds;
   291 	
   301 	
   292 	if( !iPropDefs )
   302 	InitPropDefsL( mdeObject.Def() );
   293 		{
       
   294 		CMdEObjectDef& objectDef = mdeObject.Def();
       
   295 		iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( objectDef );
       
   296 		// Prefetch max text lengt for validity checking
       
   297 		iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   298 		}
       
   299 	
   303 	
   300 	CMdeObjectWrapper::HandleObjectPropertyL(
   304 	CMdeObjectWrapper::HandleObjectPropertyL(
   301                  mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd );
   305                  mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd );
   302 
   306 
   303 	CMdeObjectWrapper::HandleObjectPropertyL(
   307 	CMdeObjectWrapper::HandleObjectPropertyL(
   322     const TMimeTypeMapping<TAudioMetadataHandling>* mapping = 
   326     const TMimeTypeMapping<TAudioMetadataHandling>* mapping = 
   323     	iAudioParser->ParseMimeType( mdeObject.Uri() );
   327     	iAudioParser->ParseMimeType( mdeObject.Uri() );
   324     
   328     
   325     if ( mapping && !mdeObject.Placeholder() )
   329     if ( mapping && !mdeObject.Placeholder() )
   326         {
   330         {
   327     	if( !iPropDefs )
   331         InitPropDefsL( mdeObject.Def() );
   328     		{
       
   329     		CMdEObjectDef& objectDef = mdeObject.Def();
       
   330     		iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( objectDef );
       
   331     		// Prefetch max text lengt for validity checking
       
   332     		iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   333     		}
       
   334         
   332         
   335     	CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   333     	CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   336     			*iPropDefs->iItemTypePropertyDef, (TAny*)&(mapping->iMimeType), aIsAdd );
   334     			*iPropDefs->iItemTypePropertyDef, (TAny*)&(mapping->iMimeType), aIsAdd );
   337         }
   335         }
   338     
   336     
   354 #endif
   352 #endif
   355     
   353     
   356     CMdEObject& mdeObject = aHD->MdeObject();
   354     CMdEObject& mdeObject = aHD->MdeObject();
   357     const TDesC& uri = mdeObject.Uri();
   355     const TDesC& uri = mdeObject.Uri();
   358  
   356  
   359     if( !iPropDefs )
   357     InitPropDefsL( mdeObject.Def() );
   360         {
       
   361         CMdEObjectDef& audioObjectDef = mdeObject.Def();
       
   362         iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef );
       
   363         // Prefetch max text lengt for validity checking
       
   364         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   365         }
       
   366 
   358 
   367     TBool possiblyProtectedContent( EFalse );
   359     TBool possiblyProtectedContent( EFalse );
   368     if( aMimeType.Length() > 0 )
   360     if( aMimeType.Length() > 0 )
   369         {
   361         {
   370         if( aMimeType == KMimeTypeWma )
   362         if( aMimeType == KMimeTypeWma )
   534         CThumbnailObjectSource* tnmSource = CThumbnailObjectSource::NewL( jpegBuf, mimeType, uri );
   526         CThumbnailObjectSource* tnmSource = CThumbnailObjectSource::NewL( jpegBuf, mimeType, uri );
   535         // Ownership of buffer is transferred to Thumbnail Manager
   527         // Ownership of buffer is transferred to Thumbnail Manager
   536         CleanupStack::Pop(); // jpegBuf
   528         CleanupStack::Pop(); // jpegBuf
   537         iTNM->CreateThumbnails( *tnmSource );
   529         iTNM->CreateThumbnails( *tnmSource );
   538         delete tnmSource;
   530         delete tnmSource;
       
   531         tnmSource = NULL;
   539         TBool thumbnailPresent( ETrue );
   532         TBool thumbnailPresent( ETrue );
   540         CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   533         CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   541                           *iPropDefs->iThumbnailPropertyDef, &thumbnailPresent, aIsAdd );
   534                           *iPropDefs->iThumbnailPropertyDef, &thumbnailPresent, aIsAdd );
   542         }
   535         }
   543     else if( iHarvestAlbumArt && iTNM )
   536     else if( iHarvestAlbumArt && iTNM )
   553     dStop.UniversalTime();
   546     dStop.UniversalTime();
   554     WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
   547     WRITELOG1( "CHarvesterAudioPlugin::GetMusicPropertiesL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
   555 #endif   
   548 #endif   
   556     }
   549     }
   557 
   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 
   558 // End of file
   561 // End of file
   559 
   562