1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/http/rhttpsession.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,300 @@
1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +
1.21 +/**
1.22 + @file RHTTPSession.h
1.23 + @warning : This file contains Rose Model ID comments - please do not delete
1.24 +*/
1.25 +
1.26 +#ifndef __RHTTPSESSION_H__
1.27 +#define __RHTTPSESSION_H__
1.28 +
1.29 +// System includes
1.30 +#include <e32std.h>
1.31 +#include <uri8.h>
1.32 +#include <http/rhttpconnectioninfo.h>
1.33 +#include <http/rhttpfiltercollection.h>
1.34 +#include <http/rhttptransaction.h>
1.35 +#include <http/mhttpdataoptimiser.h>
1.36 +
1.37 +// Forward declarations
1.38 +class MHTTPTransactionCallback;
1.39 +class CHTTPSession;
1.40 +class MHTTPSessionEventCallback;
1.41 +class MHTTPFilterCreationCallback;
1.42 +class TCertInfo;
1.43 +class CCertificate;
1.44 +
1.45 +/**
1.46 +Constant to represent any HTTP Status code when registering filters.
1.47 +@publishedAll
1.48 +@released
1.49 +*/
1.50 +const TInt KAnyStatusCode = -1;
1.51 +
1.52 +
1.53 +//##ModelId=3C4C187B0280
1.54 +class RHTTPSession
1.55 +/**
1.56 +A session handle. A session is a set of HTTP transactions using
1.57 +the same connection settings (e.g. proxy) and the same set of filters.
1.58 + Multi-homing support provided by HTTP framework enables clients to
1.59 + specify Connection preferences through the session property
1.60 + EHttpSocketConnection.
1.61 +
1.62 +Note that RHTTPSession (and consequently the whole of HTTP)
1.63 +depends on the active scheduler; a scheduler must be installed
1.64 +when the session is opened and it must be running if a transaction
1.65 +is actually to do anything.
1.66 +@publishedAll
1.67 +@released
1.68 +@see RHTTPTransaction
1.69 +*/
1.70 + {
1.71 + public:
1.72 + /** Constructor.
1.73 + @post The session is closed. (It must be opened with OpenL)
1.74 + @see OpenL */
1.75 + //##ModelId=3C4C187B02EF
1.76 + inline RHTTPSession();
1.77 +
1.78 + /** Sets the session event callback.
1.79 + Until it is set all incoming session events are consumed
1.80 + */
1.81 + //##ModelId=3C4C187B02EA
1.82 + IMPORT_C void SetSessionEventCallback(MHTTPSessionEventCallback* aSessionEventCallback);
1.83 +
1.84 + /** Send an session event
1.85 + @param aEvent. The session event to sent.
1.86 + */
1.87 + //##ModelId=3C4C187B02E6
1.88 + IMPORT_C void SendSessionEventL(THTTPSessionEvent aStatus, THTTPSessionEvent::TDirection aDirection,
1.89 + THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
1.90 +
1.91 + /** Fail the session event
1.92 + */
1.93 + IMPORT_C void FailSessionEvent(THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
1.94 +
1.95 + //##ModelId=3A49F701013F
1.96 + /** Opens the session using the default protocol HTTP/TCP.
1.97 + This function leaves with an apropriate code if the open failed.
1.98 + @pre The session is closed. An active scheduler is installed.
1.99 + @post The session is open.
1.100 + */
1.101 + //##ModelId=3C4C187B02DA
1.102 + IMPORT_C void OpenL();
1.103 +
1.104 + /** Opens the session using the protocol indicated by the parameter passed in.
1.105 + This function leaves with an apropriate code if the open failed.
1.106 + @param aProtocol The protocol required
1.107 + @pre The session is closed. An active scheduler is installed.
1.108 + @post The session is open.
1.109 + */
1.110 + //##ModelId=3C4C187B02DB
1.111 + IMPORT_C void OpenL(const TDesC8& aProtocol);
1.112 +
1.113 + /** Opens the session using the protocol indicated by the parameter passed in.
1.114 + This method should be used if configuring the installed filters is required.
1.115 + Once construction if the session is complete the callback method passed in is
1.116 + called passing in a TFilterConfigurationIterator to allow the filters that
1.117 + are installed to be configured.
1.118 + This function leaves with an apropriate code if the open failed.
1.119 + @param aProtocol The protocol required
1.120 + @param aSessionCallback The pointer to the object providing the call back method
1.121 + @pre The session is closed. An active scheduler is installed.
1.122 + @post The session is open.
1.123 + */
1.124 + //##ModelId=3C4C187B02DD
1.125 + IMPORT_C void OpenL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback);
1.126 +
1.127 + /** This is a static methods that lists all the available protocols by adding the
1.128 + prorocol descriptors to the descriptor array passed in. Any existing data in the
1.129 + descriptor array passed in is deleted.
1.130 + This function leaves if the descriptor array can not be updated with the appropriate
1.131 + array code.
1.132 + @param aProtocolArray A pointer array to heap based descriptors. The data in this
1.133 + array will be deleted and filled with descriptors containing the available protocols
1.134 + @see OpenL
1.135 + */
1.136 + //##ModelId=3C4C187B02D4
1.137 + IMPORT_C static void ListAvailableProtocolsL(RPointerArray<HBufC8>& aProtocolArray);
1.138 +
1.139 + /** Creates a transaction.
1.140 + @pre The session is open
1.141 + @param aURI The URI that the request will be sent to.
1.142 + @param aCallback A callback for all status events relating to
1.143 + this transaction.
1.144 + @param aMethod The HTTP method to use (default: GET)
1.145 + @leave KErrNoMemory There was not enough memory.
1.146 + */
1.147 + //##ModelId=3C4C187B02D0
1.148 + IMPORT_C RHTTPTransaction OpenTransactionL(const TUriC8& aURI,
1.149 + MHTTPTransactionCallback& aCallback,
1.150 + RStringF aMethod = RStringF());
1.151 +
1.152 + /** Closes the session. All transactions will be stopped and closed
1.153 + @post The session and all open transactions in it are closed.
1.154 + */
1.155 + //##ModelId=3C4C187B02C8
1.156 + IMPORT_C void Close();
1.157 +
1.158 +
1.159 + //##ModelId=3C4C187B02C7
1.160 + IMPORT_C static const TStringTable& GetTable();
1.161 +
1.162 + /** Accessor for the HTTP string pool.
1.163 + @return A handle for the string pool used in HTTP.
1.164 + */
1.165 + //##ModelId=3C4C187B02C6
1.166 + IMPORT_C RStringPool StringPool() const;
1.167 +
1.168 + /** Accessor for the connection info for this session, and which
1.169 + is used for all transactions in the session. Note that by and
1.170 + large, the connection info should be set up before the first
1.171 + transaction is created. @return A handle to the connection
1.172 + inf. */
1.173 + //##ModelId=3C4C187B02BE
1.174 + IMPORT_C RHTTPConnectionInfo ConnectionInfo() const;
1.175 +
1.176 + /** Accessor for the filter collection. Note that the filter
1.177 + collection can't be edited after the first transaction has
1.178 + been created. */
1.179 + //##ModelId=3C4C187B02BD
1.180 + inline RHTTPFilterCollection FilterCollection() const;
1.181 +
1.182 +
1.183 + /** Accessor for the session headers. These are headers that will get added to each request
1.184 + They only become part of the transaction headers when a transaction is submitted and they will not
1.185 + replace headers that already exist in the transaction request
1.186 + */
1.187 + //##ModelId=3C4C187B02BC
1.188 + IMPORT_C RHTTPHeaders RequestSessionHeadersL();
1.189 +
1.190 +
1.191 + /** Accessor for the response session headers. These are headers that will get added to each response if the
1.192 + corresponding header doesn't already exist
1.193 + */
1.194 + //##ModelId=3C4C187B02B6
1.195 + IMPORT_C RHTTPHeaders ResponseSessionHeadersL();
1.196 +
1.197 + /** Equality operator.
1.198 + @param aTrans The session to compare this one to.
1.199 + */
1.200 + //##ModelId=3C4C187B02B4
1.201 + TBool operator==(RHTTPSession aTrans) const;
1.202 + /** Inequality operator
1.203 + @param aTrans The session to compare this one to.
1.204 + */
1.205 +
1.206 + //##ModelId=3C4C187B02B2
1.207 + TBool operator!=(RHTTPSession aTrans) const;
1.208 +
1.209 + /** Obtain the server certificate information for this session. This function
1.210 + should only be used for WSP, for text-mode use RHttpTransaction::ServerCert.
1.211 + @see RHttpTransaction::ServerCert
1.212 + @param aServerCert A client supplied object into which the certificate
1.213 + information will be placed.
1.214 + @return KErrNone if certificate has been completed, KErrNotSupported if
1.215 + this function is called for text-mode.
1.216 + @deprecated v9.2 onwards - maintained for compatibility with v9.1 and before
1.217 + TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative.
1.218 + */
1.219 + //##ModelId=3C4C187B02AA
1.220 + IMPORT_C TInt ServerCert(TCertInfo& aServerCert);
1.221 +
1.222 +
1.223 + /** Obtain the server certificate information for this session. This function
1.224 + should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
1.225 + @see RHttpSession::ServerCert
1.226 + @internalAll
1.227 + @prototype
1.228 + @return a CCertificate pointer to an CWTLSCertificate object.
1.229 + Calling code can safely cast to CWTLSCertificate if using "WSP/WSP".
1.230 + NULL returned if certificate information not found.
1.231 + */
1.232 + IMPORT_C const CCertificate* RHTTPSession::ServerCert();
1.233 +
1.234 + /** Connect this WSP session. This function does nothing when called for text-mode.
1.235 + */
1.236 + //##ModelId=3C4C187B02A9
1.237 + IMPORT_C void ConnectL();
1.238 +
1.239 + /** Disconnect this WSP session. This function does nothing when called for text-mode.
1.240 + */
1.241 + //##ModelId=3C4C187B02A8
1.242 + IMPORT_C void DisconnectL();
1.243 +
1.244 + /**Set the default Proxy for Http Session. This function reads default proxy information,if available, from CommsDat
1.245 + and uses it for the current Session.
1.246 + @internalAll
1.247 + */
1.248 + IMPORT_C void SetupDefaultProxyFromCommsDatL();
1.249 +
1.250 + /**Sets the HTTP data optimiser for the session.
1.251 + @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
1.252 + @publishedPartner
1.253 + */
1.254 + IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
1.255 +
1.256 + /**Returns the object of the MHttpDataOptimiser implementation class.
1.257 + @internalTechnology
1.258 + */
1.259 + IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
1.260 +
1.261 +private:
1.262 + friend class RHTTPFilterCollection;
1.263 + friend class CHTTPSession;
1.264 +
1.265 + //##ModelId=3C4C187B0296
1.266 + CHTTPSession* iImplementation;
1.267 +};
1.268 +
1.269 +inline RHTTPSession::RHTTPSession()
1.270 + : iImplementation(0)
1.271 + {
1.272 + }
1.273 +
1.274 +
1.275 +inline RHTTPFilterCollection RHTTPSession::FilterCollection() const
1.276 + {
1.277 + RHTTPFilterCollection c;
1.278 + c.iImplementation = iImplementation;
1.279 + return c;
1.280 + }
1.281 +
1.282 +inline TBool RHTTPSession::operator==(RHTTPSession aTrans) const
1.283 + {
1.284 + return (iImplementation == aTrans.iImplementation);
1.285 + };
1.286 +inline TBool RHTTPSession::operator!=(RHTTPSession aTrans) const
1.287 + {
1.288 + return !(*this == aTrans);
1.289 + };
1.290 +
1.291 +
1.292 +
1.293 +inline RHTTPSession RHTTPFilterCollection::Session() const
1.294 + {
1.295 + RHTTPSession s;
1.296 + s.iImplementation = iImplementation;
1.297 + return s;
1.298 + }
1.299 +
1.300 +
1.301 +
1.302 +
1.303 +#endif // __RHTTPSESSION_H__