upnpmediaserver/contentdirectoryservice/src/dlna/upnpdlnafilter.cpp
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 0 7f85d04be362
equal deleted inserted replaced
32:3785f754ee62 38:5360b7ddc251
     1 /** @file
     1 /** @file
     2  * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
     2  * Copyright (c) 2005-2009 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".
    25 #include "upnpfileutils.h"
    25 #include "upnpfileutils.h"
    26 #include "upnpsecuritymanager.h"
    26 #include "upnpsecuritymanager.h"
    27 #define KLogFile _L("DLNAWebServer.txt")
    27 #define KLogFile _L("DLNAWebServer.txt")
    28 #include "upnpcustomlog.h"
    28 #include "upnpcustomlog.h"
    29 #include "upnphttpfilereceivetransaction.h"
    29 #include "upnphttpfilereceivetransaction.h"
    30 #include "upnphttpfileservetransaction.h"
    30 #include "upnphttpdataservetransaction.h"
    31 #include "upnpdlnafilterheaders.h"
    31 #include "upnpdlnafilterheaders.h"
    32 #include "upnpcommonupnplits.h"
    32 #include "upnpcommonupnplits.h"
    33 #include "upnpdlnacorelation.h"
    33 #include "upnpdlnacorelation.h"
    34 
    34 
       
    35 
    35 // CONSTANTS
    36 // CONSTANTS
    36 _LIT8( KDlnaFilter, "DLNA");
    37 _LIT8( KDlnaFilter, "DLNA");
    37 _LIT8( KIpPortPlaceholder8, "___.___.___.___:_____" );
    38 _LIT8( KIpPortPlaceholder8, "___.___.___.___:_____" );
    38 
    39 
    39 // ============================ MEMBER FUNCTIONS ===============================
    40 // ============================ MEMBER FUNCTIONS ===============================
    40 
    41 
    41 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    42 // CUpnpDlnaFilter::CUpnpDlnaFilter
    43 // CUpnpDlnaFilter::NewL
    43 // C++ default constructor.
    44 // Two-phased constructor.
    44 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    45 //
    46 //
    46 CUpnpDlnaFilter::CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
    47 EXPORT_C CUpnpDlnaFilter* CUpnpDlnaFilter::NewL(
    47     CUpnpSecurityManager* aSecurityManager ) :
    48     MUpnpContentDirectoryDataFinder* aFinder,
    48     iCdDataFinder( aFinder ), iSecurityManager( aSecurityManager )
    49     CUpnpSecurityManager* aSecurityManager )
    49     {
    50     {
    50     }
    51     CUpnpDlnaFilter* self =
    51 
    52             CUpnpDlnaFilter::NewLC( aFinder, aSecurityManager );
    52 // -----------------------------------------------------------------------------
    53     CleanupStack::Pop( self );
    53 // CUpnpDlnaFilter::~CUpnpDlnaFilter
    54     return self;
    54 // C++ default destructor.
    55     }
    55 // -----------------------------------------------------------------------------
    56 
    56 //
    57 // -----------------------------------------------------------------------------
    57 CUpnpDlnaFilter::~CUpnpDlnaFilter()
    58 //  CUpnpDlnaFilter::NewTransactionL
    58     {
    59 //
    59     iFs.Close();
    60 // -----------------------------------------------------------------------------
    60     delete iProtocolInfo;
    61 //
       
    62 EXPORT_C void CUpnpDlnaFilter::NewTransactionL( const TDesC8& aMethod, const TDesC8& aUri, 
       
    63     const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
       
    64     {
       
    65     if ( aMethod == KHttpPost() )
       
    66         {
       
    67         aResultTrans = CUpnpHttpFileReceiveTransaction::NewL( *this, aSender, aUri );
       
    68         }
       
    69     else
       
    70         {
       
    71         aResultTrans = CUpnpHttpDataServeTransaction::NewL( *this, aSender, aUri );
       
    72         }
    61     }
    73     }
    62 
    74 
    63 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    64 // CUpnpDlnaFilter::NewLC
    76 // CUpnpDlnaFilter::NewLC
    65 // Two-phased constructor.
    77 // Two-phased constructor.
    66 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    67 //
    79 //
    68 CUpnpDlnaFilter* CUpnpDlnaFilter::NewLC(
    80 EXPORT_C CUpnpDlnaFilter* CUpnpDlnaFilter::NewLC(
    69     MUpnpContentDirectoryDataFinder* aFinder,
    81     MUpnpContentDirectoryDataFinder* aFinder,
    70     CUpnpSecurityManager* aSecurityManager )
    82     CUpnpSecurityManager* aSecurityManager )
    71     {
    83     {
    72     CUpnpDlnaFilter* self = new (ELeave) CUpnpDlnaFilter( aFinder,
    84     CUpnpDlnaFilter* self = new (ELeave) CUpnpDlnaFilter( aFinder,
    73         aSecurityManager );
    85         aSecurityManager );
    75     self->ConstructL();
    87     self->ConstructL();
    76     return self;
    88     return self;
    77     }
    89     }
    78 
    90 
    79 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    80 // CUpnpDlnaFilter::NewL
    92 // CUpnpDlnaFilter::CUpnpDlnaFilter
    81 // Two-phased constructor.
    93 // C++ default constructor.
    82 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
    83 //
    95 //
    84 CUpnpDlnaFilter* CUpnpDlnaFilter::NewL(
    96 CUpnpDlnaFilter::CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
    85     MUpnpContentDirectoryDataFinder* aFinder,
    97     CUpnpSecurityManager* aSecurityManager ) :
    86     CUpnpSecurityManager* aSecurityManager )
    98     iCdDataFinder( aFinder ), iSecurityManager( aSecurityManager )
    87     {
    99     {
    88     CUpnpDlnaFilter* self =
   100     }
    89             CUpnpDlnaFilter::NewLC( aFinder, aSecurityManager );
   101 
    90     CleanupStack::Pop( self );
   102 // -----------------------------------------------------------------------------
    91     return self;
   103 // CUpnpDlnaFilter::~CUpnpDlnaFilter
       
   104 // C++ default destructor.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CUpnpDlnaFilter::~CUpnpDlnaFilter()
       
   108     {
       
   109     iFs.Close();
       
   110     delete iProtocolInfo;
    92     }
   111     }
    93 
   112 
    94 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
    95 // CUpnpDlnaFilter::ConstructL
   114 // CUpnpDlnaFilter::ConstructL
    96 // EPOC default constructor for performing 2nd stage construction.
   115 // EPOC default constructor for performing 2nd stage construction.
    97 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
    98 //
   117 //
    99 void CUpnpDlnaFilter::ConstructL()
   118 void CUpnpDlnaFilter::ConstructL()
   100     {
   119     {
   101     User::LeaveIfError( iFs.Connect() );
   120     User::LeaveIfError( iFs.Connect() );
       
   121     User::LeaveIfNull(iCdDataFinder);
   102     }
   122     }
   103 
   123 
   104 // -----------------------------------------------------------------------------
   124 // -----------------------------------------------------------------------------
   105 // CUpnpDlnaFilter::SecurityManager
   125 // CUpnpDlnaFilter::SecurityManager
   106 // 
   126 // 
   139 //
   159 //
   140 HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri )
   160 HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri )
   141     {
   161     {
   142     HBufC8* result = NULL;
   162     HBufC8* result = NULL;
   143     CUpnpDlnaProtocolInfo* protocolInfo = ProtocolInfoL( aContentUri );
   163     CUpnpDlnaProtocolInfo* protocolInfo = ProtocolInfoL( aContentUri );
       
   164     CleanupStack::PushL(protocolInfo);
   144     if ( protocolInfo )
   165     if ( protocolInfo )
   145         {
   166         {
   146         TPtrC8 thirdField = protocolInfo->ThirdField();
   167         TPtrC8 thirdField = protocolInfo->ThirdField();
   147         if ( thirdField != KNullDesC8() )
   168         if ( thirdField != KNullDesC8() )
   148             {
   169             {
   149             result = thirdField.AllocL();
   170             result = thirdField.AllocL();
   150             }
   171             }
   151         }
   172         }
   152     delete protocolInfo;
   173     CleanupStack::PopAndDestroy(protocolInfo);
   153     return result;
   174     return result;
   154     }
   175     }
   155 
   176 
   156 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   157 // CUpnpDlnaFilter::ProtocolInfoL
   178 // CUpnpDlnaFilter::ProtocolInfoL
   230 //
   251 //
   231 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   232 //
   253 //
   233 TInt CUpnpDlnaFilter::CheckDLNAPostCorrelationsL( CUpnpHttpFileReceiveTransaction& aTransaction )
   254 TInt CUpnpDlnaFilter::CheckDLNAPostCorrelationsL( CUpnpHttpFileReceiveTransaction& aTransaction )
   234     {
   255     {
   235     TPtrC8 contentURI = aTransaction.SenderUri();
   256     HBufC8* decodedContentURI = DecodeContentUriLC(aTransaction.SenderUri());
   236     HBufC8* decodedContentURI = HBufC8::NewLC( contentURI.Length() );
       
   237     TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
       
   238     ptrDecodedContentURI.Copy( contentURI );
       
   239     UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
       
   240 
   257 
   241     TBool streamingSupport = 0;
   258     TBool streamingSupport = 0;
   242     TBool interactiveSupport = 0;
   259     TBool interactiveSupport = 0;
   243 
   260 
   244     CUpnpDlnaProtocolInfo* protocolInfo = NULL;
   261     CUpnpDlnaProtocolInfo* protocolInfo = NULL;
   303 // -----------------------------------------------------------------------------
   320 // -----------------------------------------------------------------------------
   304 //  CUpnpDlnaFilter::CheckDLNACorrelations
   321 //  CUpnpDlnaFilter::CheckDLNACorrelations
   305 //
   322 //
   306 // -----------------------------------------------------------------------------
   323 // -----------------------------------------------------------------------------
   307 //
   324 //
   308 TInt CUpnpDlnaFilter::CheckDLNACorrelationsL( CUpnpHttpFileServeTransaction& aTransaction )
   325 TInt CUpnpDlnaFilter::CheckDLNACorrelationsL( CUpnpHttpDataServeTransaction& aTransaction )
   309     {
   326     {
   310     TPtrC8 contentURI = aTransaction.SenderUri() ;
   327     HBufC8* decodedContentURI = DecodeContentUriLC(aTransaction.SenderUri());
   311     HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
       
   312     TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
       
   313     ptrDecodedContentURI.Copy( contentURI );
       
   314     UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
       
   315     CleanupStack::PushL( decodedContentURI );
       
   316     delete iProtocolInfo;
   328     delete iProtocolInfo;
   317     iProtocolInfo = NULL;
   329     iProtocolInfo = NULL;
   318     iProtocolInfo = ProtocolInfoL( *decodedContentURI );
   330     iProtocolInfo = ProtocolInfoL( *decodedContentURI );
   319     CleanupStack::PopAndDestroy( decodedContentURI );    
   331     CleanupStack::PopAndDestroy( decodedContentURI );    
   320     TPtrC8 fourthField( KNullDesC8 );
   332     TPtrC8 fourthField( KNullDesC8 );
   347 
   359 
   348 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   349 // CUpnpHttpServer::CheckCorelationL
   361 // CUpnpHttpServer::CheckCorelationL
   350 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   351 //    
   363 //    
   352 TInt CUpnpDlnaFilter::CheckCorelationL(  CUpnpHttpFileServeTransaction& aTransaction,
   364 TInt CUpnpDlnaFilter::CheckCorelationL(  CUpnpHttpDataServeTransaction& aTransaction,
   353                                          TUpnpDlnaCorelation& aDlnaCorelation )
   365                                          TUpnpDlnaCorelation& aDlnaCorelation )
   354     {
   366     {
   355     //-------------Checking DLNA correlations, response with HTTPerror if some problem occurs
   367     //-------------Checking DLNA correlations, response with HTTPerror if some problem occurs
   356     // DLNA v0.75, 7.3.31.1 checking Operations Parameter    
       
   357     if (
       
   358     // We don't support timeSeek and playSpeed at the moment, so according to point 7.4.71.1 (ver 1.5 rev 0.96)
       
   359     ((aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
       
   360             || aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )
       
   361                     != KNullDesC8()) &&
       
   362     // 7.4.71.2 - range takes precedence
       
   363                     aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8())
       
   364             ||
       
   365             //
       
   366             // or if request mode is Streaming and
       
   367             (aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode ). CompareC(
       
   368                 UpnpDLNA::KTransferModeStreaming ) == 0 && (
       
   369             // if we have no protocolInfo (because for example there is no cdDataFinder )
       
   370                     !iProtocolInfo ||
       
   371                     // Streaming is not supported for this content type
       
   372                             iProtocolInfo -> DlnaFlag(
       
   373                                 UpnpDlnaProtocolInfo::TM_S_FLAG ) == EFalse)) )
       
   374         {
       
   375         // we respond with 406 error code - Not Acceptable.
       
   376         return -EHttpNotAcceptable;
       
   377         }
       
   378 
   368 
   379     aDlnaCorelation.iStreamingSupport = EFalse;
   369     aDlnaCorelation.iStreamingSupport = EFalse;
   380     aDlnaCorelation.iInteractiveSupport = EFalse;
   370     aDlnaCorelation.iInteractiveSupport = EFalse;
   381     aDlnaCorelation.iBackgrondSupport = EFalse;
   371     aDlnaCorelation.iBackgrondSupport = EFalse;
   382     aDlnaCorelation.iGetContentFeaturesExist = EFalse;
   372     aDlnaCorelation.iGetContentFeaturesExist = EFalse;
   383     aDlnaCorelation.iGetContentFeaturesIsOK = ETrue;
   373     aDlnaCorelation.iGetContentFeaturesIsOK = ETrue;
   384     
   374     
   385     // We can only check for getcontentFeaturesExist if we have cdDataFinder ( protocolInfo is not null )
   375     /* We can only check for getcontentFeaturesExist if we have cdDataFinder 
       
   376      * ( protocolInfo is not null )*/
   386     if ( iProtocolInfo )
   377     if ( iProtocolInfo )
   387         {
   378         {
   388         aDlnaCorelation.iBackgrondSupport = 1;
   379         aDlnaCorelation.iBackgrondSupport = 1;
   389         aDlnaCorelation.iStreamingSupport = iProtocolInfo->DlnaFlag(
   380         aDlnaCorelation.iStreamingSupport = iProtocolInfo->DlnaFlag(
   390             UpnpDlnaProtocolInfo::TM_S_FLAG );
   381             UpnpDlnaProtocolInfo::TM_S_FLAG );
   402                 {
   393                 {
   403                 aDlnaCorelation.iGetContentFeaturesIsOK = EFalse;
   394                 aDlnaCorelation.iGetContentFeaturesIsOK = EFalse;
   404                 }
   395                 }
   405             }
   396             }
   406         }
   397         }
       
   398 
       
   399     // DLNA v0.75, 7.3.31.1 checking Operations Parameter    
       
   400     if (
       
   401 		/* We don't support timeSeek and playSpeed at the moment, so according to 
       
   402 		 * point 7.4.71.1 (ver 1.5 rev 0.96)*/
       
   403             aDlnaCorelation.iGetContentFeaturesIsOK &&
       
   404 		((	(aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
       
   405 			|| aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )!= KNullDesC8()) 
       
   406 			&&
       
   407 			// 7.4.71.2 - range takes precedence
       
   408 			aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8()	)
       
   409 		||
       
   410 		// or if request mode is Streaming and
       
   411 		(	aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode ). CompareC(
       
   412 			UpnpDLNA::KTransferModeStreaming ) == 0 
       
   413 			&& 
       
   414 			(
       
   415 			/* if we have no protocolInfo (because for example there is 
       
   416 			no cdDataFinder )*/
       
   417 			!iProtocolInfo ||
       
   418 			// Streaming is not supported for this content type
       
   419 			iProtocolInfo -> DlnaFlag(UpnpDlnaProtocolInfo::TM_S_FLAG ) == EFalse)	)) 
       
   420 		)
       
   421         {
       
   422         // we respond with 406 error code - Not Acceptable.
       
   423         return -EHttpNotAcceptable;
       
   424         }
       
   425 
   407     
   426     
   408     // Append contentFeatures.dlna.org
   427     // Append contentFeatures.dlna.org
   409     if ( aDlnaCorelation.iGetContentFeaturesExist )
   428     if ( aDlnaCorelation.iGetContentFeaturesExist )
   410         {
   429         {
   411         if ( aDlnaCorelation.iFourthField.Length() > 0 )
   430         if ( aDlnaCorelation.iFourthField.Length() > 0 )
   419         
   438         
   420 // -----------------------------------------------------------------------------
   439 // -----------------------------------------------------------------------------
   421 // CUpnpHttpServer::CheckTransferMode
   440 // CUpnpHttpServer::CheckTransferMode
   422 // -----------------------------------------------------------------------------
   441 // -----------------------------------------------------------------------------
   423 //        
   442 //        
   424 TInt CUpnpDlnaFilter::CheckTransferModeL( CUpnpHttpFileServeTransaction& aTransaction,
   443 TInt CUpnpDlnaFilter::CheckTransferModeL( CUpnpHttpDataServeTransaction& aTransaction,
   425                                          TUpnpDlnaCorelation& aDlnaCorelation )
   444                                          TUpnpDlnaCorelation& aDlnaCorelation )
   426     {
   445     {
   427      TDesC8& transferMode = aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode );
   446      TDesC8& transferMode = aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode );
   428     // Check if requested transfer mode is handled
   447     // Check if requested transfer mode is handled
   429     if (
   448     if (
   467 
   486 
   468 // -----------------------------------------------------------------------------
   487 // -----------------------------------------------------------------------------
   469 // CUpnpHttpServer::AppendCorelationHeaders
   488 // CUpnpHttpServer::AppendCorelationHeaders
   470 // -----------------------------------------------------------------------------
   489 // -----------------------------------------------------------------------------
   471 //        
   490 //        
   472 TInt CUpnpDlnaFilter::AppendCorelationHeadersL( CUpnpHttpFileServeTransaction& aTransaction,
   491 TInt CUpnpDlnaFilter::AppendCorelationHeadersL( CUpnpHttpDataServeTransaction& aTransaction,
   473                              TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode )
   492                              TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode )
   474     {
   493     {
   475     if ( aTransferMode.Length() > 0 && ((aTransferMode.CompareC(
   494     if ( aTransferMode.Length() > 0 && ((aTransferMode.CompareC(
   476         UpnpDLNA::KTransferModeStreaming ) == 0 && !aDlnaCorelation.iStreamingSupport)
   495         UpnpDLNA::KTransferModeStreaming ) == 0 && !aDlnaCorelation.iStreamingSupport)
   477             || (aTransferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
   496             || (aTransferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
   503 // -----------------------------------------------------------------------------
   522 // -----------------------------------------------------------------------------
   504 // CUpnpHttpSession::FormatPathL
   523 // CUpnpHttpSession::FormatPathL
   505 //
   524 //
   506 // -----------------------------------------------------------------------------
   525 // -----------------------------------------------------------------------------
   507 //
   526 //
   508 void CUpnpDlnaFilter::FormatPathL( CUpnpHttpFileServeTransaction *aTransaction, TDes &aPath )
   527 void CUpnpDlnaFilter::FormatPathL( CUpnpHttpDataServeTransaction *aTransaction, TDes &aPath )
   509     {
   528     {
   510     LOGS( "%i, CUpnpHttpSession::FormatPathL " );
   529     LOGS( "%i, CUpnpHttpSession::FormatPathL " );
   511 
   530 
   512     TPtrC8 contentURI = aTransaction->SenderUri();
   531     TPtrC8 contentURI = aTransaction->SenderUri();
   513 
   532 
   552 // -----------------------------------------------------------------------------
   571 // -----------------------------------------------------------------------------
   553 // CUpnpDlnaFilter::GetContentTypeL()
   572 // CUpnpDlnaFilter::GetContentTypeL()
   554 // Retrieves a mime type from the third field of the protocol info read from CD
   573 // Retrieves a mime type from the third field of the protocol info read from CD
   555 // -----------------------------------------------------------------------------
   574 // -----------------------------------------------------------------------------
   556 //
   575 //
   557 TInt CUpnpDlnaFilter::GetContentTypeL( CUpnpHttpFileServeTransaction &aTransaction,
   576 TInt CUpnpDlnaFilter::GetContentTypeL( CUpnpHttpDataServeTransaction &aTransaction,
   558     HBufC8*& aMime, const TDesC16& aFilename )
   577     HBufC8*& aMime, const TDesC16& aFilename )
   559     {
   578     {
   560     TInt error = KErrNone;
   579     TInt error = KErrNone;
   561 
   580 
   562     TParse parse;
   581     TParse parse;
   572         aMime->Des().Append( KXmlUtf8() );
   591         aMime->Des().Append( KXmlUtf8() );
   573         return error;
   592         return error;
   574         }
   593         }
   575 
   594 
   576     //decoding content URI
   595     //decoding content URI
   577     TPtrC8 contentURI = aTransaction.SenderUri();
   596     HBufC8* decodedContentURI = DecodeContentUriLC( aTransaction.SenderUri());
   578     HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
       
   579     TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
       
   580     ptrDecodedContentURI.Copy( contentURI );
       
   581     UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
       
   582     CleanupStack::PushL( decodedContentURI );
       
   583 
   597 
   584     //getting 3rd field
   598     //getting 3rd field
   585     aMime = ThirdFieldFromCdL( *decodedContentURI );
   599     aMime = ThirdFieldFromCdL( *decodedContentURI );
   586     CleanupStack::PopAndDestroy( decodedContentURI );
   600     CleanupStack::PopAndDestroy( decodedContentURI );
   587     // asterick as mime type is not good - so error is KErrNotFound
   601     // asterick as mime type is not good - so error is KErrNotFound
   657 // -----------------------------------------------------------------------------
   671 // -----------------------------------------------------------------------------
   658 // CUpnpDlnaFilter::PrepareHeaderL
   672 // CUpnpDlnaFilter::PrepareHeaderL
   659 //
   673 //
   660 // -----------------------------------------------------------------------------
   674 // -----------------------------------------------------------------------------
   661 //
   675 //
   662 TInt CUpnpDlnaFilter::PrepareHeaderL( CUpnpHttpFileServeTransaction& aTransaction )
   676 TInt CUpnpDlnaFilter::PrepareHeaderL( CUpnpHttpDataServeTransaction& aTransaction )
   663     {    
   677     {    
   664     HBufC8* mimetype = NULL;
   678     HBufC8* mimetype = NULL;
   665     HBufC16* fileName = aTransaction.PathWithNewMethodL();
   679     HBufC16* fileName = aTransaction.PathWithNewMethodL();
   666     CleanupStack::PushL( fileName );
   680     CleanupStack::PushL( fileName );
   667     
   681     
   685         }
   699         }
   686 
   700 
   687     
   701     
   688     AddHeaderIfNotEmptyL( UpnpDLNA::KHdrContentFeatures(), aTransaction );
   702     AddHeaderIfNotEmptyL( UpnpDLNA::KHdrContentFeatures(), aTransaction );
   689     
   703     
   690         // 7.4.42.2 HTTP Server Endpoints that transfer Non-Cacheable Content using · HTTP/1.0, and· GET responses.
   704         // 7.4.42.2 HTTP Server Endpoints that transfer Non-Cacheable Content using ?HTTP/1.0, and?GET responses.
   691         // These devices must prevent intermediate caching by including among the HTTP response headers
   705         // These devices must prevent intermediate caching by including among the HTTP response headers
   692         // the directive:· Pragma:  no-cache
   706         // the directive:?Pragma:  no-cache
   693     aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrPragma(),
   707     aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrPragma(),
   694                                      UpnpHTTP::KNoCache() );   
   708                                      UpnpHTTP::KNoCache() );   
   695     aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrCacheControl(),
   709     aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrCacheControl(),
   696                                      UpnpHTTP::KNoCache() );        
   710                                      UpnpHTTP::KNoCache() );        
   697 
   711 
   715 //  CUpnpDlnaFilter::AddHeaderIfNotEmptyL
   729 //  CUpnpDlnaFilter::AddHeaderIfNotEmptyL
   716 //
   730 //
   717 // -----------------------------------------------------------------------------
   731 // -----------------------------------------------------------------------------
   718 //
   732 //
   719 void CUpnpDlnaFilter::AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
   733 void CUpnpDlnaFilter::AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
   720     CUpnpHttpFileServeTransaction& aTransaction )
   734     CUpnpHttpDataServeTransaction& aTransaction )
   721     {
   735     {
   722     if ( aTransaction.FilterHeaders().QueryHeader( aHeaderName ).Length() > 0 )
   736     if ( aTransaction.FilterHeaders().QueryHeader( aHeaderName ).Length() > 0 )
   723         {
   737         {
   724         aTransaction.AddResponseHeaderL( aHeaderName,
   738         aTransaction.AddResponseHeaderL( aHeaderName,
   725             aTransaction.FilterHeaders().QueryHeader( aHeaderName ) );            
   739             aTransaction.FilterHeaders().QueryHeader( aHeaderName ) );            
   726         }
       
   727     }
       
   728 
       
   729 // -----------------------------------------------------------------------------
       
   730 //  CUpnpDlnaFilter::NewTransactionL
       
   731 //
       
   732 // -----------------------------------------------------------------------------
       
   733 //
       
   734 void CUpnpDlnaFilter::NewTransactionL( const TDesC8& aMethod, const TDesC8& aUri, 
       
   735     const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
       
   736     {
       
   737     if ( aMethod == KHttpPost() )
       
   738         {
       
   739         aResultTrans = CUpnpHttpFileReceiveTransaction::NewL( *this, aSender, aUri );
       
   740         }
       
   741     else
       
   742         {
       
   743         aResultTrans = CUpnpHttpFileServeTransaction::NewL( *this, aSender, aUri );
       
   744         }
   740         }
   745     }
   741     }
   746 
   742 
   747 // -----------------------------------------------------------------------------
   743 // -----------------------------------------------------------------------------
   748 //  CUpnpDlnaFilter::AuthorizeRequestL
   744 //  CUpnpDlnaFilter::AuthorizeRequestL
   895         }
   891         }
   896         
   892         
   897     return fileToServe;
   893     return fileToServe;
   898     }
   894     }
   899 
   895 
   900 
   896 // -----------------------------------------------------------------------------
       
   897 // CUpnpDlnaFilter::DecodeContentUriLC
       
   898 // -----------------------------------------------------------------------------
       
   899 //
       
   900 HBufC8* CUpnpDlnaFilter::DecodeContentUriLC( const TPtrC8& contentURI)
       
   901 	{
       
   902 	HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
       
   903 	TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
       
   904 	ptrDecodedContentURI.Copy( contentURI );
       
   905 	UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
       
   906 	CleanupStack::PushL( decodedContentURI );
       
   907 	return decodedContentURI;
       
   908 	
       
   909 	}
   901 //  End of File
   910 //  End of File