harvester/harvesterplugins/AudioPlugin/src/harvesteraudioplugin.cpp
branchRCL_3
changeset 27 4a4892eec172
parent 26 9f21bab39f42
child 47 b73252188534
equal deleted inserted replaced
26:9f21bab39f42 27:4a4892eec172
    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 #include <caf/caf.h>
       
    26 #include <pathinfo.h>
    26 
    27 
    27 #include "harvestercommon.h"
    28 #include "harvestercommon.h"
    28 #include "harvesteraudioplugin.h"
    29 #include "harvesteraudioplugin.h"
    29 #include "harvesteraudiopluginutils.h"
    30 #include "harvesteraudiopluginutils.h"
    30 #include "mdsutils.h"
    31 #include "mdsutils.h"
    33 #include "harvesterlog.h"
    34 #include "harvesterlog.h"
    34 
    35 
    35 const TInt KMimeLength( 10 );
    36 const TInt KMimeLength( 10 );
    36 const TUid KHarvesterRepoUid = { 0x200009FE };
    37 const TUid KHarvesterRepoUid = { 0x200009FE };
    37 const TUint32 KEnableAlbumArtHarvest = 0x00090001;
    38 const TUint32 KEnableAlbumArtHarvest = 0x00090001;
    38 
       
    39 _LIT( KExtensionWma,    "wma" );
       
    40 
    39 
    41 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase()
    40 CHarvesterAudioPluginPropertyDefs::CHarvesterAudioPluginPropertyDefs() : CBase()
    42 	{
    41 	{
    43 	}
    42 	}
    44 
    43 
    52 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    51 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    53 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    52 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    54 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    53 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    55 	iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
    54 	iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
    56     iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTimeOffsetProperty );
    55     iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTimeOffsetProperty );
       
    56     iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KInDefaultFolder );
    57 
    57 
    58 	// Media property definitions
    58 	// Media property definitions
    59 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    59 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    60 	iRatingPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KRatingProperty );
    60 	iRatingPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KRatingProperty );
    61 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    61 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
   119 	WRITELOG( "CHarvesterAudioPlugin::~CHarvesterAudioPlugin()" );
   119 	WRITELOG( "CHarvesterAudioPlugin::~CHarvesterAudioPlugin()" );
   120 	
   120 	
   121 	delete iAudioParser;
   121 	delete iAudioParser;
   122 	delete iPropDefs;
   122 	delete iPropDefs;
   123 	delete iTNM;
   123 	delete iTNM;
       
   124 	
       
   125 	delete iPhoneSoundsPath;
       
   126 	delete iMmcSoundsPath;
   124 	}
   127 	}
   125 
   128 
   126 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   127 // CHarvesterAudioPlugin::ConstructL
   130 // CHarvesterAudioPlugin::ConstructL
   128 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   142         {
   145         {
   143         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   146         TRAP_IGNORE( iTNM = CThumbnailManager::NewL( *this ) );
   144         }
   147         }
   145     
   148     
   146     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
   149     SetPriority( KHarvesterPriorityHarvestingPlugin - 2 );
       
   150 	
       
   151     TFileName sounds = PathInfo::SoundsPath();
       
   152     
       
   153     TFileName phonePath = PathInfo::PhoneMemoryRootPath();
       
   154     phonePath.Append( sounds );
       
   155     iPhoneSoundsPath = phonePath.AllocL();
       
   156 
       
   157     TFileName mmcPath = PathInfo::MemoryCardRootPath();
       
   158     mmcPath.Append( sounds );
       
   159     iMmcSoundsPath = mmcPath.Right( mmcPath.Length() - 1 ).AllocL();
   147 	}
   160 	}
   148 
   161 
   149 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   150 // CHarvesterAudioPlugin::HarvestL (from CHarvesterPlugin)
   163 // CHarvesterAudioPlugin::HarvestL (from CHarvesterPlugin)
   151 // ---------------------------------------------------------------------------
   164 // ---------------------------------------------------------------------------
   246     if( mapping )
   259     if( mapping )
   247     	{
   260     	{
   248 		// get properties for file types supported by CMetaDataUtility.
   261 		// get properties for file types supported by CMetaDataUtility.
   249     	if( mapping->iHandler == EMetaDataUtilityHandling )
   262     	if( mapping->iHandler == EMetaDataUtilityHandling )
   250     		{
   263     		{
   251     		GetMusicPropertiesL( aHD, aIsAdd );
   264     		GetMusicPropertiesL( aHD, aIsAdd, mapping->iMimeType );
   252     		}
   265     		}
   253     	}
   266     	}
   254     }
   267     }
   255 
   268 
   256 // ---------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   329 // ---------------------------------------------------------------------------
   342 // ---------------------------------------------------------------------------
   330 // CHarvesterAudioPlugin::GetMusicPropertiesL
   343 // CHarvesterAudioPlugin::GetMusicPropertiesL
   331 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   332 //    
   345 //    
   333 void CHarvesterAudioPlugin::GetMusicPropertiesL( CHarvesterData* aHD,
   346 void CHarvesterAudioPlugin::GetMusicPropertiesL( CHarvesterData* aHD,
   334                                       TBool aIsAdd )
   347                                       TBool aIsAdd, TPtrC aMimeType )
   335     {
   348     {
   336 #ifdef _DEBUG
   349 #ifdef _DEBUG
   337     TTime dStart, dStop;
   350     TTime dStart, dStop;
   338     dStart.UniversalTime();
   351     dStart.UniversalTime();
   339     dStop.UniversalTime();
   352     dStop.UniversalTime();
   348         CMdEObjectDef& audioObjectDef = mdeObject.Def();
   361         CMdEObjectDef& audioObjectDef = mdeObject.Def();
   349         iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef );
   362         iPropDefs = CHarvesterAudioPluginPropertyDefs::NewL( audioObjectDef );
   350         // Prefetch max text lengt for validity checking
   363         // Prefetch max text lengt for validity checking
   351         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
   364         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
   352         }
   365         }
   353     
   366 
   354     TPtrC ext;
   367     TBool possiblyProtectedContent( EFalse );
   355     MdsUtils::GetExt( uri, ext );
   368     if( aMimeType.Length() > 0 )
   356     
   369         {
   357     // Check for possibly protected content
   370         if( aMimeType == KMimeTypeWma )
   358     if( ext.CompareF( KExtensionWma ) == 0 )
   371             {
       
   372             possiblyProtectedContent = ETrue;
       
   373             }
       
   374         }
       
   375 
       
   376     if( possiblyProtectedContent )
   359         {
   377         {
   360         ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
   378         ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
   361         ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   379         ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   362         
   380         
   363         TBool protectedContent( EFalse );
   381         TBool protectedContent( EFalse );
   367             CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   385             CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   368                     *iPropDefs->iDrmPropertyDef, &protectedContent, aIsAdd );
   386                     *iPropDefs->iDrmPropertyDef, &protectedContent, aIsAdd );
   369             }
   387             }
   370         CleanupStack::PopAndDestroy( 2 ); // content, data
   388         CleanupStack::PopAndDestroy( 2 ); // content, data
   371         }
   389         }
   372     
   390 
   373     TBool parsed( EFalse );
   391     TBool parsed( EFalse );
   374     TRAPD( parseError, parsed = iAudioParser->ParseL( uri ) );
   392     TRAPD( parseError, parsed = iAudioParser->ParseL( uri ) );
   375 
   393 
   376     if( !parsed || (parseError != KErrNone) )
   394     if( !parsed || (parseError != KErrNone) )
   377     	{
   395     	{
   396  
   414  
   397     // Time offset
   415     // Time offset
   398     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   416     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   399     TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   417     TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   400     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
   418     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
   401 	
   419     
       
   420     if( !mdeObject.Placeholder() )
       
   421         {
       
   422         if( uri.FindF( iMmcSoundsPath->Des()) != KErrNotFound ||
       
   423             uri.FindF( iPhoneSoundsPath->Des()) != KErrNotFound )
       
   424             {
       
   425             TBool inDefaultFolder( ETrue );
       
   426             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );
       
   427             }
       
   428         else
       
   429             {
       
   430             TBool inDefaultFolder( EFalse );
       
   431             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );    
       
   432             }
       
   433         }
       
   434     
   402     if ( song.Length() > 0
   435     if ( song.Length() > 0
   403         && song.Length() < KMaxTitleFieldLength )
   436         && song.Length() < KMaxTitleFieldLength )
   404         {    
   437         {    
   405         CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   438         CMdeObjectWrapper::HandleObjectPropertyL( mdeObject, 
   406         		*iPropDefs->iTitlePropertyDef, &song, EFalse );
   439         		*iPropDefs->iTitlePropertyDef, &song, EFalse );