applayerprotocols/httptransportfw/inc/http/rhttpsession.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-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 /**
       
    17  @file
       
    18  @warning : This file contains Rose Model ID comments - please do not delete
       
    19 */
       
    20 
       
    21 #ifndef __RHTTPSESSION_H__
       
    22 #define __RHTTPSESSION_H__ 
       
    23 
       
    24 // System includes
       
    25 #include <e32std.h>
       
    26 #include <uri8.h>
       
    27 #include <http/rhttpconnectioninfo.h>
       
    28 #include <http/rhttpfiltercollection.h>
       
    29 #include <http/rhttptransaction.h>
       
    30 #include <http/mhttpdataoptimiser.h>
       
    31 
       
    32 // Forward declarations
       
    33 class MHTTPTransactionCallback;
       
    34 class CHTTPSession;
       
    35 class MHTTPSessionEventCallback;
       
    36 class MHTTPFilterCreationCallback;
       
    37 class TCertInfo;
       
    38 class CCertificate;
       
    39 
       
    40 /**
       
    41 Constant to represent any HTTP Status code when registering filters.
       
    42 @publishedAll
       
    43 @released
       
    44 */
       
    45 const TInt KAnyStatusCode = -1;
       
    46 
       
    47 
       
    48 //##ModelId=3C4C187B0280
       
    49 class RHTTPSession 
       
    50 /** 
       
    51 A session handle. A session is a set of HTTP transactions using
       
    52 the same connection settings (e.g. proxy) and the same set of filters.
       
    53     Multi-homing support provided by HTTP framework enables clients to
       
    54     specify Connection preferences through the session property 
       
    55     EHttpSocketConnection.
       
    56 
       
    57 Note that RHTTPSession (and consequently the whole of HTTP)
       
    58 depends on the active scheduler; a scheduler must be installed
       
    59 when the session is opened and it must be running if a transaction
       
    60 is actually to do anything.
       
    61 @publishedAll
       
    62 @released
       
    63 @see RHTTPTransaction
       
    64 */
       
    65 	{
       
    66  public:
       
    67 	/** Constructor.
       
    68 		@post The session is closed. (It must be opened with OpenL)
       
    69 		@see OpenL */
       
    70 	//##ModelId=3C4C187B02EF
       
    71 	inline RHTTPSession();
       
    72 
       
    73 	/** Sets the session event callback.
       
    74 		Until it is set all incoming session events are consumed
       
    75 	*/
       
    76 	//##ModelId=3C4C187B02EA
       
    77 	IMPORT_C void SetSessionEventCallback(MHTTPSessionEventCallback* aSessionEventCallback);
       
    78 
       
    79 	/** Send an session event
       
    80 		@param aEvent. The session event to sent.
       
    81 	*/
       
    82 	//##ModelId=3C4C187B02E6
       
    83 	IMPORT_C void SendSessionEventL(THTTPSessionEvent aStatus, THTTPSessionEvent::TDirection aDirection, 
       
    84 							 THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
       
    85 
       
    86 	/** Fail the session event
       
    87 	*/
       
    88 	IMPORT_C void FailSessionEvent(THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
       
    89 
       
    90 	//##ModelId=3A49F701013F
       
    91 	/** Opens the session using the default protocol HTTP/TCP. 
       
    92 		This function leaves with an apropriate code if the open failed.
       
    93 		@pre The session is closed. An active scheduler is installed.
       
    94 		@post The session is open.
       
    95 	*/
       
    96 	//##ModelId=3C4C187B02DA
       
    97  	IMPORT_C void OpenL();
       
    98 
       
    99 	/** Opens the session using the protocol indicated by the parameter passed in.
       
   100 		This function leaves with an apropriate code if the open failed.
       
   101 		@param aProtocol The protocol required
       
   102 		@pre The session is closed. An active scheduler is installed.
       
   103 		@post The session is open.
       
   104 	*/
       
   105 	//##ModelId=3C4C187B02DB
       
   106 	IMPORT_C void OpenL(const TDesC8& aProtocol);
       
   107 
       
   108 	/** Opens the session using the protocol indicated by the parameter passed in.
       
   109 		This method should be used if configuring the installed filters is required.
       
   110 		Once construction if the session is complete the callback method passed in is
       
   111 		called passing in a TFilterConfigurationIterator to allow the filters that
       
   112 		are installed to be configured.
       
   113 		This function leaves with an apropriate code if the open failed.
       
   114 		@param aProtocol The protocol required
       
   115 		@param aSessionCallback The pointer to the object providing the call back method
       
   116 		@pre The session is closed. An active scheduler is installed.
       
   117 		@post The session is open.
       
   118 	*/
       
   119 	//##ModelId=3C4C187B02DD
       
   120 	IMPORT_C void OpenL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback);
       
   121 
       
   122 	/**	This is a static methods that lists all the available protocols by adding the 
       
   123 		prorocol descriptors to the descriptor array passed in. Any existing data in the
       
   124 		descriptor array passed in is deleted.
       
   125 		This function leaves if the descriptor array can not be updated with the appropriate
       
   126 		array code.
       
   127 		@param aProtocolArray A pointer array to heap based descriptors. The data in this
       
   128 		array will be deleted and filled with descriptors containing the available protocols
       
   129 		@see OpenL
       
   130 	*/
       
   131 	//##ModelId=3C4C187B02D4
       
   132 	IMPORT_C static void ListAvailableProtocolsL(RPointerArray<HBufC8>& aProtocolArray);
       
   133 
       
   134 	/** Creates a transaction. 
       
   135 		@pre The session is open
       
   136 		@param aURI The URI that the request will be sent to.
       
   137 		@param aCallback A callback for all status events relating to
       
   138 		this transaction.
       
   139 		@param aMethod The HTTP method to use (default: GET)
       
   140 		@leave KErrNoMemory There was not enough memory.
       
   141 	*/
       
   142 	//##ModelId=3C4C187B02D0
       
   143 	IMPORT_C RHTTPTransaction OpenTransactionL(const TUriC8& aURI, 
       
   144 									  MHTTPTransactionCallback& aCallback, 
       
   145 									  RStringF aMethod = RStringF());
       
   146 
       
   147 	/** Closes the session. All transactions will be stopped and closed 
       
   148 		@post The session and all open transactions in it are closed.
       
   149 	 */
       
   150 	//##ModelId=3C4C187B02C8
       
   151 	IMPORT_C void Close();
       
   152 
       
   153 
       
   154 	//##ModelId=3C4C187B02C7
       
   155 	IMPORT_C  static const TStringTable& GetTable();
       
   156 
       
   157 	/** Accessor for the HTTP string pool. 
       
   158 		@return A handle for the string pool used in HTTP.
       
   159 	 */
       
   160 	//##ModelId=3C4C187B02C6
       
   161 	IMPORT_C RStringPool StringPool() const;
       
   162 
       
   163 	/** Accessor for the connection info for this session, and which
       
   164 		is used for all transactions in the session. Note that by and
       
   165 		large, the connection info should be set up before the first
       
   166 		transaction is created.  @return A handle to the connection
       
   167 		inf.  */
       
   168 	//##ModelId=3C4C187B02BE
       
   169 	IMPORT_C RHTTPConnectionInfo ConnectionInfo() const;
       
   170 
       
   171 	/** Accessor for the filter collection. Note that the filter
       
   172         collection can't be edited after the first transaction has
       
   173         been created. */
       
   174 	//##ModelId=3C4C187B02BD
       
   175 	inline RHTTPFilterCollection FilterCollection() const;
       
   176 
       
   177 
       
   178 	/** Accessor for the session headers. These are headers that will get added to each request
       
   179 		They only become part of the transaction headers when a transaction is submitted and they will not 
       
   180 		replace headers that already exist in the transaction request 
       
   181 	*/
       
   182 	//##ModelId=3C4C187B02BC
       
   183 	IMPORT_C RHTTPHeaders RequestSessionHeadersL();
       
   184 
       
   185 
       
   186 	/** Accessor for the response session headers. These are headers that will get added to each response if the 
       
   187 	corresponding header doesn't already exist
       
   188 	*/
       
   189 	//##ModelId=3C4C187B02B6
       
   190 	IMPORT_C RHTTPHeaders ResponseSessionHeadersL();
       
   191 
       
   192 	/** Equality operator.
       
   193 		@param aTrans The session to compare this one to.
       
   194 	*/
       
   195 	//##ModelId=3C4C187B02B4
       
   196 	TBool operator==(RHTTPSession aTrans) const;
       
   197 	/** Inequality operator
       
   198 		@param aTrans The session to compare this one to.
       
   199 	*/
       
   200 
       
   201 	//##ModelId=3C4C187B02B2
       
   202 	TBool operator!=(RHTTPSession aTrans) const;
       
   203 
       
   204 	/** Obtain the server certificate information for this session.  This function
       
   205 		should only be used for WSP, for text-mode use RHttpTransaction::ServerCert.
       
   206 		@see RHttpTransaction::ServerCert
       
   207 		@param	aServerCert A client supplied object into which the certificate
       
   208 		information will be placed.
       
   209 		@return KErrNone if certificate has been completed, KErrNotSupported if
       
   210 		this function is called for text-mode.
       
   211 		@deprecated v9.2 onwards - maintained for compatibility with v9.1 and before
       
   212 					TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative.
       
   213 	*/
       
   214 	//##ModelId=3C4C187B02AA
       
   215 	IMPORT_C TInt ServerCert(TCertInfo& aServerCert);
       
   216 
       
   217 	#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   218 	/** Obtain the server certificate information for this session.  This function
       
   219 		should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
       
   220 		@see RHttpSession::ServerCert
       
   221 		@prototype
       
   222 		@return	a CCertificate pointer to an CWTLSCertificate object.
       
   223 		Calling code can safely cast to CWTLSCertificate if using  "WSP/WSP".
       
   224 		NULL returned if certificate information not found.
       
   225 	*/
       
   226 	#else
       
   227 	/** Obtain the server certificate information for this session.  This function
       
   228 		should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
       
   229 		@see RHttpSession::ServerCert
       
   230 		@internalAll
       
   231 		@prototype
       
   232 		@return	a CCertificate pointer to an CWTLSCertificate object.
       
   233 		Calling code can safely cast to CWTLSCertificate if using  "WSP/WSP".
       
   234 		NULL returned if certificate information not found.
       
   235 	*/
       
   236 	#endif	//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   237 	IMPORT_C const CCertificate* ServerCert();
       
   238 
       
   239 	/** Connect this WSP session. This function does nothing when called for text-mode.
       
   240 	*/
       
   241 	//##ModelId=3C4C187B02A9
       
   242 	IMPORT_C void ConnectL();
       
   243 
       
   244 	/** Disconnect this WSP session. This function does nothing when called for text-mode.
       
   245 	*/
       
   246 	//##ModelId=3C4C187B02A8
       
   247 	IMPORT_C void DisconnectL();
       
   248 
       
   249 	#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   250 	/**Set the default Proxy for Http Session. This function reads default proxy information,if available, from CommsDat
       
   251 	and uses it for the current Session.
       
   252 	@internalAll
       
   253 	*/
       
   254 	IMPORT_C void SetupDefaultProxyFromCommsDatL();
       
   255 
       
   256 	#endif	//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   257 
       
   258 	#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS	
       
   259 	/**Sets the HTTP data optimiser for the session.
       
   260 	@param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
       
   261 	*/
       
   262 	#else
       
   263 	/**Sets the HTTP data optimiser for the session.
       
   264 	@param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
       
   265 	@publishedPartner
       
   266 	@released
       
   267 	*/
       
   268 	#endif	//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   269 	IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
       
   270  	
       
   271 	#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS	
       
   272  	/**Returns the object of the MHttpDataOptimiser implementation class.
       
   273 	*/
       
   274 	#else
       
   275  	/**Returns the object of the MHttpDataOptimiser implementation class.
       
   276 	@internalTechnology
       
   277 	*/
       
   278 	#endif	//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   279  	IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
       
   280 
       
   281 private:
       
   282 	friend class RHTTPFilterCollection;
       
   283 	friend class CHTTPSession;
       
   284 
       
   285 	//##ModelId=3C4C187B0296
       
   286 	CHTTPSession* iImplementation;
       
   287 };
       
   288 
       
   289 inline RHTTPSession::RHTTPSession()
       
   290 		: iImplementation(0)
       
   291 	{
       
   292 	}
       
   293 
       
   294 
       
   295 inline RHTTPFilterCollection RHTTPSession::FilterCollection() const
       
   296 	{
       
   297 	RHTTPFilterCollection c;
       
   298 	c.iImplementation = iImplementation;
       
   299 	return c;
       
   300 	}
       
   301 
       
   302 inline TBool RHTTPSession::operator==(RHTTPSession aTrans) const
       
   303 	{
       
   304 	return (iImplementation == aTrans.iImplementation);
       
   305 	};
       
   306 inline TBool RHTTPSession::operator!=(RHTTPSession aTrans) const
       
   307 	{
       
   308 	return !(*this == aTrans);
       
   309 	};
       
   310 
       
   311 
       
   312 
       
   313 inline RHTTPSession RHTTPFilterCollection::Session() const
       
   314 	{
       
   315 	RHTTPSession s;
       
   316 	s.iImplementation = iImplementation;
       
   317 	return s;
       
   318 	}
       
   319 
       
   320 
       
   321 
       
   322 
       
   323 #endif // __RHTTPSESSION_H__