harvester/harvesterplugins/WMVPlugin/src/harvesterwmvplugin.cpp
branchRCL_3
changeset 8 50de4d668bb6
parent 7 3cebc1a84278
child 9 82c0024438c8
equal deleted inserted replaced
7:3cebc1a84278 8:50de4d668bb6
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Harvests metadata from wmv video file 
    14 * Description:  Harvests metadata from wm video file 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <e32std.h>
    18 #include <e32std.h>
    19 #include <caf/content.h>
    19 #include <caf/caf.h>
    20 
    20 
    21 #include "mdsutils.h"
    21 #include "mdsutils.h"
    22 #include "harvesterdata.h"
    22 #include "harvesterdata.h"
    23 #include "harvesterlog.h"
    23 #include "harvesterlog.h"
    24 #include "harvestercommon.h"
    24 #include "harvestercommon.h"
    41 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    41 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    42 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
    42 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
    43 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    43 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    44 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    44 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    45 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    45 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
       
    46     iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
       
    47 	
       
    48     CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
       
    49     iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty );
       
    50     iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
       
    51     iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty );
       
    52     iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    46 	}
    53 	}
    47 
    54 
    48 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
    55 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
    49 	{
    56 	{
    50 	CHarvesterWmvPluginPropertyDefs* self = 
    57 	CHarvesterWmvPluginPropertyDefs* self = 
   167     {
   174     {
   168     WRITELOG( "CHarvesterWMVPlugin::GatherDataL()" );
   175     WRITELOG( "CHarvesterWMVPlugin::GatherDataL()" );
   169        
   176        
   170     const TDesC& uri = aMetadataObject.Uri();
   177     const TDesC& uri = aMetadataObject.Uri();
   171 
   178 
   172     TInt error ( KErrNone );
       
   173     TEntry* entry = new (ELeave) TEntry();
   179     TEntry* entry = new (ELeave) TEntry();
   174     CleanupStack::PushL( entry );
   180     CleanupStack::PushL( entry );
   175 
   181 
   176     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   182     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   177 
   183 
   179     aClipDetails.iFileSize = (TUint)entry->iSize;
   185     aClipDetails.iFileSize = (TUint)entry->iSize;
   180     
   186     
   181     CleanupStack::PopAndDestroy( entry );
   187     CleanupStack::PopAndDestroy( entry );
   182     
   188     
   183     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
   189     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
   184 
   190     ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   185     //Mime type check
   191    
   186     error = content->GetStringAttribute( ContentAccess::EMimeType, aClipDetails.iMimeType );
   192     ContentAccess::RStringAttributeSet attrSet;
   187     if (  error != KErrNone )
   193     CleanupClosePushL( attrSet );
   188         {
   194     
   189         WRITELOG( "CHarvesterWMVPlugin - Could not resolve mime type, leave!" );
   195     attrSet.AddL( ContentAccess::EDescription );
   190         User::Leave( KErrNotSupported );
   196     attrSet.AddL( ContentAccess::EMimeType );
   191         }
   197     attrSet.AddL( ContentAccess::ETitle );
   192 
   198     attrSet.AddL( ContentAccess::EAuthor );
   193     CleanupStack::PopAndDestroy( content );  
   199     attrSet.AddL( ContentAccess::EGenre );
       
   200 
       
   201     User::LeaveIfError( data->GetStringAttributeSet(attrSet) );
       
   202 
       
   203     TInt err = attrSet.GetValue( ContentAccess::EMimeType, aClipDetails.iMimeType );
       
   204     if ( err != KErrNone)
       
   205         {
       
   206         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting mimetype failed %d", err );
       
   207         }
       
   208         
       
   209     if ( aClipDetails.iMimeType.Length() <= 0 )
       
   210         {
       
   211         WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no mimetype" );
       
   212         }
       
   213     
       
   214     err = attrSet.GetValue( ContentAccess::EDescription, aClipDetails.iDescription );
       
   215     if ( err != KErrNone)
       
   216         {
       
   217         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting description failed %d", err );
       
   218         }
       
   219         
       
   220     if ( aClipDetails.iDescription.Length() <= 0 )
       
   221         {
       
   222         WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no description" );
       
   223         }
       
   224     
       
   225     err = attrSet.GetValue( ContentAccess::ETitle, aClipDetails.iTitle );
       
   226     if ( err != KErrNone)
       
   227         {
       
   228         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting title failed %d", err );
       
   229         }
       
   230         
       
   231     if ( aClipDetails.iTitle.Length() <= 0 )
       
   232         {
       
   233         WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no title" );
       
   234         }
       
   235     
       
   236     err = attrSet.GetValue( ContentAccess::EAuthor, aClipDetails.iAuthor );
       
   237     if ( err != KErrNone)
       
   238         {
       
   239         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting author failed %d", err );
       
   240         }
       
   241         
       
   242     if ( aClipDetails.iAuthor.Length() <= 0 )
       
   243         {
       
   244         WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no author" );
       
   245         }
       
   246 
       
   247     err = attrSet.GetValue( ContentAccess::EGenre, aClipDetails.iGenre );
       
   248     if ( err != KErrNone)
       
   249         {
       
   250         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting genre failed %d", err );
       
   251         }
       
   252         
       
   253     if ( aClipDetails.iGenre.Length() <= 0 )
       
   254         {
       
   255         WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no genre" );
       
   256         }
       
   257     
       
   258     err = content->GetAttribute( ContentAccess::EIsProtected, aClipDetails.iDrmProtected );
       
   259     if ( err != KErrNone)
       
   260         {
       
   261         WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
       
   262         }
       
   263         
       
   264     CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet
   194     }
   265     }
   195 
   266 
   196 // ---------------------------------------------------------------------------
   267 // ---------------------------------------------------------------------------
   197 // Handle object properties
   268 // Handle object properties
   198 // ---------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   227     			*iPropDefs->iSizePropertyDef, &aClipDetails.iFileSize, aIsAdd );
   298     			*iPropDefs->iSizePropertyDef, &aClipDetails.iFileSize, aIsAdd );
   228         // Mime Type
   299         // Mime Type
   229         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   300         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   230                 *iPropDefs->iItemTypePropertyDef, &aClipDetails.iMimeType, aIsAdd );
   301                 *iPropDefs->iItemTypePropertyDef, &aClipDetails.iMimeType, aIsAdd );
   231     	}
   302     	}
   232     }
   303     
   233 
   304     // DRM protection
       
   305     if( aClipDetails.iDrmProtected )
       
   306         {
       
   307         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
       
   308                 *iPropDefs->iDrmPropertyDef, &aClipDetails.iDrmProtected, aIsAdd );
       
   309         } 
       
   310     // Title (is set from URI by default)
       
   311     if(aClipDetails.iTitle.Length() > 0)
       
   312         {
       
   313         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
       
   314                 *iPropDefs->iTitlePropertyDef, &aClipDetails.iTitle, EFalse );
       
   315         }
       
   316     // Description
       
   317     if(aClipDetails.iDescription.Length() > 0)
       
   318         {
       
   319         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
       
   320                 *iPropDefs->iDescriptionPropertyDef, &aClipDetails.iDescription, aIsAdd );
       
   321         }   
       
   322     // Author
       
   323     if(aClipDetails.iAuthor.Length() > 0)
       
   324         {
       
   325         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
       
   326                 *iPropDefs->iAuthorPropertyDef, &aClipDetails.iAuthor, aIsAdd );
       
   327         }
       
   328     // Genre
       
   329     if(aClipDetails.iGenre.Length() > 0)
       
   330         {
       
   331         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
       
   332                 *iPropDefs->iGenrePropertyDef, &aClipDetails.iGenre, aIsAdd );
       
   333         }   
       
   334     }
       
   335