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