realtimenetprots/sipfw/SIP/TransactionUser/src/RouteSet.h
author Petteri Saari <petteri.saari@digia.com>
Thu, 25 Nov 2010 13:59:42 +0200
branchMSRP_FrameWork
changeset 58 cdb720e67852
parent 0 307788aac0a8
permissions -rw-r--r--
This release addresses the following issues: 1. The crash bug fix when receiving file 2. Now the sending is based on MSRP messages, there is no longer file receiving or sending. Client sends data as MSRP was designed. 3. Soma MSRP stack was created so that the client told the correct session-id, Symbian stack generated it by itself. This is not allowed, it was changed so that clients tell the session-id (same as used in SIP INVITE). 4. Unnecessary division of data to chunks removed when there is no need to interrupt sending. The message is sent in as few chunks as possible. 5. Stack can now receive files and chunks with ?unlimited? size. Old stack wrote the incoming data to memory and did not utilize disk space until the end of chunk was reached (large chunks from another client crashed it). 6. Now when writing the incoming data to file, it will take into account the byte-range header values. So, this complies with the RFC4975 requirements that stack must be able to handle chunks that come in any sequence. 7. Some buffering changes to outgoing/incoming data. 8. The outgoing data is now checked that it does not contain the created transaction-id before sending the data. 9. MSRP success reports are now implemented and tested against servers. 10. Progress report system fixed so progress is now visible on client (all the way to 100%). 11. Message Cancel receiving / Cancel sending now corrected and made to work as rfc4975 requires. (termination from sender and error code from receiver when cancelling). 12. Bug correction related to messages received not belonging to any session, old stack implementation did send error response, but after response was written it did give the buffer to client anyway. Now corrected.

/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* Name          : RouteSet.h
* Part of       : TransactionUser
* Version       : SIP/4.0
*
*/




/**
 @internalComponent
*/


#ifndef ROUTESET_H
#define ROUTESET_H

#include <e32base.h>

#include "SipStackServerDefs.h"

class CSIPRequest;
class CSIPHeaderBase;
class CSIPRouteHeader;
class CURIContainer;
class MSipRegistrations;


/*
 * This class is used for storing and manipulating a route set.
 */
class CRouteSet : public CBase
	{
public:	
	/**
	 * Creates the route set and copies all Route headers from the aReq.
	 * If aReq doesn't have Route headers, the possibly existing outbound
	 * proxy is added into the route set.
	 *
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aReq SIP request
	 * @param aRegistrations Registration subsystem
	 * @param aRegisterId Registration identifier
	 * @return New CRouteSet object, ownership is transferred
	 */
	static CRouteSet* NewL(CSIPRequest& aReq,
						   MSipRegistrations& aRegistrations,
						   TRegistrationId aRegisterId);
						   

	/**
	 * Creates a deep copy of aRouteSet.
	 *
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aRouteSet CRouteSet to be copied	 
	 * @return New CRouteSet object, ownership is transferred
	 */
	static CRouteSet* NewL(const CRouteSet& aRouteSet);


	~CRouteSet();


	/**
	 * Copies the Route-headers present in the route set, to aReq.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aReq SIP request where Route headers are added
	 * @param aIndex Indicates the first entry in route set, from where the
	 *	entries are copied.
	 *	0 = copy all entries, 1 = copy from the second entry onwards, etc.
	 * @return -
	 */
    void CopyToRequestL(CSIPRequest& aReq, TUint aIndex = 0) const;


	/**
	 * Returns the URI of the first entry of the route set.
	 *
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param
	 * @return CURIContainer* URI of the first entry of the route set,
	 *	ownership is not transferred. NULL if route set is empty.
	 */
	const CURIContainer* TopUri() const;

	
	/**
	 * Replaces the topmost route with a new value.
	 *	 
	 * @pre IsEmpty() == EFalse
	 * @post
	 *
	 * @see
	 *
	 * @param aContact 
	 * @return -
	 */
	void ReplaceTopRouteL();
	
	
    /**
	 * Checks if the topmost route has LR parameter.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *	 
	 * @return ETrue if topmost route has LR parameter, EFalse if it doesn't
     *  have, or if the route set is empty.
	 */
	TBool IsLrParamInTopRoute() const;


	/**
	 * Checks if the route set is empty.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *	 
	 * @return ETrue if route set is empty, EFalse otherwise.
	 */
	TBool IsEmpty() const;
	
	
	/**
	 * Checks if the original request contained route headers when the request
	 * first was passed to TransactionUser.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *	 
	 * @return ETrue if preconfigured route exists, EFalse otherwise.
	 */
	TBool PreconfigRouteExists() const;
	
	
	/**
	 * Returns the next hop URI.
	 *
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aRemoteTarget Remote target
	 * @return CURIContainer& Next hop URI
	 */
	CURIContainer& NextHop(CURIContainer& aRemoteTarget) const;


	/**
	 * Sets a aRoute as the first route entry.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aRoute Route to be added
	 * @param aOverwrite ETrue if aRoute will replace the current first route
	 *	EFalse if aRoute is appended to the beginning	 
	 */
	void AddToBeginningL(const CSIPRouteHeader& aRoute, TBool aOverwrite);


	/**
	 * Check if the URI is present in the route set.
	 *
	 * @param aUri URI
	 * @return ETrue: aUri is present in the route set,
	 *	EFalse: otherwise
	 */
	TBool IsInSet(const CURIContainer& aUri) const;

private:
	CRouteSet();

	void ConstructL(CSIPRequest& aReq,
					MSipRegistrations& aRegistrations,
				    TRegistrationId aRegisterId);

	void ConstructL(const CRouteSet& aRouteSet);


	/**
	 * Creates a copy of aRouteHeader and adds it the route set.
	 *	 
	 * @pre
	 * @post
	 *
	 * @see
	 *
	 * @param aRouteHeader Route header to be added	 
	 */
	void AddRouteL(const CSIPHeaderBase& aRouteHeader);


    //Route headers of the route set
    RPointerArray<CSIPRouteHeader> iRoutes;
    
    //ETrue if a preconfigured route set exists (=the original request contained
    //Route headers filled by upper layer).
    TBool iPreconfigRouteExists;

#ifdef CPPUNIT_TEST	
	friend class CRouteSet_Test;
	friend class CUserAgentClient_Test;
#endif
	};

#endif // end of ROUTESET_H

// End of File