mmappcomponents/harvester/metadataextractor/src/mpxmetadataextractor.cpp
branchRCL_3
changeset 24 6c1dfe4da5dd
parent 23 e42293e811d8
child 25 63223d4fd956
equal deleted inserted replaced
23:e42293e811d8 24:6c1dfe4da5dd
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Extracts metadata from a file
    14 * Description:  Extracts metadata from a file
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.15 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.5.3.8 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <badesca.h>
    20 #include <badesca.h>
    50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" );
    50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" );
    51 
    51 
    52 #ifdef RD_MPX_TNM_INTEGRATION
    52 #ifdef RD_MPX_TNM_INTEGRATION
    53 _LIT( KImageFileType, "image/jpeg" );
    53 _LIT( KImageFileType, "image/jpeg" );
    54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds
    54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds
    55 const TInt KMPXMaxThumbnailRequest = 2; 
    55 const TInt KMPXMaxThumbnailRequest = 2;
    56 #endif //RD_MPX_TNM_INTEGRATION
    56 #endif //RD_MPX_TNM_INTEGRATION
    57 
    57 
    58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
    58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
    59 _LIT( KNonEmbeddedArtExt, ".alb" );
    59 _LIT( KNonEmbeddedArtExt, ".alb" );
    60 #endif
    60 #endif
   184     iFileOpenError = KErrNone;
   184     iFileOpenError = KErrNone;
   185     iObs = NULL;
   185     iObs = NULL;
   186     aNewProperty = NULL;
   186     aNewProperty = NULL;
   187     iFileName = aFile;
   187     iFileName = aFile;
   188     iMetadataOnly = aMetadataOnly;
   188     iMetadataOnly = aMetadataOnly;
   189     
   189 
   190     // populate the task array
   190     // populate the task array
   191     AddTasksL();
   191     AddTasksL();
   192     
   192 
   193     // execute all tasks in the array
   193     // execute all tasks in the array
   194     while ( iArrayTasks.Count() )
   194     while ( iArrayTasks.Count() )
   195         {
   195         {
   196         // execute task at index 0
   196         // execute task at index 0
   197         MPX_TRAPD( error, ExecuteTaskL() );
   197         MPX_TRAPD( error, ExecuteTaskL() );
   209                 CleanUp();
   209                 CleanUp();
   210                 User::LeaveIfError( error );
   210                 User::LeaveIfError( error );
   211                 }
   211                 }
   212             break;
   212             break;
   213             }
   213             }
   214         
   214 
   215         iArrayTasks.Remove( 0 );
   215         iArrayTasks.Remove( 0 );
   216         }
   216         }
   217     
   217 
   218     aNewProperty = iMedia;
   218     aNewProperty = iMedia;
   219     iMedia = NULL;  // ownership transferred.
   219     iMedia = NULL;  // ownership transferred.
   220     CleanUp();
   220     CleanUp();
   221     }
   221     }
   222 
   222 
   234     aMediaProp.SetTextValueL( KMPXMediaMusicArtist,
   234     aMediaProp.SetTextValueL( KMPXMediaMusicArtist,
   235                               KNullDesC );
   235                               KNullDesC );
   236     // Album
   236     // Album
   237     aMediaProp.SetTextValueL( KMPXMediaMusicAlbum,
   237     aMediaProp.SetTextValueL( KMPXMediaMusicAlbum,
   238                               KNullDesC );
   238                               KNullDesC );
   239     // Year
       
   240     aMediaProp.SetTObjectValueL<TInt64>( KMPXMediaMusicYear,
       
   241                                          (TInt64) 0 );
       
   242     // Track
   239     // Track
   243     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumTrack,
   240     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumTrack,
   244                               KNullDesC );
   241                               KNullDesC );
   245     // Genre
   242     // Genre
   246     aMediaProp.SetTextValueL( KMPXMediaMusicGenre,
   243     aMediaProp.SetTextValueL( KMPXMediaMusicGenre,
   252     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   249     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   253                               KNullDesC );
   250                               KNullDesC );
   254     // URL
   251     // URL
   255     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   252     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   256                               KNullDesC );
   253                               KNullDesC );
       
   254     // AlbumArtist
       
   255     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtist,
       
   256                               KNullDesC );
       
   257     
   257     }
   258     }
   258 
   259 
   259 // ---------------------------------------------------------------------------
   260 // ---------------------------------------------------------------------------
   260 // Sets media object attributes from metadata utilities
   261 // Sets media object attributes from metadata utilities
   261 // ---------------------------------------------------------------------------
   262 // ---------------------------------------------------------------------------
   265     MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()");
   266     MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()");
   266 
   267 
   267     const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   268     const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   268     HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
   269     HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
   269     mimeType8->Des().Append( mimeType );
   270     mimeType8->Des().Append( mimeType );
   270     
   271 
   271     // Continue to extract metadata even if fail.
   272     // Continue to extract metadata even if fail.
   272     MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) );
   273     MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) );
   273     CleanupStack::PopAndDestroy( mimeType8 );
   274     CleanupStack::PopAndDestroy( mimeType8 );
   274     
   275 
   275     // Get MetadataUtility Container
   276     // Get MetadataUtility Container
   276     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   277     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   277 
   278 
   278     // Get DRM data
   279     // Get DRM data
   279     // Need the protected flag from metadataUtility Container
   280     // Need the protected flag from metadataUtility Container
   280     MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) );
   281     MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) );
   281     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data", 
   282     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data",
   282             drmerror );
   283             drmerror );
   283         
   284 
   284     // Get metadata fields
   285     // Get metadata fields
   285     TInt count( metaCont.Count() );
   286     TInt count( metaCont.Count() );
   286     for( TInt i=0; i<count; ++i )
   287     for( TInt i=0; i<count; ++i )
   287         {
   288         {
   288         TMetaDataFieldId fieldType;
   289         TMetaDataFieldId fieldType;
   289 
   290 
   290         HBufC* value = NULL;
   291         HBufC* value = NULL;
   291         metaCont.FieldIdAt( i, fieldType );  // get the field type
   292         metaCont.FieldIdAt( i, fieldType );  // get the field type
   292         
   293 
   293         // get the value, except for album art
   294         // get the value, except for album art
   294         if ( fieldType != EMetaDataJpeg )
   295         if ( fieldType != EMetaDataJpeg )
   295            {
   296            {
   296             MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() );
   297             MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() );
   297            if ( KErrNone != err )
   298            if ( KErrNone != err )
   298                {
   299                {
   299                MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err);           
   300                MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err);
   300                continue;
   301                continue;
   301                }     
   302                }
   302            CleanupStack::PushL( value );
   303            CleanupStack::PushL( value );
   303            }
   304            }
   304         
   305 
   305         switch( fieldType )
   306         switch( fieldType )
   306             {
   307             {
   307             case EMetaDataSongTitle:
   308             case EMetaDataSongTitle:
   308                 {
   309                 {
   309                 TPtr valptr = value->Des();
   310                 TPtr valptr = value->Des();
   407                 {
   408                 {
   408                 iMedia->SetTextValueL( KMPXMediaGeneralCopyright,
   409                 iMedia->SetTextValueL( KMPXMediaGeneralCopyright,
   409                                       *value );
   410                                       *value );
   410                 break;
   411                 break;
   411                 }
   412                 }
   412             case EMetaDataDuration:     
   413             case EMetaDataDuration:
   413                 {                  
   414                 {
   414                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   415                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   415                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   416                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   416                 
   417 
   417                 // Verify if WMA, get the duration
   418                 // Verify if WMA, get the duration
   418                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   419                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   419                     {
   420                     {
   420                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   421                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   421 
   422 
   422                     // Perform the duration conversion
   423                     // Perform the duration conversion
   423                     TLex lexer( *value );
   424                     TLex lexer( *value );
   424                     TInt32 duration ( 0 );
   425                     TInt32 duration ( 0 );
   425                     lexer.Val( duration );   // [second]      
   426                     lexer.Val( duration );   // [second]
   426                     duration *= 1000;        // [msec]
   427                     duration *= 1000;        // [msec]
   427                 
   428 
   428                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   429                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   429                                                 duration );      
   430                                                 duration );
   430                 
   431 
   431                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);  
   432                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);
   432                     }
   433                     }
   433                 break;
   434                 break;
   434                 }
   435                 }
   435             case EMetaDataSampleRate:     
   436             case EMetaDataSampleRate:
   436                 {                  
   437                 {
   437                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   438                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   438                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   439                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   439                 
   440 
   440                 // Verify if WMA, get the sample rate
   441                 // Verify if WMA, get the sample rate
   441                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   442                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   442                     {
   443                     {
   443                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   444                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   444 
   445 
   445                     // Perform the sample rate conversion
   446                     // Perform the sample rate conversion
   446                     TLex lexer( *value );
   447                     TLex lexer( *value );
   447                     TInt32 sampleRate ( 0 );
   448                     TInt32 sampleRate ( 0 );
   448                     lexer.Val( sampleRate );         
   449                     lexer.Val( sampleRate );
   449                     
   450 
   450                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   451                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   451                                                       sampleRate );
   452                                                       sampleRate );
   452                            
   453 
   453                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate);  
   454                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate);
   454                     }
   455                     }
   455                 break;
   456                 break;
   456                 }
   457                 }
   457             case EMetaDataBitRate:     
   458             case EMetaDataBitRate:
   458                 {                  
   459                 {
   459                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   460                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   460                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   461                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   461                 
   462 
   462                 // Verify if WMA, get the duration
   463                 // Verify if WMA, get the duration
   463                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   464                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   464                     {
   465                     {
   465                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   466                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   466 
   467 
   467                     // Perform the duration conversion
   468                     // Perform the duration conversion
   468                     TLex lexer( *value );
   469                     TLex lexer( *value );
   469                     TInt32 bitRate ( 0 );
   470                     TInt32 bitRate ( 0 );
   470                     lexer.Val( bitRate );   
   471                     lexer.Val( bitRate );
   471                 
   472 
   472                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   473                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   473                                                      bitRate );
   474                                                      bitRate );
   474                 
   475 
   475                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);  
   476                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);
       
   477                     }
       
   478                 break;
       
   479                 }
       
   480             case EMetaDataAlbumArtist:
       
   481                 {
       
   482                 TPtr valptr = value->Des();
       
   483                 valptr.Trim();
       
   484                 TInt vallen = value->Length();
       
   485                 if (vallen>0)
       
   486                     {
       
   487                     FindAndReplaceForbiddenChars(valptr, vallen);
       
   488                     iMedia->SetTextValueL(KMPXMediaMusicAlbumArtist, *value);
   476                     }
   489                     }
   477                 break;
   490                 break;
   478                 }
   491                 }
   479             case EMetaDataOriginalArtist:  // fall through
   492             case EMetaDataOriginalArtist:  // fall through
   480             case EMetaDataVendor:          // fall through
   493             case EMetaDataVendor:          // fall through
   491                 break;
   504                 break;
   492                 }
   505                 }
   493             }
   506             }
   494         if (fieldType != EMetaDataJpeg)
   507         if (fieldType != EMetaDataJpeg)
   495             {
   508             {
   496             CleanupStack::PopAndDestroy( value );       
   509             CleanupStack::PopAndDestroy( value );
   497             }
   510             }
   498         }
   511         }
   499     }
   512     }
   500 
   513 
   501 // ---------------------------------------------------------------------------
   514 // ---------------------------------------------------------------------------
   511     //
   524     //
   512     TInt size( 0 );
   525     TInt size( 0 );
   513     if( iFileOpenError == KErrNone )
   526     if( iFileOpenError == KErrNone )
   514         {
   527         {
   515         const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   528         const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   516         MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType);   
   529         MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType);
   517         iFile.Size( size );
   530         iFile.Size( size );
   518         iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size );
   531         iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size );
   519         
   532 
   520         // Verify if WMA, skip getting info from MMF
   533         // Verify if WMA, skip getting info from MMF
   521         if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   534         if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   522             {
   535             {
   523             // No need to get MMF support
   536             // No need to get MMF support
   524             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF ");   
   537             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF ");
   525             }
   538             }
   526         else
   539         else
   527             {
   540             {
   528             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller");   
   541             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller");
   529             // Duration, bitrate, samplerate, etc
   542             // Duration, bitrate, samplerate, etc
   530             //
   543             //
   531             if( !iMetadataOnly )
   544             if( !iMetadataOnly )
   532             {
   545             {
   533                 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL(
   546                 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL(
   534                           iFile, 
   547                           iFile,
   535                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   548                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   536                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   549                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   537                 if( KErrNone == err2 )
   550                 if( KErrNone == err2 )
   538                     {
   551                     {
   539                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   552                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   544                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   557                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   545                                                     duration );
   558                                                     duration );
   546 
   559 
   547                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   560                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   548                     }
   561                     }
   549                 
   562 
   550                 iFileInfoUtil->Reset();
   563                 iFileInfoUtil->Reset();
   551                 }
   564                 }
   552             }
   565             }
   553         }
   566         }
   554     }
   567     }
   580 
   593 
   581 // ---------------------------------------------------------------------------
   594 // ---------------------------------------------------------------------------
   582 // CMPXMetadataExtractor::ThumbnailPreviewReady
   595 // CMPXMetadataExtractor::ThumbnailPreviewReady
   583 // Callback but not used here
   596 // Callback but not used here
   584 // ---------------------------------------------------------------------------
   597 // ---------------------------------------------------------------------------
   585 void CMPXMetadataExtractor::ThumbnailPreviewReady( 
   598 void CMPXMetadataExtractor::ThumbnailPreviewReady(
   586         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
   599         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
   587     {
   600     {
   588     MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()");
   601     MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()");
   589     }
   602     }
   590         
   603 
   591 
   604 
   592 // ---------------------------------------------------------------------------
   605 // ---------------------------------------------------------------------------
   593 // CMPXMetadataExtractor::ThumbnailReady
   606 // CMPXMetadataExtractor::ThumbnailReady
   594 // Callback but not used here
   607 // Callback but not used here
   595 // ---------------------------------------------------------------------------
   608 // ---------------------------------------------------------------------------
   596 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/, 
   609 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/,
   597         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId )
   610         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId )
   598     {
   611     {
   599     MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()");
   612     MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()");
   600     
   613 
   601     // Remove thumbnail id from array.
   614     // Remove thumbnail id from array.
   602     TInt index = iArrayTNRequestId.Find( aId );
   615     TInt index = iArrayTNRequestId.Find( aId );
   603     if ( index >= 0 )
   616     if ( index >= 0 )
   604         {
   617         {
   605         iArrayTNRequestId.Remove( index );
   618         iArrayTNRequestId.Remove( index );
   620     {
   633     {
   621     MPX_FUNC("CMPXMetadataExtractor::TimeoutTimerCallback()");
   634     MPX_FUNC("CMPXMetadataExtractor::TimeoutTimerCallback()");
   622 
   635 
   623     CMPXMetadataExtractor* ptr =
   636     CMPXMetadataExtractor* ptr =
   624         static_cast<CMPXMetadataExtractor*>(aPtr);
   637         static_cast<CMPXMetadataExtractor*>(aPtr);
   625         
   638 
   626     // Timer expired before thumbnail callback occurred. Stop wait loop to unblock. 
   639     // Timer expired before thumbnail callback occurred. Stop wait loop to unblock.
   627     ptr->StopWaitLoop();
   640     ptr->StopWaitLoop();
   628     return KErrNone;
   641     return KErrNone;
   629     }
   642     }
   630 
   643 
   631 // ----------------------------------------------------------------------------
   644 // ----------------------------------------------------------------------------
   634 void CMPXMetadataExtractor::StopWaitLoop()
   647 void CMPXMetadataExtractor::StopWaitLoop()
   635     {
   648     {
   636     MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()");
   649     MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()");
   637     // Cancel timer
   650     // Cancel timer
   638     CancelTimeoutTimer();
   651     CancelTimeoutTimer();
   639     
   652 
   640     // Stop wait loop to unblock.
   653     // Stop wait loop to unblock.
   641     if ( iTNSyncWait->IsStarted() )
   654     if ( iTNSyncWait->IsStarted() )
   642         {
   655         {
   643         MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop.");
   656         MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop.");
   644         iTNSyncWait->AsyncStop();
   657         iTNSyncWait->AsyncStop();
   645         }
   658         }
   646     }
   659     }
   647 
   660 
   648 // ----------------------------------------------------------------------------
   661 // ----------------------------------------------------------------------------
   649 // Cancel timer. 
   662 // Cancel timer.
   650 // ----------------------------------------------------------------------------
   663 // ----------------------------------------------------------------------------
   651 void CMPXMetadataExtractor::CancelTimeoutTimer()
   664 void CMPXMetadataExtractor::CancelTimeoutTimer()
   652     {
   665     {
   653     MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()");
   666     MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()");
   654     
   667 
   655     // Cancel timer.
   668     // Cancel timer.
   656     if ( iTimer && iTimer->IsActive() )
   669     if ( iTimer && iTimer->IsActive() )
   657         {
   670         {
   658         MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling");
   671         MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling");
   659         iTimer->Cancel();
   672         iTimer->Cancel();
   666 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia )
   679 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia )
   667     {
   680     {
   668     MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()");
   681     MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()");
   669     TInt err = KErrNone;
   682     TInt err = KErrNone;
   670     iCancelled = EFalse;
   683     iCancelled = EFalse;
   671     
   684 
   672     if ( !aMedia->IsSupported(KMPXMediaGeneralUri) )
   685     if ( !aMedia->IsSupported(KMPXMediaGeneralUri) )
   673         {
   686         {
   674         return KErrArgument;
   687         return KErrArgument;
   675         }
   688         }
   676     
   689 
   677     // Get full file name.
   690     // Get full file name.
   678     const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri);
   691     const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri);
   679     MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path );
   692     MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path );
   680 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   693 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   681     TParsePtrC parse( path );
   694     TParsePtrC parse( path );
   693             TBuf<20> mimeType(KImageFileType);
   706             TBuf<20> mimeType(KImageFileType);
   694             TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData);
   707             TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData);
   695             HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC();   // make a local copy of sampleData
   708             HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC();   // make a local copy of sampleData
   696             source = CThumbnailObjectSource::NewLC(
   709             source = CThumbnailObjectSource::NewLC(
   697                 value8, mimeType, path );    // give up ownership of value8
   710                 value8, mimeType, path );    // give up ownership of value8
   698             
   711 
   699             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer");
   712             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer");
   700             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   713             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   701             iArrayTNRequestId.Append( tnId );
   714             iArrayTNRequestId.Append( tnId );
   702             CleanupStack::PopAndDestroy( source );
   715             CleanupStack::PopAndDestroy( source );
   703             CleanupStack::Pop( value8 );
   716             CleanupStack::Pop( value8 );
   704             }
   717             }
   705         else
   718         else
   706             {
   719             {
   707             source = CThumbnailObjectSource::NewLC(
   720             source = CThumbnailObjectSource::NewLC(
   708                 path, KImageFileType  );
   721                 path, KImageFileType  );
   709             
   722 
   710             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path");
   723             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path");
   711             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   724             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   712             iArrayTNRequestId.Append( tnId );
   725             iArrayTNRequestId.Append( tnId );
   713             CleanupStack::PopAndDestroy( source );
   726             CleanupStack::PopAndDestroy( source );
   714             }
   727             }
   719 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   732 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   720     // create wanted fields array
   733     // create wanted fields array
   721     RArray<TMetaDataFieldId> wantedFields;
   734     RArray<TMetaDataFieldId> wantedFields;
   722     CleanupClosePushL( wantedFields );
   735     CleanupClosePushL( wantedFields );
   723     wantedFields.Append(EMetaDataJpeg);
   736     wantedFields.Append(EMetaDataJpeg);
   724     
   737 
   725     // Open file
   738     // Open file
   726     if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) )
   739     if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) )
   727         {
   740         {
   728         const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType );
   741         const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType );
   729         MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType );
   742         MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType );
   735     else
   748     else
   736         {
   749         {
   737         MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) );
   750         MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) );
   738         }
   751         }
   739     CleanupStack::PopAndDestroy( &wantedFields );
   752     CleanupStack::PopAndDestroy( &wantedFields );
   740     
   753 
   741     if ( !err )
   754     if ( !err )
   742         {
   755         {
   743         //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
   756         //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
   744         CheckBeforeSendRequest();
   757         CheckBeforeSendRequest();
   745         MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path ));
   758         MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path ));
   754     }
   767     }
   755 
   768 
   756 // ----------------------------------------------------------------------------
   769 // ----------------------------------------------------------------------------
   757 // Add album art to media object.
   770 // Add album art to media object.
   758 // ----------------------------------------------------------------------------
   771 // ----------------------------------------------------------------------------
   759 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia, 
   772 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia,
   760                                                const TDesC& aFile )
   773                                                const TDesC& aFile )
   761     {
   774     {
   762     MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()");
   775     MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()");
   763     
   776 
   764     // get metadata container.
   777     // get metadata container.
   765     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   778     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   766     TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg );
   779     TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg );
   767    
   780 
   768     if ( data8.Length() )
   781     if ( data8.Length() )
   769         {
   782         {
   770         MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist.");
   783         MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist.");
   771 #ifdef RD_MPX_TNM_INTEGRATION
   784 #ifdef RD_MPX_TNM_INTEGRATION
   772         HBufC8* value8 = NULL; 
   785         HBufC8* value8 = NULL;
   773         MPX_TRAPD( err, value8 = data8.AllocL() );
   786         MPX_TRAPD( err, value8 = data8.AllocL() );
   774         if ( KErrNone != err )
   787         if ( KErrNone != err )
   775             {
   788             {
   776             MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err);
   789             MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err);
   777             return;
   790             return;
   778             }              
   791             }
   779         CleanupStack::PushL( value8 );
   792         CleanupStack::PushL( value8 );
   780     
   793 
   781         TBuf<256> mimeType;
   794         TBuf<256> mimeType;
   782         mimeType.Copy( KImageFileType );
   795         mimeType.Copy( KImageFileType );
   783         CThumbnailObjectSource* source = CThumbnailObjectSource::NewL(
   796         CThumbnailObjectSource* source = CThumbnailObjectSource::NewL(
   784                 value8, mimeType, aFile );
   797                 value8, mimeType, aFile );
   785         TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   798         TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   786         iArrayTNRequestId.Append( tnId ); // add thumbnail id to array
   799         iArrayTNRequestId.Append( tnId ); // add thumbnail id to array
   787         CleanupStack::Pop( value8 );
   800         CleanupStack::Pop( value8 );
   788         delete source;
   801         delete source;
   789         
   802 
   790         aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile );
   803         aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile );
   791 #endif // RD_MPX_TNM_INTEGRATION          
   804 #endif // RD_MPX_TNM_INTEGRATION
   792         aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile );
   805         aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile );
   793         }
   806         }
   794     }
   807     }
   795 
   808 
   796 // ----------------------------------------------------------------------------
   809 // ----------------------------------------------------------------------------
   924         }
   937         }
   925     else // other case use apparc to fetch and set mimetype
   938     else // other case use apparc to fetch and set mimetype
   926         {
   939         {
   927         TDataType dataType;
   940         TDataType dataType;
   928         TUid dummyUid(KNullUid);
   941         TUid dummyUid(KNullUid);
   929         iAppArc.AppForDocument(iFileName, dummyUid, dataType);
   942         // File handle based mime type recogniton required , because AppArc does 
       
   943         // not have All Files capa required for files in private folders 
       
   944         TDataRecognitionResult result;
       
   945         RFs fs;
       
   946 		RFile rFile;
       
   947         User::LeaveIfError(fs.Connect());
       
   948 		CleanupClosePushL(fs);
       
   949         User::LeaveIfError(fs.ShareProtected());
       
   950         User::LeaveIfError(rFile.Open(fs, iFileName, EFileShareReadersOrWriters));
       
   951 		CleanupClosePushL(rFile);
       
   952         User::LeaveIfError(iAppArc.RecognizeData(rFile, result)); 
       
   953         CleanupStack::PopAndDestroy(&rFile);
       
   954         CleanupStack::PopAndDestroy(&fs);
       
   955         dataType = result.iDataType;
   930         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   956         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   931         }
   957         }
   932         
   958 
   933     // Initially set default tags.
   959     // Initially set default tags.
   934     SetDefaultL( *iMedia );
   960     SetDefaultL( *iMedia );
   935     }
   961     }
   936 
   962 
   937 // ----------------------------------------------------------------------------
   963 // ----------------------------------------------------------------------------
   979     if ( iArrayTasks.Count() )
  1005     if ( iArrayTasks.Count() )
   980         {
  1006         {
   981         MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" );
  1007         MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" );
   982         User::Leave( KErrAbort );
  1008         User::Leave( KErrAbort );
   983         }
  1009         }
   984     
  1010 
   985     iCancelled = EFalse;
  1011     iCancelled = EFalse;
   986     iFileOpenError = KErrNone;
  1012     iFileOpenError = KErrNone;
   987     iFileName = aFile;
  1013     iFileName = aFile;
   988     iObs = aObs;
  1014     iObs = aObs;
   989     iMetadataOnly = aMetadataOnly;
  1015     iMetadataOnly = aMetadataOnly;
   990     
  1016 
   991     // populate the task array
  1017     // populate the task array
   992     AddTasksL();
  1018     AddTasksL();
   993     
  1019 
   994     // Start task timer to execute task
  1020     // Start task timer to execute task
   995     if ( iArrayTasks.Count() )
  1021     if ( iArrayTasks.Count() )
   996         {
  1022         {
   997         if ( iTaskTimer->IsActive() )
  1023         if ( iTaskTimer->IsActive() )
   998             {
  1024             {
   999             iTaskTimer->Cancel();
  1025             iTaskTimer->Cancel();
  1000             }   
  1026             }
  1001         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1027         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1002         }
  1028         }
  1003     }
  1029     }
  1004 
  1030 
  1005 // ---------------------------------------------------------------------------
  1031 // ---------------------------------------------------------------------------
  1007 // ---------------------------------------------------------------------------
  1033 // ---------------------------------------------------------------------------
  1008 //
  1034 //
  1009 TInt CMPXMetadataExtractor::OpenFile()
  1035 TInt CMPXMetadataExtractor::OpenFile()
  1010     {
  1036     {
  1011     MPX_FUNC("CMPXMetadataExtractor::OpenFile()");
  1037     MPX_FUNC("CMPXMetadataExtractor::OpenFile()");
  1012     
  1038 
  1013     // Open the file
  1039     // Open the file
  1014     iFile.Close();
  1040     iFile.Close();
  1015     TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters );
  1041     TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters );
  1016     MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error );
  1042     MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error );
  1017     return error;
  1043     return error;
  1023 //
  1049 //
  1024 void CMPXMetadataExtractor::AddTasksL()
  1050 void CMPXMetadataExtractor::AddTasksL()
  1025     {
  1051     {
  1026     MPX_FUNC("CMPXMetadataExtractor::AddTasks()");
  1052     MPX_FUNC("CMPXMetadataExtractor::AddTasks()");
  1027     iFileOpenError = OpenFile();
  1053     iFileOpenError = OpenFile();
  1028     
  1054 
  1029     // Do not change the order of the task below.
  1055     // Do not change the order of the task below.
  1030     iArrayTasks.Reset();
  1056     iArrayTasks.Reset();
  1031     if ( iFileOpenError == KErrNone )
  1057     if ( iFileOpenError == KErrNone )
  1032         {
  1058         {
  1033         // to avoid resources contention (i.e. accessing sql, file system, etc)
  1059         // to avoid resources contention (i.e. accessing sql, file system, etc)
  1064 // Handle task timer expired
  1090 // Handle task timer expired
  1065 // ----------------------------------------------------------------------------
  1091 // ----------------------------------------------------------------------------
  1066 void CMPXMetadataExtractor::HandleTaskTimerExpired()
  1092 void CMPXMetadataExtractor::HandleTaskTimerExpired()
  1067     {
  1093     {
  1068     MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()");
  1094     MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()");
  1069     
  1095 
  1070     if ( iTaskTimer && iTaskTimer->IsActive() )
  1096     if ( iTaskTimer && iTaskTimer->IsActive() )
  1071         {
  1097         {
  1072         iTaskTimer->Cancel();
  1098         iTaskTimer->Cancel();
  1073         }
  1099         }
  1074     // execute task at index 0
  1100     // execute task at index 0
  1081             delete iMedia;
  1107             delete iMedia;
  1082             iMedia = NULL;
  1108             iMedia = NULL;
  1083             }
  1109             }
  1084         iArrayTasks.Reset();
  1110         iArrayTasks.Reset();
  1085         }
  1111         }
  1086     
  1112 
  1087     // Remove task at index 0.
  1113     // Remove task at index 0.
  1088     if ( iArrayTasks.Count() )
  1114     if ( iArrayTasks.Count() )
  1089         {
  1115         {
  1090         iArrayTasks.Remove( 0 );
  1116         iArrayTasks.Remove( 0 );
  1091         }
  1117         }
  1092     
  1118 
  1093     // check if we have any more task to run
  1119     // check if we have any more task to run
  1094     if ( iArrayTasks.Count() )
  1120     if ( iArrayTasks.Count() )
  1095         {
  1121         {
  1096         // start task timer
  1122         // start task timer
  1097         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1123         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1102         if ( iObs && !iCancelled )
  1128         if ( iObs && !iCancelled )
  1103             {
  1129             {
  1104             iObs->HandleCreateMediaComplete( iMedia, error );
  1130             iObs->HandleCreateMediaComplete( iMedia, error );
  1105             iMedia = NULL;  // ownership transferred.
  1131             iMedia = NULL;  // ownership transferred.
  1106             }
  1132             }
  1107         
  1133 
  1108         CleanUp();
  1134         CleanUp();
  1109         }
  1135         }
  1110     }
  1136     }
  1111 
  1137 
  1112 // ----------------------------------------------------------------------------
  1138 // ----------------------------------------------------------------------------
  1133     // DB Flags to set
  1159     // DB Flags to set
  1134     TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit);
  1160     TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit);
  1135     // Validate the objects to be used
  1161     // Validate the objects to be used
  1136     MPX_ASSERT(iMedia);
  1162     MPX_ASSERT(iMedia);
  1137     MPX_ASSERT(iDrmMediaUtility);
  1163     MPX_ASSERT(iDrmMediaUtility);
  1138     
  1164 
  1139     // File Path
  1165     // File Path
  1140     TParsePtrC parse( iFileName );
  1166     TParsePtrC parse( iFileName );
  1141     iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName );
  1167     iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName );
  1142     iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() );
  1168     iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() );
  1143     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName);
  1169     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName);
  1144 
  1170 
  1145     // get the protected flag from MetadataUtility Container
  1171     // get the protected flag from MetadataUtility Container
  1146     TPtrC ptr = aMetaCont.Field( EMetaDataProtected );  
  1172     TPtrC ptr = aMetaCont.Field( EMetaDataProtected );
  1147     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr);
  1173     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr);
  1148     _LIT( KNonProtected, "0" );
  1174     _LIT( KNonProtected, "0" );
  1149     if ( ptr.Compare( KNonProtected ) == 0 )
  1175     if ( ptr.Compare( KNonProtected ) == 0 )
  1150         {
  1176         {
  1151         // this is non-protected file
  1177         // this is non-protected file
  1152         // prot = EFalse
  1178         // prot = EFalse
  1153         MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected");
  1179         MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected");
  1154         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1180         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1155         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1181         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1156         }
  1182         }
  1157     else  
  1183     else
  1158         {  // DRM file
  1184         {  // DRM file
  1159 
  1185 
  1160         // DRM Rights
  1186         // DRM Rights
  1161         //
  1187         //
  1162         CMPXMedia* drm = NULL;
  1188         CMPXMedia* drm = NULL;
  1204             User::LeaveIfError( drmError );
  1230             User::LeaveIfError( drmError );
  1205             }
  1231             }
  1206 
  1232 
  1207         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1233         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1208         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1234         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1209     
  1235 
  1210         iDrmMediaUtility->Close();
  1236         iDrmMediaUtility->Close();
  1211     
  1237 
  1212         }  // DRM file
  1238         }  // DRM file
  1213 
  1239 
  1214     
  1240 
  1215     // verify the file open status
  1241     // verify the file open status
  1216     if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound )
  1242     if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound )
  1217         {
  1243         {
  1218         dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
  1244         dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
  1219         }
  1245         }
  1220     
  1246 
  1221     // Finally set the db flag
  1247     // Finally set the db flag
  1222     //
  1248     //
  1223     iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags );
  1249     iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags );
  1224    
  1250 
  1225     }
  1251     }