--- a/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp Thu Oct 14 13:45:23 2010 +0300
+++ b/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp Wed Oct 20 14:56:54 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -36,7 +36,7 @@
const TUint32 KMusicServiceFeatureFlagSupport = 0x00000012; // referred from 5.0 MusicWapCenRepKeys.h - Album Download
_LIT8( KCameseDrmHeaderFilterName, "CameseDrmHeader" );
-_LIT8( KDataTypeCameseDRM,"application/vnd.ms-wmdrm.lic-chlg-req" );
+_LIT8( KDataTypeCameseDRM,"application/vnd.ms-wmdrm.lic-chlg-req" );
// ============================ MEMBER FUNCTIONS ===============================
@@ -49,7 +49,7 @@
: iSession(aSession),
iTransactionId(KErrNotFound),
iState(EIdle),
- iDataSupplierSet(EFalse)
+ iDataSupplierSet(EFalse)
{
}
@@ -60,46 +60,46 @@
// -----------------------------------------------------------------------------
//
void CHttpFilterCameseDrmHeader::ConstructL()
- {
+ {
iStringPool = iSession->StringPool();
iStringPool.OpenL(RHTTPSession::GetTable());
-
- // Filter Name
+
+ // Filter Name
RStringF filterName = iStringPool.OpenFStringL( KCameseDrmHeaderFilterName() );
CleanupClosePushL( filterName );
-
+
// Register the filter for the HTTP events we are interested.
iSession->FilterCollection().AddFilterL(*this, // The filter to add
- THTTPEvent::EGotResponseHeaders,
- RStringF(),
- KAnyStatusCode,
- KCameseDrmHeaderFilterPosition,
+ THTTPEvent::EGotResponseHeaders,
+ RStringF(),
+ KAnyStatusCode,
+ KCameseDrmHeaderFilterPosition,
filterName);
-
+
iSession->FilterCollection().AddFilterL(*this, // The filter to add
- THTTPEvent::EGotResponseBodyData,
- RStringF(),
- KAnyStatusCode,
- KCameseDrmHeaderFilterPosition,
+ THTTPEvent::EGotResponseBodyData,
+ RStringF(),
+ KAnyStatusCode,
+ KCameseDrmHeaderFilterPosition,
filterName);
-
+
iSession->FilterCollection().AddFilterL(*this, // The filter to add
- THTTPEvent::EResponseComplete,
- RStringF(),
- KAnyStatusCode,
- KCameseDrmHeaderFilterPosition,
+ THTTPEvent::EResponseComplete,
+ RStringF(),
+ KAnyStatusCode,
+ KCameseDrmHeaderFilterPosition,
filterName);
-
+
iSession->FilterCollection().AddFilterL(*this, // The filter to add
- THTTPEvent::ECancel,
- RStringF(),
- KAnyStatusCode,
- KCameseDrmHeaderFilterPosition,
+ THTTPEvent::ECancel,
+ RStringF(),
+ KAnyStatusCode,
+ KCameseDrmHeaderFilterPosition,
filterName);
-
- CleanupStack::PopAndDestroy(&filterName);
+
+ CleanupStack::PopAndDestroy(&filterName);
}
//------------------------------------------------------------------------------
@@ -110,23 +110,23 @@
{
CAMESE_LOG("CHttpFilterCameseDrmHeader::~CHttpFilterCameseDrmHeader");
- Reset();
- if ( iLoadCount )
- {
- // As we're already in a destructor, MHFUnload must not delete us again
- iLoadCount = -1;
+ Reset();
+ if ( iLoadCount )
+ {
+ // As we're already in a destructor, MHFUnload must not delete us again
+ iLoadCount = -1;
RStringF filterName;
- TRAPD( error, filterName = iStringPool.OpenFStringL(
+ TRAPD( error, filterName = iStringPool.OpenFStringL(
KCameseDrmHeaderFilterName ) );
- if ( !error && iSession )
+ if ( !error && iSession )
{
- iSession->FilterCollection().RemoveFilter( filterName );
+ iSession->FilterCollection().RemoveFilter( filterName );
}
- filterName.Close();
- }
+ filterName.Close();
+ }
delete iDlaHandler;
- }
+ }
// -----------------------------------------------------------------------------
// CHttpFilterCameseDrmHeader::NewL
@@ -137,8 +137,8 @@
{
ASSERT( aSession );
CAMESE_LOG( "CHttpFilterCameseDrmHeader::NewL" );
-
- CHttpFilterCameseDrmHeader* filter =
+
+ CHttpFilterCameseDrmHeader* filter =
new (ELeave) CHttpFilterCameseDrmHeader (reinterpret_cast< RHTTPSession* >( aSession ) );
CleanupStack::PushL( filter );
filter->ConstructL();
@@ -151,7 +151,7 @@
// -----------------------------------------------------------------------------
//
void CHttpFilterCameseDrmHeader::MHFLoad(
- RHTTPSession /*aSession*/,
+ RHTTPSession /*aSession*/,
THTTPFilterHandle /*aFilterHandler*/ )
{
CAMESE_LOG( "CHttpFilterCameseDrmHeader::MHFLoad" );
@@ -163,18 +163,18 @@
// -----------------------------------------------------------------------------
//
void CHttpFilterCameseDrmHeader::MHFUnload(
- RHTTPSession /*aSession*/,
+ RHTTPSession /*aSession*/,
THTTPFilterHandle /*aFilterHandler*/ )
{
CAMESE_LOG( "CHttpFilterCameseDrmHeader::MHFUnload" );
ASSERT( iLoadCount > 0 );
- if ( --iLoadCount )
- {
- return;
+ if ( --iLoadCount )
+ {
+ return;
}
-
- delete this;
+
+ delete this;
}
// -----------------------------------------------------------------------------
@@ -188,58 +188,58 @@
// Check if we are interested in the transaction
if ( (iTransactionId != KErrNotFound ) &&
(aTransaction.Id() != iTransactionId) )
- {
+ {
return;
}
- CAMESE_LOG1( "CHttpFilterCameseDrmHeader::MHFRunL aEvent=%i",
- aEvent.iStatus );
+ CAMESE_LOG1( "CHttpFilterCameseDrmHeader::MHFRunL aEvent=%i",
+ aEvent.iStatus );
switch( aEvent.iStatus )
{
- case THTTPEvent::EGotResponseHeaders:
- // Only interested in headers if in idle state.
- if ( iState == EIdle )
- {
+ case THTTPEvent::EGotResponseHeaders:
+ // Only interested in headers if in idle state.
+ if ( iState == EIdle )
+ {
CheckResponseHeadersL( aTransaction );
- }
- break;
-
- case THTTPEvent::EGotResponseBodyData:
- if ( iState == EDrmHeaderCapture )
- {
- CaptureDrmHeaderL( aTransaction );
- }
- break;
-
- case THTTPEvent::EResponseComplete:
- if ( iState == EDrmHeaderCapture )
- {
- RequestLicenseL( aTransaction );
- }
- break;
-
+ }
+ break;
+
+ case THTTPEvent::EGotResponseBodyData:
+ if ( iState == EDrmHeaderCapture )
+ {
+ CaptureDrmHeaderL( aTransaction );
+ }
+ break;
+
+ case THTTPEvent::EResponseComplete:
+ if ( iState == EDrmHeaderCapture )
+ {
+ RequestLicenseL( aTransaction );
+ }
+ break;
+
case THTTPEvent::ECancel:
- CAMESE_LOG(
+ CAMESE_LOG(
"CHttpFilterCameseDrmHeader::MHFRunL Handling Cancelation" );
if ( iState == ERequestingLicense )
{
// Asynchronous cancelation while the
// filter is blocked.
-
+
CAMESE_LOG(
"CHttpFilterCameseDrmHeader::MHFRunL Canceling Camese" );
// Need to unblock the license request.
if ( iDlaHandler )
{
iDlaHandler->CancelLicenseAcquisition();
- }
+ }
}
break;
-
- default:
- // Stray event
- ASSERT( ETrue );
- break;
+
+ default:
+ // Stray event
+ ASSERT( ETrue );
+ break;
}
}
@@ -247,61 +247,61 @@
//------------------------------------------------------------------------
// CHttpFilterCameseDrmHeader::CheckResponseHeadersL
//------------------------------------------------------------------------
-//
-void CHttpFilterCameseDrmHeader::CheckResponseHeadersL(
+//
+void CHttpFilterCameseDrmHeader::CheckResponseHeadersL(
RHTTPTransaction& aTrans )
- {
- RHTTPHeaders responseHeaders = aTrans.Response().GetHeaderCollection();
-
- RStringF contentTypeNameStr =
- iStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+ {
+ RHTTPHeaders responseHeaders = aTrans.Response().GetHeaderCollection();
- // read the first part of content-type field
- THTTPHdrVal contentTypeVal;
+ RStringF contentTypeNameStr =
+ iStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+
+ // read the first part of content-type field
+ THTTPHdrVal contentTypeVal;
- if( !responseHeaders.GetField( contentTypeNameStr, 0, contentTypeVal ) )
- {
- if ( contentTypeVal.StrF().DesC().MatchF( KDataTypeCameseDRM ) !=
+ if( !responseHeaders.GetField( contentTypeNameStr, 0, contentTypeVal ) )
+ {
+ if ( contentTypeVal.StrF().DesC().MatchF( KDataTypeCameseDRM ) !=
KErrNotFound )
- {
- CAMESE_LOG( "CHttpFilterCameseDrmHeader::CheckResponseHeaders Found Drm Header" );
+ {
+ CAMESE_LOG( "CHttpFilterCameseDrmHeader::CheckResponseHeaders Found Drm Header" );
StartDrmHeaderCaptureL( aTrans );
- }
- }
+ }
+ }
}
-
+
//------------------------------------------------------------------------
// CHttpFilterCameseDrmHeader::StartDrmHeaderCaptureL
//------------------------------------------------------------------------
-//
-void CHttpFilterCameseDrmHeader::StartDrmHeaderCaptureL(
+//
+void CHttpFilterCameseDrmHeader::StartDrmHeaderCaptureL(
RHTTPTransaction& aTrans )
- {
+ {
// Start processing the Drm Header Packet.
RHTTPHeaders responseHeaders = aTrans.Response().GetHeaderCollection();
- RStringF contentTypeNameStr =
+ RStringF contentTypeNameStr =
iStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
- RStringF cacheControlStr =
+ RStringF cacheControlStr =
iStringPool.StringF( HTTP::ECacheControl, RHTTPSession::GetTable() );
- RStringF noCacheVal =
+ RStringF noCacheVal =
iStringPool.StringF( HTTP::ENoCache, RHTTPSession::GetTable() );
-
+
// Cache the transaction id
iTransactionId = aTrans.Id();
-
+
// Add a Cache-Control field indicating no-cache.
// This will keep our response from being cached.
responseHeaders.SetFieldL( cacheControlStr, THTTPHdrVal( noCacheVal ) );
- // Set the HTTP Status code as KErrCompletion -
+ // Set the HTTP Status code as KErrCompletion -
// this will avoid letting download manager finalize
// the temporary drm header download.
-
+
// Album - Album Download
-
+
TInt value( 0 );
TBool omaDdSupported( EFalse );
-
+
CRepository* repository( NULL );
TRAPD( err, repository = CRepository::NewL( KCRUidMusicShopSettings ) );
@@ -310,7 +310,7 @@
// read value of KMusicServiceFeatureFlagSupport from repository
// KCRUidMusicShopSettings and check if KSupportOmaDownloadDescriptor bit is set
// in that value
-
+
err = repository->Get( KMusicServiceFeatureFlagSupport, value );
if ( !err )
{
@@ -320,54 +320,54 @@
omaDdSupported = ETrue;
}
}
-
+
delete repository;
}
if ( !omaDdSupported )
- {
+ {
aTrans.Response().SetStatusCode( KErrCompletion );
}
-
+
// Album - Album Download
// Change state to DRM Header Capture mode.
- iState = EDrmHeaderCapture;
+ iState = EDrmHeaderCapture;
}
//------------------------------------------------------------------------
// CHttpFilterCameseDownloader::ConnectionAccessPoint
//------------------------------------------------------------------------
-//
+//
TInt CHttpFilterCameseDrmHeader::ConnectionAccessPoint(
RHTTPTransaction& aTrans )
{
TInt ap( 0 );
-
- // Retrieve connection information from the http session
+
+ // Retrieve connection information from the http session
const RHTTPConnectionInfo& connInfo = aTrans.Session().ConnectionInfo();
RConnection* connPtr = NULL;
-
+
THTTPHdrVal connHeader;
TBool hasConnValue = connInfo.Property(
- iStringPool.StringF(
+ iStringPool.StringF(
HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
connHeader );
-
- // If we have access to the RConnection pointer, try to retrieve the IAP id.
+
+ // If we have access to the RConnection pointer, try to retrieve the IAP id.
if ( hasConnValue )
{
// Got RConnection Property
connPtr = REINTERPRET_CAST( RConnection*, connHeader.Int() );
-
+
// Now retrieve the access point id.
if ( connPtr )
- {
+ {
TConnectionInfo connectionInfo;
TUint count = 0;
if ( !connPtr->EnumerateConnections(count) )
- {
+ {
TPckg<TConnectionInfo> pkg(connectionInfo);
if ( !connPtr->GetConnectionInfo( 1, pkg ) )
{
@@ -376,91 +376,91 @@
}
}
}
-
- return ap;
+
+ return ap;
}
//------------------------------------------------------------------------
// CHttpFilterCameseDownloader::CaptureDrmHeaderL
//------------------------------------------------------------------------
-//
-void CHttpFilterCameseDrmHeader::CaptureDrmHeaderL(
+//
+void CHttpFilterCameseDrmHeader::CaptureDrmHeaderL(
RHTTPTransaction& aTrans )
- {
+ {
TPtrC8 ptr;
- MHTTPDataSupplier* dataSupplier = aTrans.Response().Body();
+ MHTTPDataSupplier* dataSupplier = aTrans.Response().Body();
dataSupplier->GetNextDataPart( ptr );
// Append to iDrmHeaderBuffer
if ( !iDrmHeaderBuffer )
{
- iDrmHeaderBuffer = ptr.AllocL();
- }
+ iDrmHeaderBuffer = ptr.AllocL();
+ }
else
- {
- iDrmHeaderBuffer = iDrmHeaderBuffer->ReAllocL(
- iDrmHeaderBuffer->Length() + ptr.Length() );
- iDrmHeaderBuffer->Des().Append( ptr );
- }
+ {
+ iDrmHeaderBuffer = iDrmHeaderBuffer->ReAllocL(
+ iDrmHeaderBuffer->Length() + ptr.Length() );
+ iDrmHeaderBuffer->Des().Append( ptr );
+ }
- if ( !iDataSupplierSet )
- {
+ if ( !iDataSupplierSet )
+ {
// Feed the actual client with our data supplier, that will feed an empty
// descriptor.
delete iClientDataSupplier;
- iClientDataSupplier = NULL;
- iClientDataSupplier =
+ iClientDataSupplier = NULL;
+ iClientDataSupplier =
CHttpFilterCameseDataSupplier::NewL( aTrans.Response().Body(),
KNullDesC8() );
-
+
aTrans.Response().SetBody( *iClientDataSupplier );
iDataSupplierSet = ETrue;
- }
+ }
}
//------------------------------------------------------------------------
// CHttpFilterCameseDrmHeader::RequestLicenseL
//------------------------------------------------------------------------
-//
+//
void CHttpFilterCameseDrmHeader::RequestLicenseL( RHTTPTransaction& aTrans )
- {
+ {
ASSERT( iDrmHeaderBuffer );
CAMESE_LOG(
"CHttpFilterCameseDrmHeader::RequestLicenseL Passing in Drm Header" );
-
+
if ( !iDlaHandler )
{
iDlaHandler = CWmDrmDlaHandler::NewL();
}
-
+
// Pass in our current access point to the drm interface.
iDlaHandler->SetIapId( ConnectionAccessPoint( aTrans ) );
-
+
// Use the Camese Interface, passing in
// the DRM header url. WMDRM DLA Handler uses it for
// error reporting.
- HBufC8* errorUrl8( aTrans.Request().URI().UriDes().AllocLC() );
+ HBufC8* errorUrl8( aTrans.Request().URI().UriDes().AllocLC() );
HBufC* errorUrl( CnvUtfConverter::ConvertToUnicodeFromUtf8L( *errorUrl8 ) );
CleanupStack::PushL( errorUrl );
-
+
HBufC* contentUrl( NULL );
HBufC* htmlData( NULL );
-
+
// Update state
iState = ERequestingLicense;
-
+
// This call blocks and only returns after Camese is done with the licensing
// process.
TRAPD( result, iDlaHandler->AcquireLicenseFromDrmHeaderL( *iDrmHeaderBuffer,
errorUrl,
contentUrl,
htmlData ) );
-
+
CAMESE_LOG("CHttpFilterCameseDrmHeader::RequestLicenseL Unblocked");
-
+
delete htmlData;
-
+
HBufC8* contentUrl8( NULL );
if ( contentUrl )
{
@@ -469,50 +469,50 @@
CleanupStack::PopAndDestroy( contentUrl );
}
CleanupStack::PushL( contentUrl8 );
-
-
+
+
// Check if the filter has not been canceled.
if ( result != KErrCancel )
- {
+ {
HandleRedirectL( result, aTrans, contentUrl8 );
}
CleanupStack::PopAndDestroy( 3, errorUrl8 ); //contentUrl8, errorUrl, errorUrl8
-
- // Reset state machine.
- Reset();
+
+ // Reset state machine.
+ Reset();
}
//------------------------------------------------------------------------
// CHttpFilterCameseDrmHeader::HandleRedirectL
//------------------------------------------------------------------------
-//
+//
void CHttpFilterCameseDrmHeader::HandleRedirectL(
- TInt aResult,
+ TInt CAMESE_LOG_DEF( aResult ),
RHTTPTransaction& aTrans,
HBufC8*& aContentUrl )
- {
+ {
// Now check if we have a content URL to redirect to,
// and if the content URL is not the DRM Header URL we
// passed in.
if ( aContentUrl && aContentUrl->CompareF( aTrans.Request().URI().UriDes() ) )
- {
+ {
TUriParser8 uri;
TInt err = uri.Parse( *aContentUrl );
-
+
if ( !err )
- {
- CAMESE_LOG(
+ {
+ CAMESE_LOG(
"CHttpFilterCameseDrmHeader::RequestLicenseL Redirecting" );
- CAMESE_LOG8_1( " > ContentUrl = %S", aContentUrl );
+ CAMESE_LOG8_1( " > ContentUrl = %S", aContentUrl );
CAMESE_LOG1( " > Licensing Result = %d", aResult );
-
+
// Cancel the Transaction.
aTrans.Cancel();
// Set new URI - could be content or error page.
aTrans.Request().SetURIL( uri );
-
-
+
+
// update for - Album Download
// Manually replace HOST firld in the HTTP header to reflect the new host
//
@@ -522,35 +522,35 @@
TInt error = headers.RemoveField(hostStr);
CAMESE_LOG1(" error for removing HOST field from header = %d", error);
if (error == KErrNone || error == KErrNotFound)
- {
- HBufC* host =aTrans.Request().URI().DisplayFormL(EUriHost);
- CleanupStack::PushL(host);
- HBufC8* host8 = HBufC8::NewL(host->Length());
- CleanupStack::PushL(host8);
- host8->Des().Copy(*host);
- CAMESE_LOG8_1(" > new host = %S", host8);
- RStringF hostValueStr = aTrans.Session().StringPool().OpenFStringL(*host8);
- CleanupClosePushL<RStringF>(hostValueStr);
- headers.SetFieldL( hostStr, THTTPHdrVal(hostValueStr) );
- CleanupStack::PopAndDestroy(3, host); // hostValueStr, host8, host
- }
+ {
+ HBufC* host =aTrans.Request().URI().DisplayFormL(EUriHost);
+ CleanupStack::PushL(host);
+ HBufC8* host8 = HBufC8::NewL(host->Length());
+ CleanupStack::PushL(host8);
+ host8->Des().Copy(*host);
+ CAMESE_LOG8_1(" > new host = %S", host8);
+ RStringF hostValueStr = aTrans.Session().StringPool().OpenFStringL(*host8);
+ CleanupClosePushL<RStringF>(hostValueStr);
+ headers.SetFieldL( hostStr, THTTPHdrVal(hostValueStr) );
+ CleanupStack::PopAndDestroy(3, host); // hostValueStr, host8, host
+ }
else
- {
- User::Leave(error);
- }
+ {
+ User::Leave(error);
+ }
CleanupStack::PopAndDestroy(&hostStr);
// update end for - Album Download
-
- // Submit the new transaction.
- aTrans.SubmitL();
+
+ // Submit the new transaction.
+ aTrans.SubmitL();
}
else
{
- CAMESE_LOG(
+ CAMESE_LOG(
"CHttpFilterCameseDrmHeader::RequestLicenseL Malformed Url" );
// Fail the transaction
aTrans.Fail();
- }
+ }
}
else
{
@@ -565,18 +565,18 @@
// -----------------------------------------------------------------------------
//
void CHttpFilterCameseDrmHeader::Reset()
- {
- CAMESE_LOG("CHttpFilterCameseDrmHeader::Reset");
+ {
+ CAMESE_LOG("CHttpFilterCameseDrmHeader::Reset");
iState = EIdle;
iTransactionId = KErrNotFound;
-
+
delete iDrmHeaderBuffer;
- iDrmHeaderBuffer = NULL;
-
+ iDrmHeaderBuffer = NULL;
+
delete iClientDataSupplier;
iClientDataSupplier = NULL;
iDataSupplierSet = EFalse;
-
+
delete iDlaHandler;
iDlaHandler = NULL;
}
@@ -586,17 +586,17 @@
// -----------------------------------------------------------------------------
//
TInt CHttpFilterCameseDrmHeader::MHFRunError(
- TInt aError,
+ TInt CAMESE_LOG_DEF( aError ),
RHTTPTransaction aTransaction,
- const THTTPEvent& aEvent )
+ const THTTPEvent& CAMESE_LOG_DEF( aEvent ) )
{
// Log errors
CAMESE_LOG2("CHttpFilterCameseDrmHeader::MHFRunError Error = %i Event = %i",
aError,
aEvent.iStatus);
-
+
aTransaction.Fail();
-
+
Reset();
return KErrNone;
}