omadrm/drmplugins/drmfilter/src/HTTPFilterDRM.cpp
branchRCL_3
changeset 27 1481bf457703
parent 26 1221b68b8a5f
equal deleted inserted replaced
26:1221b68b8a5f 27:1481bf457703
     1 /*
     1 /*
     2  * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2006 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                 CleanupStack::PushL( drmData );
   521                 iDataSups.Append( drmData );
   522                 iDataSups.AppendL ( drmData );
       
   523                 CleanupStack::Pop( drmData );
       
   524                 response.SetBody( *drmData );
   522                 response.SetBody( *drmData );
   525                 
       
   526 
   523 
   527                 // change the mime type to "application/vnd.oma.drm.content"
   524                 // change the mime type to "application/vnd.oma.drm.content"
   528                 headers.RemoveField( fieldNameStr );
   525                 headers.RemoveField( fieldNameStr );
   529                 headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
   526                 headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
   530 
   527 
   567                     CHTTPFilterDRMDataSupplier* drmData = 0;
   564                     CHTTPFilterDRMDataSupplier* drmData = 0;
   568                     drmData
   565                     drmData
   569                         = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   566                         = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
   570                             response.Body(),
   567                             response.Body(),
   571                             const_cast<CHTTPFilterDRM*> ( this ) );
   568                             const_cast<CHTTPFilterDRM*> ( this ) );
   572                     CleanupStack::PushL( drmData );
   569                     iDataSups.Append( drmData );
   573                     iDataSups.AppendL ( drmData );
       
   574                     CleanupStack::Pop( drmData );
       
   575                     }
   570                     }
   576 
   571 
   577                 }
   572                 }
   578 
   573 
   579             CleanupStack::PopAndDestroy( &DRMHeaderNameF );
   574             CleanupStack::PopAndDestroy( &DRMHeaderNameF );
   633         CleanupStack::PopAndDestroy( &cfmValStr );
   628         CleanupStack::PopAndDestroy( &cfmValStr );
   634 
   629 
   635         // Do not encrypt JAD files:
   630         // Do not encrypt JAD files:
   636         if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
   631         if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
   637             {
   632             {
   638             // If it is a JAD always ignore any of the above:
   633             // If it is a JAD always ignore any of the above:   
   639             const TBuf8<sizeof( KJADString )> JADStringBuf( KJADString );
   634             const TBuf8<sizeof( KJADString )> JADStringBuf( KJADString );
   640             RStringF JADValue = strP.OpenFStringL( JADStringBuf );
   635             RStringF JADValue = strP.OpenFStringL( JADStringBuf );
   641             CleanupClosePushL( JADValue );
   636             CleanupClosePushL( JADValue );
   642 
   637 
   643             RStringF jadFieldValStr = strP.StringF( fieldVal.StrF() );
   638             RStringF jadFieldValStr = strP.StringF( fieldVal.StrF() );
   665                 {
   660                 {
   666                 delete drmData;
   661                 delete drmData;
   667                 User::Leave( KErrUnknown );
   662                 User::Leave( KErrUnknown );
   668                 }
   663                 }
   669 
   664 
   670             CleanupStack::PushL( drmData );
   665             iDataSups.Append( drmData );
   671             iDataSups.AppendL ( drmData );
       
   672             CleanupStack::Pop( drmData );
       
   673                 
       
   674             response.SetBody( *drmData );
   666             response.SetBody( *drmData );
   675 
   667 
   676             ///
   668             ///         
   677             RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
   669             RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
   678             CleanupClosePushL( DRMValue1 );
   670             CleanupClosePushL( DRMValue1 );
   679 
   671 
   680             RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
   672             RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
   681             CleanupClosePushL( DRMValue3 );
   673             CleanupClosePushL( DRMValue3 );