realtimenetprots/sipfw/SIP/TransactionUser/src/RouteSet.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name          : RouteSet.h
       
    16 * Part of       : TransactionUser
       
    17 * Version       : SIP/4.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 
       
    29 #ifndef ROUTESET_H
       
    30 #define ROUTESET_H
       
    31 
       
    32 #include <e32base.h>
       
    33 
       
    34 #include "SipStackServerDefs.h"
       
    35 
       
    36 class CSIPRequest;
       
    37 class CSIPHeaderBase;
       
    38 class CSIPRouteHeader;
       
    39 class CURIContainer;
       
    40 class MSipRegistrations;
       
    41 
       
    42 
       
    43 /*
       
    44  * This class is used for storing and manipulating a route set.
       
    45  */
       
    46 class CRouteSet : public CBase
       
    47 	{
       
    48 public:	
       
    49 	/**
       
    50 	 * Creates the route set and copies all Route headers from the aReq.
       
    51 	 * If aReq doesn't have Route headers, the possibly existing outbound
       
    52 	 * proxy is added into the route set.
       
    53 	 *
       
    54 	 * @pre
       
    55 	 * @post
       
    56 	 *
       
    57 	 * @see
       
    58 	 *
       
    59 	 * @param aReq SIP request
       
    60 	 * @param aRegistrations Registration subsystem
       
    61 	 * @param aRegisterId Registration identifier
       
    62 	 * @return New CRouteSet object, ownership is transferred
       
    63 	 */
       
    64 	static CRouteSet* NewL(CSIPRequest& aReq,
       
    65 						   MSipRegistrations& aRegistrations,
       
    66 						   TRegistrationId aRegisterId);
       
    67 						   
       
    68 
       
    69 	/**
       
    70 	 * Creates a deep copy of aRouteSet.
       
    71 	 *
       
    72 	 * @pre
       
    73 	 * @post
       
    74 	 *
       
    75 	 * @see
       
    76 	 *
       
    77 	 * @param aRouteSet CRouteSet to be copied	 
       
    78 	 * @return New CRouteSet object, ownership is transferred
       
    79 	 */
       
    80 	static CRouteSet* NewL(const CRouteSet& aRouteSet);
       
    81 
       
    82 
       
    83 	~CRouteSet();
       
    84 
       
    85 
       
    86 	/**
       
    87 	 * Copies the Route-headers present in the route set, to aReq.
       
    88 	 *	 
       
    89 	 * @pre
       
    90 	 * @post
       
    91 	 *
       
    92 	 * @see
       
    93 	 *
       
    94 	 * @param aReq SIP request where Route headers are added
       
    95 	 * @param aIndex Indicates the first entry in route set, from where the
       
    96 	 *	entries are copied.
       
    97 	 *	0 = copy all entries, 1 = copy from the second entry onwards, etc.
       
    98 	 * @return -
       
    99 	 */
       
   100     void CopyToRequestL(CSIPRequest& aReq, TUint aIndex = 0) const;
       
   101 
       
   102 
       
   103 	/**
       
   104 	 * Returns the URI of the first entry of the route set.
       
   105 	 *
       
   106 	 * @pre
       
   107 	 * @post
       
   108 	 *
       
   109 	 * @see
       
   110 	 *
       
   111 	 * @param
       
   112 	 * @return CURIContainer* URI of the first entry of the route set,
       
   113 	 *	ownership is not transferred. NULL if route set is empty.
       
   114 	 */
       
   115 	const CURIContainer* TopUri() const;
       
   116 
       
   117 	
       
   118 	/**
       
   119 	 * Replaces the topmost route with a new value.
       
   120 	 *	 
       
   121 	 * @pre IsEmpty() == EFalse
       
   122 	 * @post
       
   123 	 *
       
   124 	 * @see
       
   125 	 *
       
   126 	 * @param aContact 
       
   127 	 * @return -
       
   128 	 */
       
   129 	void ReplaceTopRouteL();
       
   130 	
       
   131 	
       
   132     /**
       
   133 	 * Checks if the topmost route has LR parameter.
       
   134 	 *	 
       
   135 	 * @pre
       
   136 	 * @post
       
   137 	 *
       
   138 	 * @see
       
   139 	 *	 
       
   140 	 * @return ETrue if topmost route has LR parameter, EFalse if it doesn't
       
   141      *  have, or if the route set is empty.
       
   142 	 */
       
   143 	TBool IsLrParamInTopRoute() const;
       
   144 
       
   145 
       
   146 	/**
       
   147 	 * Checks if the route set is empty.
       
   148 	 *	 
       
   149 	 * @pre
       
   150 	 * @post
       
   151 	 *
       
   152 	 * @see
       
   153 	 *	 
       
   154 	 * @return ETrue if route set is empty, EFalse otherwise.
       
   155 	 */
       
   156 	TBool IsEmpty() const;
       
   157 	
       
   158 	
       
   159 	/**
       
   160 	 * Checks if the original request contained route headers when the request
       
   161 	 * first was passed to TransactionUser.
       
   162 	 *	 
       
   163 	 * @pre
       
   164 	 * @post
       
   165 	 *
       
   166 	 * @see
       
   167 	 *	 
       
   168 	 * @return ETrue if preconfigured route exists, EFalse otherwise.
       
   169 	 */
       
   170 	TBool PreconfigRouteExists() const;
       
   171 	
       
   172 	
       
   173 	/**
       
   174 	 * Returns the next hop URI.
       
   175 	 *
       
   176 	 * @pre
       
   177 	 * @post
       
   178 	 *
       
   179 	 * @see
       
   180 	 *
       
   181 	 * @param aRemoteTarget Remote target
       
   182 	 * @return CURIContainer& Next hop URI
       
   183 	 */
       
   184 	CURIContainer& NextHop(CURIContainer& aRemoteTarget) const;
       
   185 
       
   186 
       
   187 	/**
       
   188 	 * Sets a aRoute as the first route entry.
       
   189 	 *	 
       
   190 	 * @pre
       
   191 	 * @post
       
   192 	 *
       
   193 	 * @see
       
   194 	 *
       
   195 	 * @param aRoute Route to be added
       
   196 	 * @param aOverwrite ETrue if aRoute will replace the current first route
       
   197 	 *	EFalse if aRoute is appended to the beginning	 
       
   198 	 */
       
   199 	void AddToBeginningL(const CSIPRouteHeader& aRoute, TBool aOverwrite);
       
   200 
       
   201 
       
   202 	/**
       
   203 	 * Check if the URI is present in the route set.
       
   204 	 *
       
   205 	 * @param aUri URI
       
   206 	 * @return ETrue: aUri is present in the route set,
       
   207 	 *	EFalse: otherwise
       
   208 	 */
       
   209 	TBool IsInSet(const CURIContainer& aUri) const;
       
   210 
       
   211 private:
       
   212 	CRouteSet();
       
   213 
       
   214 	void ConstructL(CSIPRequest& aReq,
       
   215 					MSipRegistrations& aRegistrations,
       
   216 				    TRegistrationId aRegisterId);
       
   217 
       
   218 	void ConstructL(const CRouteSet& aRouteSet);
       
   219 
       
   220 
       
   221 	/**
       
   222 	 * Creates a copy of aRouteHeader and adds it the route set.
       
   223 	 *	 
       
   224 	 * @pre
       
   225 	 * @post
       
   226 	 *
       
   227 	 * @see
       
   228 	 *
       
   229 	 * @param aRouteHeader Route header to be added	 
       
   230 	 */
       
   231 	void AddRouteL(const CSIPHeaderBase& aRouteHeader);
       
   232 
       
   233 
       
   234     //Route headers of the route set
       
   235     RPointerArray<CSIPRouteHeader> iRoutes;
       
   236     
       
   237     //ETrue if a preconfigured route set exists (=the original request contained
       
   238     //Route headers filled by upper layer).
       
   239     TBool iPreconfigRouteExists;
       
   240 
       
   241 #ifdef CPPUNIT_TEST	
       
   242 	friend class CRouteSet_Test;
       
   243 	friend class CUserAgentClient_Test;
       
   244 #endif
       
   245 	};
       
   246 
       
   247 #endif // end of ROUTESET_H
       
   248 
       
   249 // End of File