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