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