commondrm/drmutility/src/DrmUtility.cpp
branchRCL_3
changeset 88 c1bd57533c56
parent 18 8a03a285ab14
equal deleted inserted replaced
81:e9463401011b 88:c1bd57533c56
   213     RFile file;
   213     RFile file;
   214     TBuf8< 32 > header;
   214     TBuf8< 32 > header;
   215     TInt64 headerSize( 0 );
   215     TInt64 headerSize( 0 );
   216     TBool isDrmFile( EFalse );
   216     TBool isDrmFile( EFalse );
   217     TPtr8 headerPtr( NULL, 0 );
   217     TPtr8 headerPtr( NULL, 0 );
       
   218     TInt dataLength = 0;
   218 
   219 
   219     aProtected = DRM::EUUnprotected;
   220     aProtected = DRM::EUUnprotected;
   220     aAgent.Set( KNullDesC );
   221     aAgent.Set( KNullDesC );
   221 
   222 
   222     CheckFileHandleL( aFileHandle );
   223     CheckFileHandleL( aFileHandle );
   304             }
   305             }
   305         else if ( (buffer->Des())[0] == 1)
   306         else if ( (buffer->Des())[0] == 1)
   306             {
   307             {
   307             // set the mimetype from the buffer which is in the beginning
   308             // set the mimetype from the buffer which is in the beginning
   308             // starting from byte 3 with the length specified at position 2
   309             // starting from byte 3 with the length specified at position 2
   309             TPtrC8 mimeType( buffer->Des().Mid(3, (buffer->Des())[1]) );
   310             // also make sure the data length is greater or equal to the
   310             if( !mimeType.CompareF( *iOmaBasedMimeType ) )
   311             // position + the 2nd byte of the content
   311                 {
   312             dataLength = 3 + (buffer->Des())[1];
   312                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   313             if( buffer->Length() >= dataLength )
   313                 isDrmFile = ETrue;
   314                 {           
       
   315                 TPtrC8 mimeType( buffer->Des().Mid(3, (buffer->Des())[1]) );
       
   316                 if( !mimeType.CompareF( *iOmaBasedMimeType ) )
       
   317                     {
       
   318                     aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
       
   319                     isDrmFile = ETrue;
       
   320                     }
   314                 }
   321                 }
   315             }
   322             }
   316         CleanupStack::PopAndDestroy( buffer );
   323         CleanupStack::PopAndDestroy( buffer );
   317         }
   324         }
   318     CleanupStack::PopAndDestroy( &file ); // file
   325     CleanupStack::PopAndDestroy( &file ); // file
   331     TInt r( KErrNone );
   338     TInt r( KErrNone );
   332     RFile file;
   339     RFile file;
   333     TPtr8 asfPtr( NULL, 0 );
   340     TPtr8 asfPtr( NULL, 0 );
   334     TBuf8< 32 > asfGuidHex;
   341     TBuf8< 32 > asfGuidHex;
   335     TBool isDrmFile( EFalse );
   342     TBool isDrmFile( EFalse );
       
   343     TInt dataLength = 0;
   336 
   344 
   337     aProtected = DRM::EUUnprotected;
   345     aProtected = DRM::EUUnprotected;
   338     aAgent.Set( KNullDesC );
   346     aAgent.Set( KNullDesC );
   339 
   347 
   340     if ( aContent.Length() < KMinContentLength )
   348     if ( aContent.Length() < KMinContentLength )
   399             }
   407             }
   400         else if ( (aContent)[0] == 1)
   408         else if ( (aContent)[0] == 1)
   401             {
   409             {
   402             // set the mimetype from the buffer which is in the beginning
   410             // set the mimetype from the buffer which is in the beginning
   403             // starting from byte 3 with the length specified at position 2
   411             // starting from byte 3 with the length specified at position 2
   404             TPtrC8 mimeType( aContent.Mid(3, (aContent)[1]) );
   412             // also make sure the data length is greater or equal to the
   405             if( !mimeType.CompareF( *iOmaBasedMimeType ) )
   413             // position + the 2nd byte of the content
   406                 {
   414             dataLength = 3 + (aContent)[1];
   407                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   415             if( aContent.Length() >= dataLength )
   408                 isDrmFile = ETrue;
   416                 {
   409                 aProtected = DRM::EUProtected;
   417                 TPtrC8 mimeType( aContent.Mid(3, (aContent)[1]) );
       
   418                 if( !mimeType.CompareF( *iOmaBasedMimeType ) )
       
   419                     {
       
   420                     aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
       
   421                     isDrmFile = ETrue;
       
   422                     aProtected = DRM::EUProtected;
       
   423                     }
   410                 }
   424                 }
   411             }
   425             }
   412         }
   426         }
   413     return isDrmFile;
   427     return isDrmFile;
   414     }
   428     }