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