commondrm/drmutility/src/DrmUtility.cpp
branchRCL_3
changeset 12 8a03a285ab14
parent 0 95b198f216e5
equal deleted inserted replaced
11:e16d72588c28 12:8a03a285ab14
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <Oma2Dcf.h>
    20 #include <oma2dcf.h>
    21 #include <drmagents.h>
    21 #include <drmagents.h>
    22 #include <drmutility.h>
    22 #include <drmutility.h>
    23 #include <centralrepository.h>
    23 #include <centralrepository.h>
    24 #include <UTF.h>
    24 #include <utf.h>
    25 
    25 
    26 #include "Oma1Dcf.h"
    26 #include "Oma1Dcf.h"
    27 
    27 
    28 #include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
    28 #include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
    29 
    29 
    63         }
    63         }
    64     for ( i = 6; i < 8; i++ )
    64     for ( i = 6; i < 8; i++ )
    65         {
    65         {
    66         copyGUID[i] = aGUID[13 - i];
    66         copyGUID[i] = aGUID[13 - i];
    67         }
    67         }
    68     for ( i = 8; i < 16 ; i++) 
    68     for ( i = 8; i < 16 ; i++)
    69         {
    69         {
    70         copyGUID[i] = aGUID[i];
    70         copyGUID[i] = aGUID[i];
    71         }
    71         }
    72     aGUID.Delete( 0, 32 );
    72     aGUID.Delete( 0, 32 );
    73     for ( i = 0; i < 16; i++ )
    73     for ( i = 0; i < 16; i++ )
    95 // ============================ MEMBER FUNCTIONS ===============================
    95 // ============================ MEMBER FUNCTIONS ===============================
    96 
    96 
    97 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    98 // Default constructor
    98 // Default constructor
    99 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   100 //  
   100 //
   101 DRM::CDrmUtility::CDrmUtility()
   101 DRM::CDrmUtility::CDrmUtility()
   102     {
   102     {
   103     }
   103     }
   104     
   104 
   105 // -----------------------------------------------------------------------------
   105 // -----------------------------------------------------------------------------
   106 // Destructor
   106 // Destructor
   107 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   108 //  
   108 //
   109 DRM::CDrmUtility::~CDrmUtility()
   109 DRM::CDrmUtility::~CDrmUtility()
   110     {
   110     {
   111     delete iOmaBasedAgentName;
   111     delete iOmaBasedAgentName;
   112     delete iOmaBasedMimeType;
   112     delete iOmaBasedMimeType;
   113     }
   113     }
   114     
   114 
   115 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   116 // CDrmUtility::NewLC
   116 // CDrmUtility::NewLC
   117 // First phase constructor
   117 // First phase constructor
   118 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   119 //  
   119 //
   120 EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewLC()
   120 EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewLC()
   121     {
   121     {
   122     DRM::CDrmUtility* self( new( ELeave ) CDrmUtility );
   122     DRM::CDrmUtility* self( new( ELeave ) CDrmUtility );
   123     CleanupStack::PushL( self );
   123     CleanupStack::PushL( self );
   124     self->ConstructL();
   124     self->ConstructL();
   127 
   127 
   128 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   129 // CDrmUtility::NewL
   129 // CDrmUtility::NewL
   130 // First phase constructor
   130 // First phase constructor
   131 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   132 //  
   132 //
   133 EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewL()
   133 EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewL()
   134     {
   134     {
   135     DRM::CDrmUtility* self( NewLC() );
   135     DRM::CDrmUtility* self( NewLC() );
   136     CleanupStack::Pop();
   136     CleanupStack::Pop();
   137     return self;
   137     return self;
   138     }
   138     }
   139 
   139 
   140 void DRM::CDrmUtility::ConstructL()
   140 void DRM::CDrmUtility::ConstructL()
   141     {
   141     {
   142     TInt err( KErrNone );
   142     TInt err( KErrNone );
   143              
   143 
   144      TRAP(err, FetchOmaBasedInfoL() );
   144      TRAP(err, FetchOmaBasedInfoL() );
   145      if( err)
   145      if( err)
   146          {
   146          {
   147          if( iOmaBasedAgentName )
   147          if( iOmaBasedAgentName )
   148              {
   148              {
   152          if( iOmaBasedMimeType )
   152          if( iOmaBasedMimeType )
   153              {
   153              {
   154              delete iOmaBasedMimeType;
   154              delete iOmaBasedMimeType;
   155              }
   155              }
   156          iOmaBasedMimeType = NULL;
   156          iOmaBasedMimeType = NULL;
   157          }   
   157          }
   158     }
   158     }
   159 
   159 
   160 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   161 // CDrmUtility::FetchOmaBasedInfoL
   161 // CDrmUtility::FetchOmaBasedInfoL
   162 // -----------------------------------------------------------------------------
   162 // -----------------------------------------------------------------------------
   165     {
   165     {
   166     TInt err = KErrNone;
   166     TInt err = KErrNone;
   167     CRepository* repository( NULL );
   167     CRepository* repository( NULL );
   168     RBuf bOmaBasedAgentName;
   168     RBuf bOmaBasedAgentName;
   169     RBuf bOmaBasedMimeType;
   169     RBuf bOmaBasedMimeType;
   170     
   170 
   171     CleanupClosePushL(bOmaBasedAgentName);
   171     CleanupClosePushL(bOmaBasedAgentName);
   172     CleanupClosePushL(bOmaBasedMimeType);
   172     CleanupClosePushL(bOmaBasedMimeType);
   173     bOmaBasedAgentName.CreateL( KCenRepDataLength );
   173     bOmaBasedAgentName.CreateL( KCenRepDataLength );
   174     bOmaBasedMimeType.CreateL( KCenRepDataLength );
   174     bOmaBasedMimeType.CreateL( KCenRepDataLength );
   175  
   175 
   176     TRAP( err, repository = CRepository::NewL( KCRUidOmaBased ) );
   176     TRAP( err, repository = CRepository::NewL( KCRUidOmaBased ) );
   177     if ( !err )
   177     if ( !err )
   178         {
   178         {
   179         CleanupStack::PushL( repository );
   179         CleanupStack::PushL( repository );
   180         
   180 
   181         err = repository->Get( KDrmOmaBasedName, bOmaBasedAgentName );
   181         err = repository->Get( KDrmOmaBasedName, bOmaBasedAgentName );
   182         if( !err )
   182         if( !err )
   183             {
   183             {
   184             iOmaBasedAgentName = bOmaBasedAgentName.AllocL(); 
   184             iOmaBasedAgentName = bOmaBasedAgentName.AllocL();
   185             }
   185             }
   186         
   186 
   187         err = repository->Get( KOmaBasedMimeType, bOmaBasedMimeType );
   187         err = repository->Get( KOmaBasedMimeType, bOmaBasedMimeType );
   188         if( !err )
   188         if( !err )
   189             {
   189             {
   190             iOmaBasedMimeType = CnvUtfConverter::ConvertFromUnicodeToUtf8L( bOmaBasedMimeType );
   190             iOmaBasedMimeType = CnvUtfConverter::ConvertFromUnicodeToUtf8L( bOmaBasedMimeType );
   191             }
   191             }
   192         CleanupStack::PopAndDestroy( repository );
   192         CleanupStack::PopAndDestroy( repository );
   193         }
   193         }
   194     
   194 
   195     CleanupStack::PopAndDestroy(2);
   195     CleanupStack::PopAndDestroy(2);
   196     
   196 
   197     User::LeaveIfError( err );
   197     User::LeaveIfError( err );
   198     }
   198     }
   199 
   199 
   200 
   200 
   201 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   202 // CDrmUtility::GetDrmInfoL
   202 // CDrmUtility::GetDrmInfoL
   203 // -----------------------------------------------------------------------------
   203 // -----------------------------------------------------------------------------
   204 //  
   204 //
   205 EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL( 
   205 EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL(
   206     RFile& aFileHandle,
   206     RFile& aFileHandle,
   207     TPtrC& aAgent,
   207     TPtrC& aAgent,
   208     DRM::TDrmProtectionStatus& aProtected ) const
   208     DRM::TDrmProtectionStatus& aProtected ) const
   209     {
   209     {
   210     TInt r( KErrNone );
   210     TInt r( KErrNone );
   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         
   218 
   219     aProtected = DRM::EUUnprotected;
   219     aProtected = DRM::EUUnprotected;
   220     aAgent.Set( KNullDesC );
   220     aAgent.Set( KNullDesC );
   221     
   221 
   222     CheckFileHandleL( aFileHandle );
   222     CheckFileHandleL( aFileHandle );
   223     User::LeaveIfError( file.Duplicate( aFileHandle ) );
   223     User::LeaveIfError( file.Duplicate( aFileHandle ) );
   224     CleanupClosePushL( file );
   224     CleanupClosePushL( file );
   225 
   225 
   226     User::LeaveIfError( file.Seek( ESeekStart, pos ) );
   226     User::LeaveIfError( file.Seek( ESeekStart, pos ) );
   227     
   227 
   228     // Check if the file is an ASF file
   228     // Check if the file is an ASF file
   229     // To be Checked on runtime wether WM DRM is supporeted or not
   229     // To be Checked on runtime wether WM DRM is supporeted or not
   230     User::LeaveIfError( file.Read( 0, header, KMinContentLength ) );
   230     User::LeaveIfError( file.Read( 0, header, KMinContentLength ) );
   231     if ( header.Length() < KMinContentLength )
   231     if ( header.Length() < KMinContentLength )
   232         {
   232         {
   233         User::Leave( KErrArgument ); 
   233         User::Leave( KErrArgument );
   234         }    
   234         }
   235         
   235 
   236     FormatGUID( header );
   236     FormatGUID( header );
   237     
   237 
   238     if ( header == KASFHeaderObject )
   238     if ( header == KASFHeaderObject )
   239         {
   239         {
   240         // It's ASF, check still whether it's WM DRM protected or not
   240         // It's ASF, check still whether it's WM DRM protected or not
   241         file.Read( header, KWMHeaderObjectLength );
   241         file.Read( header, KWMHeaderObjectLength );
   242         headerSize = ConvertToInt64( header );
   242         headerSize = ConvertToInt64( header );
   243         if( headerSize <= KWMTopLevelHeaderObjectLength || 
   243         if( headerSize <= KWMTopLevelHeaderObjectLength ||
   244             headerSize > KMaxWMHeaderLength )
   244             headerSize > KMaxWMHeaderLength )
   245             {
   245             {
   246             User::Leave( KErrArgument );
   246             User::Leave( KErrArgument );
   247             }
   247             }
   248         buffer = HBufC8::NewLC( headerSize );
   248         buffer = HBufC8::NewLC( headerSize );
   249 
   249 
   250         headerPtr.Set( buffer->Des() ); 
   250         headerPtr.Set( buffer->Des() );
   251         User::LeaveIfError( file.Read( headerPtr, 
   251         User::LeaveIfError( file.Read( headerPtr,
   252                 headerSize - ( KMinContentLength + KWMHeaderObjectLength ) ) );
   252                 headerSize - ( KMinContentLength + KWMHeaderObjectLength ) ) );
   253     
   253 
   254         r = headerPtr.Find( KWrmHeader );
   254         r = headerPtr.Find( KWrmHeader );
   255         if ( r == KErrNotFound ) 
   255         if ( r == KErrNotFound )
   256             {
   256             {
   257             aProtected = DRM::EUUnprotected;
   257             aProtected = DRM::EUUnprotected;
   258             }
   258             }
   259         else
   259         else
   260             {
   260             {
   261             isDrmFile = ETrue;
   261             isDrmFile = ETrue;
   262             aProtected = DRM::EUProtected;
   262             aProtected = DRM::EUProtected;
   263             aAgent.Set( DRM::KDrmWMAgentName );                            
   263             aAgent.Set( DRM::KDrmWMAgentName );
   264             }
   264             }
   265         CleanupStack::PopAndDestroy( buffer ); // buffer    
   265         CleanupStack::PopAndDestroy( buffer ); // buffer
   266         }
   266         }
   267     else
   267     else
   268         {
   268         {
   269         // Check whether it's OMA DRM protected or not
   269         // Check whether it's OMA DRM protected or not
   270         buffer = HBufC8::NewLC( KOmaHeaderLength );
   270         buffer = HBufC8::NewLC( KOmaHeaderLength );
   271         
   271 
   272         headerPtr.Set( buffer->Des() );
   272         headerPtr.Set( buffer->Des() );
   273         User::LeaveIfError( file.Read( 0, headerPtr ));
   273         User::LeaveIfError( file.Read( 0, headerPtr ));
   274         
   274 
   275         if ( COma1Dcf::IsValidDcf( headerPtr ) )
   275         if ( COma1Dcf::IsValidDcf( headerPtr ) )
   276             {
   276             {
   277             isDrmFile = ETrue;
   277             isDrmFile = ETrue;
   278             aProtected = DRM::EUProtected;                             
   278             aProtected = DRM::EUProtected;
   279             aAgent.Set( DRM::KDrmOmaAgentName );                
   279             aAgent.Set( DRM::KDrmOmaAgentName );
   280             }
   280             }
   281         else if ( COma2Dcf::IsValidDcf( headerPtr ) )
   281         else if ( COma2Dcf::IsValidDcf( headerPtr ) )
   282             {
   282             {
   283             isDrmFile = ETrue;
   283             isDrmFile = ETrue;
   284             _LIT8( KCommonHeadersBox, "ohdr" );
   284             _LIT8( KCommonHeadersBox, "ohdr" );
   285             pos = headerPtr.Find( KCommonHeadersBox );
   285             pos = headerPtr.Find( KCommonHeadersBox );
   286             
   286 
   287             // If no box can be found or if there isn't enough data
   287             // If no box can be found or if there isn't enough data
   288             // set protection as unknown
   288             // set protection as unknown
   289             if( pos == KErrNotFound || 
   289             if( pos == KErrNotFound ||
   290                 headerPtr.Length() < pos + KOma2EncryptionFieldOffset )
   290                 headerPtr.Length() < pos + KOma2EncryptionFieldOffset )
   291                 {
   291                 {
   292                 aProtected = DRM::EUUnknown;
   292                 aProtected = DRM::EUUnknown;
   293                 }
   293                 }
   294             // If encryption field is 0, then content isn't protected
   294             // If encryption field is 0, then content isn't protected
   297                 aProtected = DRM::EUUnprotected;
   297                 aProtected = DRM::EUUnprotected;
   298                 }
   298                 }
   299             else
   299             else
   300                 {
   300                 {
   301                 aProtected = DRM::EUProtected;
   301                 aProtected = DRM::EUProtected;
   302                 }                  
   302                 }
   303             aAgent.Set( DRM::KDrmOmaAgentName );                
   303             aAgent.Set( DRM::KDrmOmaAgentName );
   304             }   
   304             }
   305         else if ( (buffer->Des())[0] == 1)
   305         else if ( (buffer->Des())[0] == 1)
   306             {
   306             {
   307             // set the mimetype from the buffer which is in the beginning
   307             // set the mimetype from the buffer which is in the beginning
   308             // starting from byte 3 with the length specified at position 2		
   308             // starting from byte 3 with the length specified at position 2
   309             TPtrC8 mimeType( buffer->Des().Mid(3, (buffer->Des())[1]) );
   309             TPtrC8 mimeType( buffer->Des().Mid(3, (buffer->Des())[1]) );
   310             if( !mimeType.CompareF( *iOmaBasedMimeType ) ) 
   310             if( !mimeType.CompareF( *iOmaBasedMimeType ) )
   311                 {	
   311                 {
   312                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   312                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   313                 isDrmFile = ETrue;
   313                 isDrmFile = ETrue;
   314                 }
   314                 }
   315             }
   315             }
   316         CleanupStack::PopAndDestroy( buffer );
   316         CleanupStack::PopAndDestroy( buffer );
   317         }  
   317         }
   318     CleanupStack::PopAndDestroy( &file ); // file
   318     CleanupStack::PopAndDestroy( &file ); // file
   319     return isDrmFile;
   319     return isDrmFile;
   320     }  
   320     }
   321   
   321 
   322 // -----------------------------------------------------------------------------
   322 // -----------------------------------------------------------------------------
   323 // CDrmUtility::GetDrmInfoL
   323 // CDrmUtility::GetDrmInfoL
   324 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   325 //  
   325 //
   326 EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL( 
   326 EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL(
   327     const TDesC8& aContent,
   327     const TDesC8& aContent,
   328     TPtrC& aAgent,
   328     TPtrC& aAgent,
   329     DRM::TDrmProtectionStatus& aProtected ) const
   329     DRM::TDrmProtectionStatus& aProtected ) const
   330     {
   330     {
   331     TInt r( KErrNone );
   331     TInt r( KErrNone );
   332     RFile file;
   332     RFile file;
   333     TPtr8 asfPtr( NULL, 0 );
   333     TPtr8 asfPtr( NULL, 0 );
   334     TBuf8< 32 > asfGuidHex;
   334     TBuf8< 32 > asfGuidHex;
   335     TBool isDrmFile( EFalse );
   335     TBool isDrmFile( EFalse );
   336     
   336 
   337     aProtected = DRM::EUUnprotected;
   337     aProtected = DRM::EUUnprotected;
   338     aAgent.Set( KNullDesC );
   338     aAgent.Set( KNullDesC );
   339 
   339 
   340     if ( aContent.Length() < KMinContentLength )
   340     if ( aContent.Length() < KMinContentLength )
   341         {
   341         {
   342         User::Leave( KErrArgument );   
   342         User::Leave( KErrArgument );
   343         }
   343         }
   344         
   344 
   345     // Check if the file is an ASF file
   345     // Check if the file is an ASF file
   346     asfPtr.Set( 
   346     asfPtr.Set(
   347         const_cast<TUint8*>( asfGuidHex.Ptr() ), 0, KMinContentLength * 2 );
   347         const_cast<TUint8*>( asfGuidHex.Ptr() ), 0, KMinContentLength * 2 );
   348     asfPtr.Copy( aContent.Left( KMinContentLength ) );    
   348     asfPtr.Copy( aContent.Left( KMinContentLength ) );
   349     FormatGUID( asfPtr );
   349     FormatGUID( asfPtr );
   350     
   350 
   351     if ( asfPtr == KASFHeaderObject )
   351     if ( asfPtr == KASFHeaderObject )
   352         {
   352         {
   353         // It's ASF, check still whether it's WM DRM protected or not
   353         // It's ASF, check still whether it's WM DRM protected or not
   354         r = aContent.Find( KWrmHeader );
   354         r = aContent.Find( KWrmHeader );
   355         if ( r == KErrNotFound ) 
   355         if ( r == KErrNotFound )
   356             {
   356             {
   357             aProtected = DRM::EUUnprotected;   
   357             aProtected = DRM::EUUnprotected;
   358             }
   358             }
   359         else
   359         else
   360             {
   360             {
   361             isDrmFile = ETrue;
   361             isDrmFile = ETrue;
   362             aProtected = DRM::EUProtected;                               
   362             aProtected = DRM::EUProtected;
   363             aAgent.Set( DRM::KDrmWMAgentName ); 
   363             aAgent.Set( DRM::KDrmWMAgentName );
   364             }   
   364             }
   365         }
   365         }
   366     else
   366     else
   367         {
   367         {
   368         // Check whether it's OMA DRM protected or not.
   368         // Check whether it's OMA DRM protected or not.
   369         if ( ( aContent.Length() >= KMinContentLengthOma1Based ) && 
   369         if ( ( aContent.Length() >= KMinContentLengthOma1Based ) &&
   370             ( COma1Dcf::IsValidDcf( aContent ) ) )
   370             ( COma1Dcf::IsValidDcf( aContent ) ) )
   371             {
   371             {
   372             isDrmFile = ETrue;
   372             isDrmFile = ETrue;
   373             aProtected = DRM::EUProtected;                          
   373             aProtected = DRM::EUProtected;
   374             aAgent.Set( DRM::KDrmOmaAgentName );
   374             aAgent.Set( DRM::KDrmOmaAgentName );
   375             }
   375             }
   376         else if ( COma2Dcf::IsValidDcf( aContent ) )
   376         else if ( COma2Dcf::IsValidDcf( aContent ) )
   377             {
   377             {
   378             isDrmFile = ETrue;
   378             isDrmFile = ETrue;
   379             _LIT8( KCommonHeadersBox, "ohdr" );
   379             _LIT8( KCommonHeadersBox, "ohdr" );
   380             TInt pos( aContent.Find( KCommonHeadersBox ) );
   380             TInt pos( aContent.Find( KCommonHeadersBox ) );
   381             
   381 
   382             // If no box can be found or if there isn't enough data
   382             // If no box can be found or if there isn't enough data
   383             // set protection as unknown
   383             // set protection as unknown
   384             if ( pos == KErrNotFound || 
   384             if ( pos == KErrNotFound ||
   385                  aContent.Length() < pos + KOma2EncryptionFieldOffset )
   385                  aContent.Length() < pos + KOma2EncryptionFieldOffset )
   386                 {
   386                 {
   387                 aProtected = DRM::EUUnknown;
   387                 aProtected = DRM::EUUnknown;
   388                 }
   388                 }
   389             // If encryption field is 0, then content isn't protected    
   389             // If encryption field is 0, then content isn't protected
   390             else if ( !aContent[pos + KOma2EncryptionFieldOffset] )
   390             else if ( !aContent[pos + KOma2EncryptionFieldOffset] )
   391                 {
   391                 {
   392                 aProtected = DRM::EUUnprotected;    
   392                 aProtected = DRM::EUUnprotected;
   393                 }
   393                 }
   394             else
   394             else
   395                 {
   395                 {
   396                 aProtected = DRM::EUProtected;    
   396                 aProtected = DRM::EUProtected;
   397                 }                               
   397                 }
   398             aAgent.Set( DRM::KDrmOmaAgentName );            
   398             aAgent.Set( DRM::KDrmOmaAgentName );
   399             }
   399             }
   400         else if ( (aContent)[0] == 1)
   400         else if ( (aContent)[0] == 1)
   401             {
   401             {
   402             // set the mimetype from the buffer which is in the beginning
   402             // set the mimetype from the buffer which is in the beginning
   403             // starting from byte 3 with the length specified at position 2     
   403             // starting from byte 3 with the length specified at position 2
   404             TPtrC8 mimeType( aContent.Mid(3, (aContent)[1]) );
   404             TPtrC8 mimeType( aContent.Mid(3, (aContent)[1]) );
   405             if( !mimeType.CompareF( *iOmaBasedMimeType ) )
   405             if( !mimeType.CompareF( *iOmaBasedMimeType ) )
   406                 {   
   406                 {
   407                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   407                 aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
   408                 isDrmFile = ETrue;
   408                 isDrmFile = ETrue;
   409                 aProtected = DRM::EUProtected;
   409                 aProtected = DRM::EUProtected;
   410                 }
   410                 }
   411             }
   411             }
   412         }
   412         }
   413     return isDrmFile;
   413     return isDrmFile;
   414     }      
   414     }
   415 
   415 
   416 // -----------------------------------------------------------------------------
   416 // -----------------------------------------------------------------------------
   417 // CDrmUtility::IsProtectedL
   417 // CDrmUtility::IsProtectedL
   418 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   419 //  
   419 //
   420 EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( RFile& aFileHandle ) const
   420 EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( RFile& aFileHandle ) const
   421     {
   421     {
   422     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   422     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   423     TPtrC agent( KNullDesC );
   423     TPtrC agent( KNullDesC );
   424     TBool isDrmFile( EFalse );
   424     TBool isDrmFile( EFalse );
   425     TBool isProtected( EFalse );
   425     TBool isProtected( EFalse );
   426     
   426 
   427     isDrmFile = GetDrmInfoL( aFileHandle, agent, protection );
   427     isDrmFile = GetDrmInfoL( aFileHandle, agent, protection );
   428     
   428 
   429     if ( isDrmFile && protection == DRM::EUProtected )
   429     if ( isDrmFile && protection == DRM::EUProtected )
   430         {
   430         {
   431         isProtected = ETrue;
   431         isProtected = ETrue;
   432         }
   432         }
   433     return isProtected;
   433     return isProtected;
   434     }
   434     }
   435 
   435 
   436     
   436 
   437 // -----------------------------------------------------------------------------
   437 // -----------------------------------------------------------------------------
   438 // CDrmUtility::IsProtectedL
   438 // CDrmUtility::IsProtectedL
   439 // -----------------------------------------------------------------------------
   439 // -----------------------------------------------------------------------------
   440 //  
   440 //
   441 EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( const TDesC8& aContent ) const
   441 EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( const TDesC8& aContent ) const
   442     {
   442     {
   443     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   443     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   444     TPtrC agent( KNullDesC );
   444     TPtrC agent( KNullDesC );
   445     TBool isDrmFile( EFalse );
   445     TBool isDrmFile( EFalse );
   446     TBool isProtected( EFalse );
   446     TBool isProtected( EFalse );
   447     
   447 
   448     isDrmFile = GetDrmInfoL( aContent, agent, protection );
   448     isDrmFile = GetDrmInfoL( aContent, agent, protection );
   449     
   449 
   450     if( isDrmFile && protection == DRM::EUProtected )
   450     if( isDrmFile && protection == DRM::EUProtected )
   451         {
   451         {
   452         isProtected = ETrue;
   452         isProtected = ETrue;
   453         }
   453         }
   454     return isProtected;
   454     return isProtected;
   456 
   456 
   457 
   457 
   458 // -----------------------------------------------------------------------------
   458 // -----------------------------------------------------------------------------
   459 // CDrmUtility::GetAgentL
   459 // CDrmUtility::GetAgentL
   460 // -----------------------------------------------------------------------------
   460 // -----------------------------------------------------------------------------
   461 //  
   461 //
   462 EXPORT_C TBool DRM::CDrmUtility::GetAgentL( 
   462 EXPORT_C TBool DRM::CDrmUtility::GetAgentL(
   463     RFile& aFileHandle,
   463     RFile& aFileHandle,
   464     TPtrC& aAgent ) const
   464     TPtrC& aAgent ) const
   465     {
   465     {
   466     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   466     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   467     TBool isDrmFile( EFalse );
   467     TBool isDrmFile( EFalse );
   468 
   468 
   469     isDrmFile = GetDrmInfoL( aFileHandle, aAgent, protection );
   469     isDrmFile = GetDrmInfoL( aFileHandle, aAgent, protection );
   470 
   470 
   471     return isDrmFile;
   471     return isDrmFile;
   472     }
   472     }
   473     
   473 
   474 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   475 // CDrmUtility::GetAgentL
   475 // CDrmUtility::GetAgentL
   476 // -----------------------------------------------------------------------------
   476 // -----------------------------------------------------------------------------
   477 //  
   477 //
   478 EXPORT_C TBool DRM::CDrmUtility::GetAgentL( 
   478 EXPORT_C TBool DRM::CDrmUtility::GetAgentL(
   479     const TDesC8& aContent,
   479     const TDesC8& aContent,
   480     TPtrC& aAgent ) const
   480     TPtrC& aAgent ) const
   481     {
   481     {
   482     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   482     DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
   483     TBool isDrmFile( EFalse );
   483     TBool isDrmFile( EFalse );
   484 
   484 
   485     isDrmFile = GetDrmInfoL( aContent, aAgent, protection );
   485     isDrmFile = GetDrmInfoL( aContent, aAgent, protection );
   486 
   486 
   487     return isDrmFile;
   487     return isDrmFile;
   488     }
   488     }
   489  	
   489 
   490 
   490 
   491 // -----------------------------------------------------------------------------
   491 // -----------------------------------------------------------------------------
   492 // CDrmUtility::CheckFileHandlerL
   492 // CDrmUtility::CheckFileHandlerL
   493 // Checks whether given filehandle is valid if not leaves with KErrArgument
   493 // Checks whether given filehandle is valid if not leaves with KErrArgument
   494 // (other items were commented in a header).
   494 // (other items were commented in a header).
   495 // -----------------------------------------------------------------------------
   495 // -----------------------------------------------------------------------------
   496 // 
   496 //
   497 EXPORT_C void DRM::CDrmUtility::CheckFileHandleL( RFile& aFileHandle ) const
   497 EXPORT_C void DRM::CDrmUtility::CheckFileHandleL( RFile& aFileHandle ) const
   498     {
   498     {
   499     if ( !aFileHandle.SubSessionHandle() )
   499     if ( !aFileHandle.SubSessionHandle() )
   500         {
   500         {
   501         User::Leave( KErrBadHandle );
   501         User::Leave( KErrBadHandle );
   502         }
   502         }
   503     }
   503     }
   504        
   504 
   505 //  End of File
   505 //  End of File