omadrm/drmplugins/drmfilter/src/HTTPFilterDRM.cpp
branchRCL_3
changeset 26 1221b68b8a5f
parent 12 8a03a285ab14
child 27 1481bf457703
equal deleted inserted replaced
25:50c53e893c3f 26:1221b68b8a5f
     1 /*
     1 /*
     2  * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   215     delete this;
   215     delete this;
   216     }
   216     }
   217 
   217 
   218 //------------------------------------------------------------------------
   218 //------------------------------------------------------------------------
   219 // CHTTPFilterDRM::MHFRunL
   219 // CHTTPFilterDRM::MHFRunL
   220 // See MHTTPFilterBase::MHFRunL 
   220 // See MHTTPFilterBase::MHFRunL
   221 //------------------------------------------------------------------------
   221 //------------------------------------------------------------------------
   222 //
   222 //
   223 void CHTTPFilterDRM::MHFRunL( RHTTPTransaction aTransaction,
   223 void CHTTPFilterDRM::MHFRunL( RHTTPTransaction aTransaction,
   224     const THTTPEvent& aEvent )
   224     const THTTPEvent& aEvent )
   225     {
   225     {
   318         case KErrCANotSupported:
   318         case KErrCANotSupported:
   319         case KErrCANoPermission:
   319         case KErrCANoPermission:
   320         case KErrCANoRights:
   320         case KErrCANoRights:
   321         case KErrCorrupt:
   321         case KErrCorrupt:
   322             {
   322             {
   323             error = NW_STAT_FAILURE; //Unable to perform operation   
   323             error = NW_STAT_FAILURE; //Unable to perform operation
   324             }
   324             }
   325             break;
   325             break;
   326         case KErrArgument:
   326         case KErrArgument:
   327             {
   327             {
   328             error = KBadMimeType;
   328             error = KBadMimeType;
   459 
   459 
   460 //------------------------------------------------------------------------
   460 //------------------------------------------------------------------------
   461 // CHTTPFilterDRM::CheckHeadersL
   461 // CHTTPFilterDRM::CheckHeadersL
   462 // Check HTTP headers and extract MIME type
   462 // Check HTTP headers and extract MIME type
   463 //------------------------------------------------------------------------
   463 //------------------------------------------------------------------------
   464 // 
   464 //
   465 void CHTTPFilterDRM::CheckHeadersL( const RHTTPTransaction& aTrans )
   465 void CHTTPFilterDRM::CheckHeadersL( const RHTTPTransaction& aTrans )
   466     {
   466     {
   467     // read the header data and check the MIME type here    
   467     // read the header data and check the MIME type here
   468     // check the status and body
   468     // check the status and body
   469     RHTTPResponse response = aTrans.Response();
   469     RHTTPResponse response = aTrans.Response();
   470     TInt status = response.StatusCode();
   470     TInt status = response.StatusCode();
   471 
   471 
   472 #if defined (_DEBUG) && defined (_LOGGING)
   472 #if defined (_DEBUG) && defined (_LOGGING)
   510                 CHTTPFilterDRMDataSupplier* drmData = 0;
   510                 CHTTPFilterDRMDataSupplier* drmData = 0;
   511 
   511 
   512                 drmData = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   512                 drmData = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   513                     response.Body(), const_cast<CHTTPFilterDRM*> ( this ) );
   513                     response.Body(), const_cast<CHTTPFilterDRM*> ( this ) );
   514                 /** Support for Hutchinson's content protection scheme, CFM
   514                 /** Support for Hutchinson's content protection scheme, CFM
   515                  *  
   515                  *
   516                  */
   516                  */
   517                 drmData->SetProcessedContentType( EStandardDRMContent );
   517                 drmData->SetProcessedContentType( EStandardDRMContent );
   518                 /**
   518                 /**
   519                  *
   519                  *
   520                  */
   520                  */
   521                 iDataSups.Append( drmData );
   521                 CleanupStack::PushL( drmData );
       
   522                 iDataSups.AppendL ( drmData );
       
   523                 CleanupStack::Pop( drmData );
   522                 response.SetBody( *drmData );
   524                 response.SetBody( *drmData );
       
   525                 
   523 
   526 
   524                 // change the mime type to "application/vnd.oma.drm.content"
   527                 // change the mime type to "application/vnd.oma.drm.content"
   525                 headers.RemoveField( fieldNameStr );
   528                 headers.RemoveField( fieldNameStr );
   526                 headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
   529                 headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
   527 
   530 
   564                     CHTTPFilterDRMDataSupplier* drmData = 0;
   567                     CHTTPFilterDRMDataSupplier* drmData = 0;
   565                     drmData
   568                     drmData
   566                         = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   569                         = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   567                             response.Body(),
   570                             response.Body(),
   568                             const_cast<CHTTPFilterDRM*> ( this ) );
   571                             const_cast<CHTTPFilterDRM*> ( this ) );
   569                     iDataSups.Append( drmData );
   572                     CleanupStack::PushL( drmData );
       
   573                     iDataSups.AppendL ( drmData );
       
   574                     CleanupStack::Pop( drmData );
   570                     }
   575                     }
   571 
   576 
   572                 }
   577                 }
   573 
   578 
   574             CleanupStack::PopAndDestroy( &DRMHeaderNameF );
   579             CleanupStack::PopAndDestroy( &DRMHeaderNameF );
   628         CleanupStack::PopAndDestroy( &cfmValStr );
   633         CleanupStack::PopAndDestroy( &cfmValStr );
   629 
   634 
   630         // Do not encrypt JAD files:
   635         // Do not encrypt JAD files:
   631         if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
   636         if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
   632             {
   637             {
   633             // If it is a JAD always ignore any of the above:   
   638             // If it is a JAD always ignore any of the above:
   634             const TBuf8<sizeof( KJADString )> JADStringBuf( KJADString );
   639             const TBuf8<sizeof( KJADString )> JADStringBuf( KJADString );
   635             RStringF JADValue = strP.OpenFStringL( JADStringBuf );
   640             RStringF JADValue = strP.OpenFStringL( JADStringBuf );
   636             CleanupClosePushL( JADValue );
   641             CleanupClosePushL( JADValue );
   637 
   642 
   638             RStringF jadFieldValStr = strP.StringF( fieldVal.StrF() );
   643             RStringF jadFieldValStr = strP.StringF( fieldVal.StrF() );
   660                 {
   665                 {
   661                 delete drmData;
   666                 delete drmData;
   662                 User::Leave( KErrUnknown );
   667                 User::Leave( KErrUnknown );
   663                 }
   668                 }
   664 
   669 
   665             iDataSups.Append( drmData );
   670             CleanupStack::PushL( drmData );
       
   671             iDataSups.AppendL ( drmData );
       
   672             CleanupStack::Pop( drmData );
       
   673                 
   666             response.SetBody( *drmData );
   674             response.SetBody( *drmData );
   667 
   675 
   668             ///         
   676             ///
   669             RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
   677             RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
   670             CleanupClosePushL( DRMValue1 );
   678             CleanupClosePushL( DRMValue1 );
   671 
   679 
   672             RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
   680             RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
   673             CleanupClosePushL( DRMValue3 );
   681             CleanupClosePushL( DRMValue3 );