15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <http/rhttptransaction.h> |
18 #include <http/rhttptransaction.h> |
19 #include <barsc.h> |
19 #include <barsc.h> |
20 #include <drmcommon.h> |
20 #include <DRMCommon.h> |
21 #include <f32file.h> |
21 #include <f32file.h> |
22 #include <s32buf.h> |
22 #include <s32buf.h> |
23 #include <drmmessageparser.h> |
23 #include <DRMMessageParser.h> |
24 #include <caf/caf.h> |
24 #include <caf/caf.h> |
25 #include <oma2agent.h> |
25 #include <caf/cafplatform.h> |
26 |
26 #include <Oma2Agent.h> |
27 #include "httpfilterdrmdatasupplier.h" |
27 |
28 #include "httpfilterdrm.h" |
28 #include "HTTPFilterDRMDataSupplier.h" |
|
29 #include "HTTPFilterDRM.h" |
29 |
30 |
30 //------------------------------------------------------------------------ |
31 //------------------------------------------------------------------------ |
31 |
32 |
32 const TInt KMinContentSizeToGetTheURI = 520; |
33 const TInt KMinContentSizeToGetTheURI = 520; |
33 const TInt KDefaultSize( 2048 ); |
34 const TInt KDefaultSize( 2048 ); |
55 |
56 |
56 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
57 // CHTTPFilterDRMDataSupplier::NewL |
58 // CHTTPFilterDRMDataSupplier::NewL |
58 // Two-phase constructor, CFM |
59 // Two-phase constructor, CFM |
59 // ----------------------------------------------------------------------------- |
60 // ----------------------------------------------------------------------------- |
60 // |
61 // |
61 CHTTPFilterDRMDataSupplier* CHTTPFilterDRMDataSupplier::NewL( TInt aTransId, |
62 CHTTPFilterDRMDataSupplier* CHTTPFilterDRMDataSupplier::NewL( TInt aTransId, |
62 MHTTPDataSupplier* iDataBody, TProcessedContentType aType, |
63 MHTTPDataSupplier* iDataBody, TProcessedContentType aType, |
63 CHTTPFilterDRM* aOwner ) |
64 CHTTPFilterDRM* aOwner ) |
64 { |
65 { |
65 CHTTPFilterDRMDataSupplier* self = |
66 CHTTPFilterDRMDataSupplier* self = |
77 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
78 // |
79 // |
79 CHTTPFilterDRMDataSupplier::CHTTPFilterDRMDataSupplier( TInt aTransId, |
80 CHTTPFilterDRMDataSupplier::CHTTPFilterDRMDataSupplier( TInt aTransId, |
80 MHTTPDataSupplier* iDataBody, CHTTPFilterDRM* aOwner ) : |
81 MHTTPDataSupplier* iDataBody, CHTTPFilterDRM* aOwner ) : |
81 iTransId( aTransId ), iBufPtr( 0, 0 ), iPHData( iDataBody ), iSendReady( |
82 iTransId( aTransId ), iBufPtr( 0, 0 ), iPHData( iDataBody ), iSendReady( |
82 EFalse ), iOwner( aOwner ) |
83 EFalse ), iLastPart( EFalse ), iOwner( aOwner ) |
83 { |
84 { |
84 iDRMMessageParser = 0; |
85 iDRMMessageParser = 0; |
85 iPrevPos = 0; |
86 iPrevPos = 0; |
86 iMemBuf = 0; |
87 iMemBuf = 0; |
87 iDataPartSize = KWholeDataPart; |
88 iDataPartSize = KWholeDataPart; |
267 permission->iPrint = CDRMConstraint::NewL(); |
268 permission->iPrint = CDRMConstraint::NewL(); |
268 |
269 |
269 permission->iAvailableRights = ERightsPlay | ERightsDisplay |
270 permission->iAvailableRights = ERightsPlay | ERightsDisplay |
270 | ERightsExecute | ERightsPrint; |
271 | ERightsExecute | ERightsPrint; |
271 |
272 |
272 permission->iRightsObjectVersion.iVersionMain = 1; // major version for Oma 1 Rights Objects |
273 permission->iRightsObjectVersion.iVersionMain = 1; // major version for Oma 1 Rights Objects |
273 |
274 |
274 // "ringtone=no" present |
275 // "ringtone=no" present |
275 permission->iInfoBits = ENoRingingTone; |
276 permission->iInfoBits = ENoRingingTone; |
276 |
277 |
277 // Set the permission to the rights class, it will duplicate the permission |
278 // Set the permission to the rights class, it will duplicate the permission |
278 rights->SetPermissionL( *permission ); |
279 rights->SetPermissionL( *permission ); |
279 |
280 |
348 // ----------------------------------------------------------------------------- |
349 // ----------------------------------------------------------------------------- |
349 // |
350 // |
350 TBool CHTTPFilterDRMDataSupplier::GetNextDataPart( TPtrC8& aDataPart ) |
351 TBool CHTTPFilterDRMDataSupplier::GetNextDataPart( TPtrC8& aDataPart ) |
351 { |
352 { |
352 |
353 |
|
354 // First call after releasedata |
353 if ( iDataPartSize == KWholeDataPart ) |
355 if ( iDataPartSize == KWholeDataPart ) |
354 { |
356 { |
355 aDataPart.Set( iMemBuf->iBuf->GetPtr() ); |
357 aDataPart.Set( iMemBuf->iBuf->GetPtr() ); |
356 iDataPartSize = aDataPart.Length(); |
358 iDataPartSize = aDataPart.Length(); |
357 } |
359 if( iSendReady ) |
358 else |
360 { |
|
361 iLastPart = ETrue; |
|
362 } |
|
363 } |
|
364 else // Consecutive calls so that we always return the same part |
|
365 // and same amount of data |
359 { |
366 { |
360 aDataPart.Set( iMemBuf->iBuf->GetPtr().Left( iDataPartSize ) ); |
367 aDataPart.Set( iMemBuf->iBuf->GetPtr().Left( iDataPartSize ) ); |
361 } |
368 } |
362 |
369 |
363 return ( iDataPartSize == KWholeDataPart ) ? iSendReady : EFalse; |
370 // this check did not work, as in this phase the iDataPartSize is never |
|
371 // KWholeDataPart |
|
372 //return ( iDataPartSize == KWholeDataPart ) ? iSendReady : EFalse; |
|
373 |
|
374 // Always return info if this is the last part, this is only true |
|
375 // if iSendReady has been true when ReleaseData() has been called |
|
376 return iLastPart; |
364 } |
377 } |
365 |
378 |
366 // ----------------------------------------------------------------------------- |
379 // ----------------------------------------------------------------------------- |
367 // CHTTPFilterDRMDataSupplier::ReleaseData |
380 // CHTTPFilterDRMDataSupplier::ReleaseData |
368 // virtual methods from MHTTPDataSupplier |
381 // virtual methods from MHTTPDataSupplier |
369 // ----------------------------------------------------------------------------- |
382 // ----------------------------------------------------------------------------- |
370 // |
383 // |
371 void CHTTPFilterDRMDataSupplier::ReleaseData() |
384 void CHTTPFilterDRMDataSupplier::ReleaseData() |
372 { |
385 { |
373 if ( iDataPartSize == KWholeDataPart ) |
386 if ( iDataPartSize == KWholeDataPart || |
|
387 ( iLastPart && iSendReady ) ) |
374 { |
388 { |
375 TRAP_IGNORE( Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(0) ) ); |
389 TRAP_IGNORE( Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(0) ) ); |
376 if ( iSendReady ) |
390 if ( iSendReady ) |
377 { |
391 { |
378 iOwner->DeleteDataSupplier( iTransId ); |
392 iOwner->DeleteDataSupplier( iTransId ); |
386 // Warning: assuming sink is big enough for write of whole b. |
400 // Warning: assuming sink is big enough for write of whole b. |
387 TRAP_IGNORE( Sink()->WriteL( b->Ptr(), b->Length() ) ); |
401 TRAP_IGNORE( Sink()->WriteL( b->Ptr(), b->Length() ) ); |
388 CleanupStack::PopAndDestroy( b ); |
402 CleanupStack::PopAndDestroy( b ); |
389 // Update data part size to available data. |
403 // Update data part size to available data. |
390 iDataPartSize = KWholeDataPart; |
404 iDataPartSize = KWholeDataPart; |
|
405 |
|
406 // if we are ready processing, make sure the client knows this |
|
407 // is the last part |
|
408 if( iSendReady ) |
|
409 { |
|
410 iLastPart = ETrue; |
|
411 } |
391 } |
412 } |
392 } |
413 } |
393 |
414 |
394 // ----------------------------------------------------------------------------- |
415 // ----------------------------------------------------------------------------- |
395 // CHTTPFilterDRMDataSupplier::OverallDataSize |
416 // CHTTPFilterDRMDataSupplier::OverallDataSize |