williamr@2: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file RHTTPSession.h williamr@2: @warning : This file contains Rose Model ID comments - please do not delete williamr@2: */ williamr@2: williamr@2: #ifndef __RHTTPSESSION_H__ williamr@2: #define __RHTTPSESSION_H__ williamr@2: williamr@2: // System includes williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // Forward declarations williamr@2: class MHTTPTransactionCallback; williamr@2: class CHTTPSession; williamr@2: class MHTTPSessionEventCallback; williamr@2: class MHTTPFilterCreationCallback; williamr@2: class TCertInfo; williamr@2: class CCertificate; williamr@2: williamr@2: /** williamr@2: Constant to represent any HTTP Status code when registering filters. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: const TInt KAnyStatusCode = -1; williamr@2: williamr@2: williamr@2: //##ModelId=3C4C187B0280 williamr@2: class RHTTPSession williamr@2: /** williamr@2: A session handle. A session is a set of HTTP transactions using williamr@2: the same connection settings (e.g. proxy) and the same set of filters. williamr@2: Multi-homing support provided by HTTP framework enables clients to williamr@2: specify Connection preferences through the session property williamr@2: EHttpSocketConnection. williamr@2: williamr@2: Note that RHTTPSession (and consequently the whole of HTTP) williamr@2: depends on the active scheduler; a scheduler must be installed williamr@2: when the session is opened and it must be running if a transaction williamr@2: is actually to do anything. williamr@2: @publishedAll williamr@2: @released williamr@2: @see RHTTPTransaction williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Constructor. williamr@2: @post The session is closed. (It must be opened with OpenL) williamr@2: @see OpenL */ williamr@2: //##ModelId=3C4C187B02EF williamr@2: inline RHTTPSession(); williamr@2: williamr@2: /** Sets the session event callback. williamr@2: Until it is set all incoming session events are consumed williamr@2: */ williamr@2: //##ModelId=3C4C187B02EA williamr@2: IMPORT_C void SetSessionEventCallback(MHTTPSessionEventCallback* aSessionEventCallback); williamr@2: williamr@2: /** Send an session event williamr@2: @param aEvent. The session event to sent. williamr@2: */ williamr@2: //##ModelId=3C4C187B02E6 williamr@2: IMPORT_C void SendSessionEventL(THTTPSessionEvent aStatus, THTTPSessionEvent::TDirection aDirection, williamr@2: THTTPFilterHandle aStart = THTTPFilterHandle::EClient); williamr@2: williamr@2: /** Fail the session event williamr@2: */ williamr@2: IMPORT_C void FailSessionEvent(THTTPFilterHandle aStart = THTTPFilterHandle::EClient); williamr@2: williamr@2: //##ModelId=3A49F701013F williamr@2: /** Opens the session using the default protocol HTTP/TCP. williamr@2: This function leaves with an apropriate code if the open failed. williamr@2: @pre The session is closed. An active scheduler is installed. williamr@2: @post The session is open. williamr@2: */ williamr@2: //##ModelId=3C4C187B02DA williamr@2: IMPORT_C void OpenL(); williamr@2: williamr@2: /** Opens the session using the protocol indicated by the parameter passed in. williamr@2: This function leaves with an apropriate code if the open failed. williamr@2: @param aProtocol The protocol required williamr@2: @pre The session is closed. An active scheduler is installed. williamr@2: @post The session is open. williamr@2: */ williamr@2: //##ModelId=3C4C187B02DB williamr@2: IMPORT_C void OpenL(const TDesC8& aProtocol); williamr@2: williamr@2: /** Opens the session using the protocol indicated by the parameter passed in. williamr@2: This method should be used if configuring the installed filters is required. williamr@2: Once construction if the session is complete the callback method passed in is williamr@2: called passing in a TFilterConfigurationIterator to allow the filters that williamr@2: are installed to be configured. williamr@2: This function leaves with an apropriate code if the open failed. williamr@2: @param aProtocol The protocol required williamr@2: @param aSessionCallback The pointer to the object providing the call back method williamr@2: @pre The session is closed. An active scheduler is installed. williamr@2: @post The session is open. williamr@2: */ williamr@2: //##ModelId=3C4C187B02DD williamr@2: IMPORT_C void OpenL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback); williamr@2: williamr@2: /** This is a static methods that lists all the available protocols by adding the williamr@2: prorocol descriptors to the descriptor array passed in. Any existing data in the williamr@2: descriptor array passed in is deleted. williamr@2: This function leaves if the descriptor array can not be updated with the appropriate williamr@2: array code. williamr@2: @param aProtocolArray A pointer array to heap based descriptors. The data in this williamr@2: array will be deleted and filled with descriptors containing the available protocols williamr@2: @see OpenL williamr@2: */ williamr@2: //##ModelId=3C4C187B02D4 williamr@2: IMPORT_C static void ListAvailableProtocolsL(RPointerArray& aProtocolArray); williamr@2: williamr@2: /** Creates a transaction. williamr@2: @pre The session is open williamr@2: @param aURI The URI that the request will be sent to. williamr@2: @param aCallback A callback for all status events relating to williamr@2: this transaction. williamr@2: @param aMethod The HTTP method to use (default: GET) williamr@2: @leave KErrNoMemory There was not enough memory. williamr@2: */ williamr@2: //##ModelId=3C4C187B02D0 williamr@2: IMPORT_C RHTTPTransaction OpenTransactionL(const TUriC8& aURI, williamr@2: MHTTPTransactionCallback& aCallback, williamr@2: RStringF aMethod = RStringF()); williamr@2: williamr@2: /** Closes the session. All transactions will be stopped and closed williamr@2: @post The session and all open transactions in it are closed. williamr@2: */ williamr@2: //##ModelId=3C4C187B02C8 williamr@2: IMPORT_C void Close(); williamr@2: williamr@2: williamr@2: //##ModelId=3C4C187B02C7 williamr@2: IMPORT_C static const TStringTable& GetTable(); williamr@2: williamr@2: /** Accessor for the HTTP string pool. williamr@2: @return A handle for the string pool used in HTTP. williamr@2: */ williamr@2: //##ModelId=3C4C187B02C6 williamr@2: IMPORT_C RStringPool StringPool() const; williamr@2: williamr@2: /** Accessor for the connection info for this session, and which williamr@2: is used for all transactions in the session. Note that by and williamr@2: large, the connection info should be set up before the first williamr@2: transaction is created. @return A handle to the connection williamr@2: inf. */ williamr@2: //##ModelId=3C4C187B02BE williamr@2: IMPORT_C RHTTPConnectionInfo ConnectionInfo() const; williamr@2: williamr@2: /** Accessor for the filter collection. Note that the filter williamr@2: collection can't be edited after the first transaction has williamr@2: been created. */ williamr@2: //##ModelId=3C4C187B02BD williamr@2: inline RHTTPFilterCollection FilterCollection() const; williamr@2: williamr@2: williamr@2: /** Accessor for the session headers. These are headers that will get added to each request williamr@2: They only become part of the transaction headers when a transaction is submitted and they will not williamr@2: replace headers that already exist in the transaction request williamr@2: */ williamr@2: //##ModelId=3C4C187B02BC williamr@2: IMPORT_C RHTTPHeaders RequestSessionHeadersL(); williamr@2: williamr@2: williamr@2: /** Accessor for the response session headers. These are headers that will get added to each response if the williamr@2: corresponding header doesn't already exist williamr@2: */ williamr@2: //##ModelId=3C4C187B02B6 williamr@2: IMPORT_C RHTTPHeaders ResponseSessionHeadersL(); williamr@2: williamr@2: /** Equality operator. williamr@2: @param aTrans The session to compare this one to. williamr@2: */ williamr@2: //##ModelId=3C4C187B02B4 williamr@2: TBool operator==(RHTTPSession aTrans) const; williamr@2: /** Inequality operator williamr@2: @param aTrans The session to compare this one to. williamr@2: */ williamr@2: williamr@2: //##ModelId=3C4C187B02B2 williamr@2: TBool operator!=(RHTTPSession aTrans) const; williamr@2: williamr@2: /** Obtain the server certificate information for this session. This function williamr@2: should only be used for WSP, for text-mode use RHttpTransaction::ServerCert. williamr@2: @see RHttpTransaction::ServerCert williamr@2: @param aServerCert A client supplied object into which the certificate williamr@2: information will be placed. williamr@2: @return KErrNone if certificate has been completed, KErrNotSupported if williamr@2: this function is called for text-mode. williamr@2: @deprecated v9.2 onwards - maintained for compatibility with v9.1 and before williamr@2: TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative. williamr@2: */ williamr@2: //##ModelId=3C4C187B02AA williamr@2: IMPORT_C TInt ServerCert(TCertInfo& aServerCert); williamr@2: williamr@2: williamr@2: /** Obtain the server certificate information for this session. This function williamr@2: should only be used for WSP. HTTP should use RHttpTransaction::ServerCert. williamr@2: @see RHttpSession::ServerCert williamr@2: @internalAll williamr@2: @prototype williamr@2: @return a CCertificate pointer to an CWTLSCertificate object. williamr@2: Calling code can safely cast to CWTLSCertificate if using "WSP/WSP". williamr@2: NULL returned if certificate information not found. williamr@2: */ williamr@2: IMPORT_C const CCertificate* RHTTPSession::ServerCert(); williamr@2: williamr@2: /** Connect this WSP session. This function does nothing when called for text-mode. williamr@2: */ williamr@2: //##ModelId=3C4C187B02A9 williamr@2: IMPORT_C void ConnectL(); williamr@2: williamr@2: /** Disconnect this WSP session. This function does nothing when called for text-mode. williamr@2: */ williamr@2: //##ModelId=3C4C187B02A8 williamr@2: IMPORT_C void DisconnectL(); williamr@2: williamr@2: /**Set the default Proxy for Http Session. This function reads default proxy information,if available, from CommsDat williamr@2: and uses it for the current Session. williamr@2: @internalAll williamr@2: */ williamr@2: IMPORT_C void SetupDefaultProxyFromCommsDatL(); williamr@2: williamr@2: /**Sets the HTTP data optimiser for the session. williamr@2: @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client. williamr@2: @publishedPartner williamr@2: */ williamr@2: IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser); williamr@2: williamr@2: /**Returns the object of the MHttpDataOptimiser implementation class. williamr@2: @internalTechnology williamr@2: */ williamr@2: IMPORT_C MHttpDataOptimiser* HttpDataOptimiser (); williamr@2: williamr@2: private: williamr@2: friend class RHTTPFilterCollection; williamr@2: friend class CHTTPSession; williamr@2: williamr@2: //##ModelId=3C4C187B0296 williamr@2: CHTTPSession* iImplementation; williamr@2: }; williamr@2: williamr@2: inline RHTTPSession::RHTTPSession() williamr@2: : iImplementation(0) williamr@2: { williamr@2: } williamr@2: williamr@2: williamr@2: inline RHTTPFilterCollection RHTTPSession::FilterCollection() const williamr@2: { williamr@2: RHTTPFilterCollection c; williamr@2: c.iImplementation = iImplementation; williamr@2: return c; williamr@2: } williamr@2: williamr@2: inline TBool RHTTPSession::operator==(RHTTPSession aTrans) const williamr@2: { williamr@2: return (iImplementation == aTrans.iImplementation); williamr@2: }; williamr@2: inline TBool RHTTPSession::operator!=(RHTTPSession aTrans) const williamr@2: { williamr@2: return !(*this == aTrans); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: inline RHTTPSession RHTTPFilterCollection::Session() const williamr@2: { williamr@2: RHTTPSession s; williamr@2: s.iImplementation = iImplementation; williamr@2: return s; williamr@2: } williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #endif // __RHTTPSESSION_H__