applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspProxyInfoProvider.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 #ifndef __CWSPPROXYINFOPROVIDER_H__
       
    17 #define __CWSPPROXYINFOPROVIDER_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <wsp/mwspproxyinfoprovider.h>
       
    22 #include <wsp/wsptypes.h>
       
    23 #include <http/rhttpsession.h>
       
    24 
       
    25 // User includes
       
    26 #include "tproxyinfo.h"
       
    27 
       
    28 /** The CWspProxyInfoProvider class implements the MWspProxyInfoProvider API. 
       
    29 	The proxy information that is provided is obtained either from the HTTP
       
    30 	session properties or from the Symbian OS Comms Database.
       
    31 
       
    32 	The EWspProxyAddress property must be set in the HTTP session for the proxy
       
    33 	info not to be taken from the Comms Database. The other properties 
       
    34 	(described below) are optional. If these have been not set then the 
       
    35 	following defaults will bw applied; the session will be unsecured CO over IP.
       
    36 
       
    37 	The following HTTP properties define the proxy info;
       
    38 
       
    39 	1) EWspProxyAddress	- a property of type RStringF that contains a bearer
       
    40 	independent address.
       
    41 
       
    42 	2) EWspBearer		- a property of type RStringF which should have a value
       
    43 	of EWspIp for an IP (v4) bearer or a value of EWspSMS for an 8-bit WAP SMS
       
    44 	bearer
       
    45 
       
    46 	3) EWspSecurity		- a property of type RStringF which should contain the
       
    47 	values EWspUseWtls, for a WTLS secured WSP session, or EWspDoNotUseWtls, for
       
    48 	a non-secured WSP session.
       
    49 
       
    50 	4) EWspSessionType	- a property of type RStringF that can have either the
       
    51 	value EWspConnectionOriented for a CO session and a value of 
       
    52 	EWspConnectionless for a CL session.
       
    53 
       
    54 	For the case of an IP bearer, the following additional properties are 
       
    55 	required to be defined;
       
    56 
       
    57 	a) EWspLocalPort	- a property of type TInt that contains the local port
       
    58 	number. Defaulted at 0, which means that the transport handler will allocate
       
    59 	an appropriate value.
       
    60 
       
    61 	b) EWspRemotePort	- a property of type TInt that contains the remote port
       
    62 	number. Default value depends of the security status of the session.
       
    63 
       
    64 	For the case of an SMS bearer, the following additional property is 
       
    65 	required to be defined;
       
    66 
       
    67 	a) EWspServiceNumber	- a property of type RStringF that should contain 
       
    68 	the service centre number for the SMS bearer.
       
    69 */
       
    70 //##ModelId=3BBDAFC80354
       
    71 class CWspProxyInfoProvider : public CBase, public MWspProxyInfoProvider
       
    72 	{
       
    73 public:	// Methods
       
    74 
       
    75 /**	
       
    76 	Static factory constructor.
       
    77 	@since			7.0
       
    78 	@param			aSession	The HTTP session in use.
       
    79 	@return			A pointer to a fully initialised object.
       
    80 */
       
    81 	//##ModelId=3C4C419D0014
       
    82 	static CWspProxyInfoProvider* NewL(RHTTPSession aSession);
       
    83 
       
    84 /**Standard destructor.
       
    85 	@since	7.0
       
    86 */
       
    87 	//##ModelId=3C4C419D0000
       
    88 	~CWspProxyInfoProvider();
       
    89 
       
    90 /**Updates the proxy info. If the client has specified 
       
    91 						proxy info in the session properties then that is the 
       
    92 						proxy info that is used. If no proxy info has been 
       
    93 						defined in the session properties, then the default WAP
       
    94 						proxy in the Comms Database is used.
       
    95 	@since			7.0
       
    96 	@leave		The function will leave if the proxy info cannot be obtained
       
    97 					from either the Comms DB or from the HTTP session properties.
       
    98 	@post			The proxy info has been updated.
       
    99 */
       
   100 	//##ModelId=3C4C419C03CA
       
   101 	void UpdateProxyInfoL();
       
   102 
       
   103 /**Updates the proxy info to use the redirected proxy
       
   104 						address. If more than one address is given in 
       
   105 						aRedirectedAddresses, then only the first one is used.
       
   106 						A flag is set indicating that the proxy info should not
       
   107 						be updated on the next call to UpdateProxyInfoL.
       
   108 	@since			7.0
       
   109 	@leave		The function will leave if the redirected address info cannot
       
   110 					be extracted from the supplied data.
       
   111 	@param			aRedirectedAddresses	A reference to a structure containing
       
   112 											the parsed alternate addresses for the 
       
   113 											redirected proxy.
       
   114 	@post			The proxy information has been updated to use the redirected
       
   115 					proxy address. The next call to UpdateProxyInfoL will not 
       
   116 					cause the proxy info to be updated.
       
   117 */									
       
   118 	//##ModelId=3C4C419C0384
       
   119 	void SetTemporaryRedirectedProxyL(TWspRedirectedAddress& aRedirectAddress);
       
   120 
       
   121 /**Updates the proxy info to use the redirected proxy
       
   122 						address. If more than one address is given in 
       
   123 						aRedirectedAddresses, then only the first one is used.
       
   124 						A flag is set indicating that the proxy info should not
       
   125 						be updated on the next call to UpdateProxyInfoL. Also,
       
   126 						the session properties are updated with the new proxy 
       
   127 						info.
       
   128 	@since			7.0
       
   129 	@leave		The function will leave if the redirected address info cannot
       
   130 					be extracted from the supplied data. It will also leave if
       
   131 					the redirected proxy info cannot be set in the HTTP session
       
   132 					properties.
       
   133 	@param			aRedirectedAddresses	A reference to a structure containing
       
   134 											the parsed alternate address for the 
       
   135 											redirected proxy.
       
   136 	@post			The proxy information has been updated to use the redirected
       
   137 					proxy address. The next call to UpdateProxyInfoL will not 
       
   138 					cause the proxy info to be updated. The session properties 
       
   139 					are updated with the new proxy info.
       
   140 */									
       
   141 	//##ModelId=3C4C419C0348
       
   142 	void SetPermanentRedirectedProxyL(TWspRedirectedAddress& aRedirectAddress);
       
   143 
       
   144 /**Checks the current proxy info against the proxy info 
       
   145 						specified by the client either through the HTTP session
       
   146 						properties or the Comms Database. Also updates the 
       
   147 						current proxy info if there has been a change. A flag is
       
   148 						set indicating that the proxy info should not be updated
       
   149 						on the next call to UpdateProxyInfoL.
       
   150 	@since			7.0
       
   151 	@leave		The function will leave if the proxy info cannot be obtained
       
   152 					from either the Comms DB or from the HTTP session properties.
       
   153 	@return			A boolean value of ETrue if the current proxy info defers 
       
   154 					from the client specified proxy info.
       
   155 	@post			The proxy info has been updated. The next call to 
       
   156 					UpdateProxyInfoL will not cause the proxy info to be updated.
       
   157 */
       
   158 	//##ModelId=3C4C419C032A
       
   159 	TBool ProxyInfoChangedAndUpdateL();
       
   160 
       
   161 /**Ensures that the next call to UpdateProxiInfoL actually 
       
   162 						does an update.
       
   163 	@since			7.0
       
   164 	@post			The proxy info is unlocked so that the next call to 
       
   165 					UpdateProxiInfoL actually does an update.
       
   166 */
       
   167 	//##ModelId=3C4C419C0316
       
   168 	void UnlockProxyInfo();
       
   169 
       
   170 /**Removes all proxy information and closes the related resources.
       
   171 	@since			7.0
       
   172 	@post			The proxy info is removed; strings associated with it are closed.
       
   173 */
       
   174 	//##ModelId=3C4C419C0302
       
   175 	void ResetProxyInfo();
       
   176 
       
   177 private:	// Methods from MWspProxyInfoProvider
       
   178 
       
   179 /**@see			MWspProxyInfoProvider
       
   180 */
       
   181 	//##ModelId=3C4C419C02D0
       
   182 	virtual const TDesC8& ProxyAddress() const;
       
   183 
       
   184 /**@see			MWspProxyInfoProvider
       
   185 */
       
   186 	//##ModelId=3C4C419C028A
       
   187 	virtual TUint16 RemotePort() const;
       
   188 
       
   189 /**@see			MWspProxyInfoProvider
       
   190 */
       
   191 	//##ModelId=3C4C419C0262
       
   192 	virtual TUint16 LocalPort() const;
       
   193 
       
   194 /**@see			MWspProxyInfoProvider
       
   195 */
       
   196 	//##ModelId=3C4C419C0230
       
   197 	virtual TWspBearer Bearer() const;
       
   198 
       
   199 /**@see			MWspProxyInfoProvider
       
   200 */
       
   201 	//##ModelId=3C4C419C0207
       
   202 	virtual const TDesC8& ServiceCentreNumber() const;
       
   203 
       
   204 /**@see			MWspProxyInfoProvider
       
   205 */
       
   206 	//##ModelId=3C4C419C01DF
       
   207 	virtual TWspSession WspSessionService() const;
       
   208 
       
   209 /**@see			MWspProxyInfoProvider
       
   210 */
       
   211 	//##ModelId=3C4C419C01C1
       
   212 	virtual TBool SecureConnection() const;
       
   213 
       
   214 private:	// Methods
       
   215 
       
   216 /**First phase constructor.
       
   217 	@since			7.0
       
   218 */
       
   219 	//##ModelId=3C4C419C018F
       
   220 	CWspProxyInfoProvider(RHTTPSession aSession);
       
   221 
       
   222 /**Sets the currect proxy info to be that given the redirected
       
   223 						address. Any fields that are not set in the redirected
       
   224 						address are kept from the current proxy info.
       
   225 	@since			7.0
       
   226 	@leave		The function will leave if the redirected address info cannot
       
   227 					be extracted from the supplied data.
       
   228 	@param			aRedirectedAddress		A structure containing a single parsed
       
   229 											alternate address for the redirected proxy.
       
   230 	@post			The current proxy info contains the redirected proxt info.
       
   231 */
       
   232 	//##ModelId=3C4C419C015D
       
   233 	void ChangeToRedirectedProxyInfoL(TWspRedirectedAddress& aRedirectAddress);
       
   234 	
       
   235 /**Extracts the specified proxy info. Checks the HTTP 
       
   236 						session properties for proxy info. If the proxy info has
       
   237 						not been completely specified in the properties then the
       
   238 						default WAP proxy in the Comms Database is used.
       
   239 	@since			7.0
       
   240 	@leave		The function will leave with KErrNotSupported if the
       
   241 					Connectionless session service has been specified. It will 
       
   242 					also leave with KWspErrServiceNumberNotDefined if an SMS 
       
   243 					bearer has been specified and there is no Service Centre
       
   244 					number defined. The function will leave if the proxy info
       
   245 					cannot be extracted from the Comms DB.
       
   246 	@return			A TProxyInfo object that contains the proxy info.
       
   247 */
       
   248 	//##ModelId=3C4C419C013F
       
   249 	TProxyInfo GetProxyInfoL() const;
       
   250 
       
   251 private:	// Static methods
       
   252 
       
   253 /**Extracts the WSP session type from the HTTP session properties set. A default
       
   254 	value of EWspConnectionOriented is given if the connection type property is 
       
   255 	not given.
       
   256 	@since			7.0
       
   257 	@param			aConnInfo		The session properties for the current HTTP 
       
   258 									session.
       
   259 	@param			aStringPool		The current string pool.
       
   260 	@return			The WSP session type specified in the properties set.
       
   261 */
       
   262 	//##ModelId=3C4C419C00F9
       
   263 	static TWspSession ExtractSessionTypeFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool);
       
   264 
       
   265 /**Extracts the bearer type from the HTTP session properties set. A default 
       
   266 	value of EIP is given if the bearer property is not present.
       
   267 	@since			7.0
       
   268 	@param			aConnInfo		The session properties for the current HTTP 
       
   269 									session.
       
   270 	@param			aStringPool		The current string pool.
       
   271 	@return			The bearer type specified in the properties set.
       
   272 */
       
   273 	//##ModelId=3C4C419C00B3
       
   274 	static TWspBearer ExtractBearerInfoFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool);
       
   275 
       
   276 /**Extracts the security info from the HTTP session properties set. A default 
       
   277 	value of EFalse is given if the security info property is not present.
       
   278 	@since			7.0
       
   279 	@param			aConnInfo		The session properties for the current HTTP 
       
   280 									session.
       
   281 	@param			aStringPool		The current string pool.
       
   282 	@return			A boolean value of ETrue of a security has been specified 
       
   283 					in the properties set.
       
   284 */
       
   285 	//##ModelId=3C4C419C0077
       
   286 	static TBool ExtractSecurityInfoFromSession(RHTTPConnectionInfo aConnInfo, RStringPool aStringPool);
       
   287 
       
   288 /**Extracts the specified port number from the HTTP session properties set. Can
       
   289 	be either HTTP::ELocalPort or HTTP::ERemotePort. The default value of zero is
       
   290 	given if the specified port property is not present.
       
   291 	@since			7.0
       
   292 	@param			aPortType		The specified port. 
       
   293 	@param			aConnInfo		The session properties for the current HTTP 
       
   294 									session.
       
   295 	@param			aStringPool		The current string pool.
       
   296 	@return			A 16-bit unsigned integer with the port number extracted 
       
   297 					from the properties set.
       
   298 */
       
   299 	//##ModelId=3C4C419C0031
       
   300 	static TUint16 ExtractPortInfoFromSession(TInt aPortType, RHTTPConnectionInfo aConnInfo, RStringPool aStringPool);
       
   301 
       
   302 /**Gives the default remote port number given the security status and connection
       
   303 	type, as specified by the WAP specs.
       
   304 	@since			7.0
       
   305 	@param			aConnInfo		The session properties for the current HTTP 
       
   306 									session.
       
   307 	@param			aStringPool		The current string pool.
       
   308 	@return			A 16-bit unsigned integer with the default remote port 
       
   309 					number.
       
   310 */
       
   311 	//##ModelId=3C4C419C0009
       
   312 	static TUint16 DefaultRemotePort(TBool aSecureConnection, TBool aCOConnection);
       
   313 
       
   314 /**Reads the connection information from the comms database file. Gives the 
       
   315 	bearer type, proxy address, security info, service centre number and 
       
   316 	connection type through the output arguments.
       
   317 	@since			7.0
       
   318 	@param			aStringPool				The current string pool.
       
   319 	@param			aBearer					An output argument for the bearer 
       
   320 											type.
       
   321 	@param			aProxyAddress			An output argument for the proxy
       
   322 											address.
       
   323 	@param			aSecureConnection		An output argument for the security
       
   324 											info.
       
   325 	@param			aServiceCentreNumber	An output argument for the service
       
   326 											centre number.
       
   327 	@param			aSessionServiceType		An output argument for the		
       
   328 											connection type.
       
   329 */
       
   330 	//##ModelId=3C4C419B038D
       
   331 	static void ReadWapAccessPointInfoL(
       
   332 									   RStringPool		aStringPool,
       
   333 									   TWspBearer&		aBearer, 
       
   334 									   RStringF&		aProxyAddress, 
       
   335 									   TBool&			aSecureConnection, 
       
   336 									   RStringF&		aServiceCentreNumber,
       
   337 									   TWspSession&		aSessionServiceType
       
   338 									   );
       
   339 
       
   340 /**Extracts a redirected address data structure from the given data. The 
       
   341 	redirected address data structure is defined by the WSP Specification, July
       
   342 	2001. The extracted information is returned in the TWspRedirectedAddress 
       
   343 	object. If there is more than one address in the data, then only the first
       
   344 	redirected address is extracted. The remaining data is ignored.
       
   345 	@since			7.0
       
   346 	@leave		The function will leave with KWspErrBadRedirectedAddressData
       
   347 					if the data is not correctly formed. If an unsupported bearer
       
   348 					has been specified then the function will leave with
       
   349 					KWspErrBearerNotSupported. The function will also leave if 
       
   350 					the RStringF for the proxy address fails to open.
       
   351 	@param			aStringPool				The current string pool.
       
   352 	@param			aRedirectedAddresses	A reference to the buffer containing 
       
   353 											the redirected addresses data.
       
   354 */
       
   355 	//##ModelId=3C4C419B036F
       
   356 	static TWspRedirectedAddress ExtractRedirectedProxyInfoL(RStringPool aStringPool, const TDesC8& aRedirectedAddresses);
       
   357 
       
   358 /**Extracts the (SMS) service centre number from the comms database.
       
   359 	@since			7.0
       
   360 	@param			aStringPool				The current string pool.
       
   361 	@param			aServiceCentreNumber	An output argument for the service
       
   362 											centre number.
       
   363 */
       
   364 	//##ModelId=3C4C419B0351
       
   365 	static void ReadServiceCentreNumberL(RStringPool aStringPool, RStringF& aServiceCentreNumber);
       
   366 
       
   367 private:	// Attributes
       
   368 
       
   369 	/** The HTTP sessiom in use. This is not owned.
       
   370 	*/
       
   371 	//##ModelId=3C4C419B0346
       
   372 	RHTTPSession		iSession;
       
   373 
       
   374 	/** The proxy info.
       
   375 	*/
       
   376 	//##ModelId=3C4C419B033C
       
   377 	TProxyInfo			iProxyInfo;
       
   378 
       
   379 	/** A flag to indicate that the proxy info has already been updated and 
       
   380 		should not be changed on the next UpdateProcyInfoL call.
       
   381 	*/
       
   382 	//##ModelId=3C4C419B032A
       
   383 	TBool				iProxyInfoLocked;
       
   384 
       
   385 	};
       
   386 
       
   387 #endif	// __CWSPPROXYINFOPROVIDER_H__