mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataprovidergetobjectpropvalue.cpp
branchRCL_3
changeset 11 780c925249c1
parent 8 bee149131e4b
child 24 6c1dfe4da5dd
equal deleted inserted replaced
10:d240f0a77280 11:780c925249c1
    13 *
    13 *
    14 * Description:  Implement the operation: getobjectpropvalue
    14 * Description:  Implement the operation: getobjectpropvalue
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 #include <mtp/cmtptypearray.h>
       
    20 #include <f32file.h>
    18 
    21 
    19 #include "cabstractmediamtpdataprovidergetobjectpropvalue.h"
    22 #include "cabstractmediamtpdataprovidergetobjectpropvalue.h"
    20 #include "abstractmediamtpdataproviderconst.h"
    23 #include "abstractmediamtpdataproviderconst.h"
    21 #include "mmmtpdplogger.h"
    24 #include "mmmtpdplogger.h"
    22 #include "mmmtpdpdefs.h"
    25 #include "mmmtpdpdefs.h"
    79 // CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectProperty
    82 // CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectProperty
    80 // no need to do anything here, just leave, as this should never be
    83 // no need to do anything here, just leave, as this should never be
    81 // invoked or invalid propcode
    84 // invoked or invalid propcode
    82 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    83 //
    86 //
    84 void CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectPropertyL( TUint16 /*aPropCode*/ )
    87 void CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectPropertyL( TUint16 aPropCode )
    85     {
    88     {
    86     PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectPropertyL, leave with KErrNotSupported"));
    89     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectPropertyL" ) );
       
    90     switch ( aPropCode )
       
    91         {
       
    92         case EMTPObjectPropCodeRepresentativeSampleFormat:
       
    93             {
       
    94             iMTPTypeUint16.Set( 0 );
       
    95             SendDataL( iMTPTypeUint16 );
       
    96             }
       
    97             break;
    87 
    98 
    88     // May need add implementation here for further extension.
    99         case EMTPObjectPropCodeRepresentativeSampleSize: // fall through
       
   100         case EMTPObjectPropCodeRepresentativeSampleHeight: // fall through
       
   101         case EMTPObjectPropCodeRepresentativeSampleWidth:
       
   102             {
       
   103             iMTPTypeUint32.Set( 0 );
       
   104             SendDataL( iMTPTypeUint32 );
       
   105             }
       
   106             break;
    89 
   107 
    90     User::Leave( KErrNotSupported );
   108         case EMTPObjectPropCodeRepresentativeSampleData:
       
   109             {
       
   110             if ( iMTPTypeArray != NULL )
       
   111                 {
       
   112                 delete iMTPTypeArray;
       
   113                 iMTPTypeArray = NULL;
       
   114                 }
       
   115             iMTPTypeArray = CMTPTypeArray::NewL( EMTPTypeAUINT8 );
       
   116 
       
   117             const TDesC& suid = iObjectInfo->DesC( CMTPObjectMetaData::ESuid );
       
   118             PRINT1( _L( "MM MTP <> EMTPObjectPropCodeRepresentativeSampleData file suid=%S" ), &suid );
       
   119             RFile sampleFile;
       
   120             User::LeaveIfError( sampleFile.Open( iFramework.Fs(), suid, EFileShareReadersOnly ) );
       
   121             CleanupClosePushL( sampleFile );    // + sampleFile
       
   122 
       
   123             TInt size = 0;
       
   124             User::LeaveIfError( sampleFile.Size( size ) );
       
   125             PRINT1( _L( "MM MTP <> EMTPObjectPropCodeRepresentativeSampleData sampleFile.Size() size=%d" ), size );
       
   126 
       
   127             if( size > 0 )
       
   128                 {
       
   129                 HBufC8* sampleData = HBufC8::NewLC( size * sizeof(TUint8) );    // + sampleData
       
   130                 TPtr8 samplePtr = sampleData->Des();
       
   131                 User::LeaveIfError( sampleFile.Read( samplePtr ) );
       
   132                 iMTPTypeArray->SetByDesL( samplePtr );
       
   133                 CleanupStack::PopAndDestroy( sampleData );    // - sampleData
       
   134                 }
       
   135             CleanupStack::PopAndDestroy( &sampleFile );    // - sampleFile
       
   136 
       
   137             SendDataL( *iMTPTypeArray );
       
   138             }
       
   139             break;
       
   140 
       
   141         default:
       
   142             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProviderGetObjectPropValue::ServiceSpecificObjectPropertyL, leave with KErrNotSupported"));
       
   143             User::Leave( KErrNotSupported );
       
   144         }
    91     }
   145     }
    92 
   146 
    93 // end of file
   147 // end of file