applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienttransaction.cpp
changeset 0 b16258d2340f
child 37 5f1cd966e0d9
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <http.h>
       
    17 #include "chttpclienttransaction.h"
       
    18 #include "chttprequestcomposer.h"
       
    19 #include "chttpresponseparser.h"
       
    20 #include "chttpconnectionmanager.h"
       
    21 
       
    22 CHttpClientTransaction* CHttpClientTransaction::NewL(RHTTPTransaction aTransaction)
       
    23 	{
       
    24 	CHttpClientTransaction* self = new (ELeave) CHttpClientTransaction(aTransaction);
       
    25 	return self;	
       
    26 	}
       
    27 	
       
    28 CHttpClientTransaction::~CHttpClientTransaction()
       
    29 	{
       
    30 	}
       
    31 
       
    32 CHttpClientTransaction::CHttpClientTransaction(RHTTPTransaction aTransaction)
       
    33 : CProtTransaction(aTransaction), iStringTable(RHTTPSession::GetTable())
       
    34 	{
       
    35 	}
       
    36 	
       
    37 void CHttpClientTransaction::SetConnectionManager(CHttpConnectionManager& aConnectionManager)
       
    38 	{
       
    39 	__ASSERT_DEBUG( iConnectionManager == NULL, User::Invariant() );
       
    40 	
       
    41 	// A connection manager has been supplied - add this object to it.	
       
    42 	iConnectionManager = &aConnectionManager;
       
    43 	}
       
    44 
       
    45 CHttpConnectionManager* CHttpClientTransaction::ConnectionManager() const
       
    46 	{
       
    47 	return iConnectionManager;
       
    48 	}
       
    49 
       
    50 void CHttpClientTransaction::RemoveConnectionManager()
       
    51 	{
       
    52 	iConnectionManager = NULL;
       
    53 	}
       
    54 	
       
    55 /*
       
    56  *	Methods from CProtTransaction
       
    57  */
       
    58 
       
    59 void CHttpClientTransaction::CreateTxDataL()
       
    60 	{
       
    61 	__ASSERT_DEBUG( iConnectionManager != NULL, User::Invariant() );
       
    62 
       
    63 	delete iTxData;
       
    64 	iTxData = NULL;
       
    65 	iTxData = CHttpRequestComposer::NewL(*this, *iConnectionManager);
       
    66 	}
       
    67 	
       
    68 void CHttpClientTransaction::CreateRxDataL(MRxDataObserver& aObserver)
       
    69 	{
       
    70 	__ASSERT_DEBUG( iConnectionManager != NULL, User::Invariant() );
       
    71 
       
    72 	delete iRxData;
       
    73 	iRxData = NULL;
       
    74 	iRxData = CHttpResponseParser::NewL(*this, aObserver, *iConnectionManager);
       
    75 	}
       
    76 	
       
    77 void CHttpClientTransaction::IncRetryCount ()
       
    78 	{
       
    79 	++iRetryCount;		
       
    80 	}
       
    81 
       
    82 TBool CHttpClientTransaction::RetryNeeded ()
       
    83 	{
       
    84 	const TInt KMaxRetryCount = 3;	
       
    85 	return ( ( iTransactionState != ECancelled ) && 
       
    86 			( iTransactionState != ECompleted ) && 
       
    87 			( iRetryCount < KMaxRetryCount) );
       
    88 	}
       
    89 	
       
    90 TBool CHttpClientTransaction::NeedDisconnectNotification () const
       
    91     {
       
    92     TBool needDisconnectNotification = EFalse;
       
    93 	RHTTPTransaction myTransaction = Transaction (); 
       
    94 	RHTTPSession mySession = myTransaction.Session ();
       
    95 	RStringPool myStringPool ( mySession.StringPool () );
       
    96 	RStringF notifyOnDisconnect = myStringPool.StringF( HTTP::ENotifyOnDisconnect, iStringTable );
       
    97 
       
    98 	RHTTPPropertySet transactionProperties = myTransaction.PropertySet();
       
    99 	RHTTPPropertySet sessionProperties = mySession.ConnectionInfo();
       
   100     
       
   101 	THTTPHdrVal hdrVal;
       
   102 	
       
   103 	// Check the transaction properties for the disconnect notification
       
   104 	// If it is set then it should be used.
       
   105 	if ( transactionProperties.Property ( notifyOnDisconnect, hdrVal ) || sessionProperties.Property ( notifyOnDisconnect, hdrVal ) )	
       
   106 		{
       
   107 		__ASSERT_DEBUG( hdrVal.Type() == THTTPHdrVal::KStrFVal, User::Invariant() );
       
   108 		
       
   109 		needDisconnectNotification = ( hdrVal.StrF().Index(iStringTable) == HTTP::EEnableDisconnectNotification );
       
   110 		}
       
   111 	return needDisconnectNotification;	
       
   112 	}