realtimenetprots/sipfw/SIP/sipapi/api/siptransactionbase.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        : siptransactionbase.h
* Part of     : SIP Client
* Interface   : SDK API, SIP Client API
* Version     : 1.0
*
*/



#ifndef CSIPTRANSACTIONBASE_H
#define CSIPTRANSACTIONBASE_H

// INCLUDES
#include <e32base.h>
#include <stringpool.h>

// FORWARD DECLARATIONS
class CSIPResponseElements;
class MTransactionAssociation;

// CLASS DECLARATION

/**
*  @publishedAll
*  @released
*
*  Base class for managing SIP transactions.
*  It provides services for querying transaction type and its state.
*
*  This class is an abstract class and cannot be instantiated.
*  @lib sipclient
*/
class CSIPTransactionBase: public CBase
	{
	public:
		/** SIP transaction state */
		enum TState
			{
			/** Trying state */
			ETrying,
			/** Calling state */
			ECalling,
			/** Proceeding state */
			EProceeding,
			/** Completed state */
			ECompleted,
			/** Confirmed state */
			EConfirmed,
			/** Terminated state */
			ETerminated,
			/** Object is being constructed and is not yet ready for use */
			EConstructing
			};

	public: // Destructor
        /**
        * Destructor
        * @internalComponent       
		*/
		virtual ~CSIPTransactionBase();

	public: // New functions
        /**
        * Gets the SIP transaction type
        * @return SIP transaction type
        */
		IMPORT_C RStringF Type() const;

		/**
		* Gets SIP transaction state
		* @return SIP transaction state
		* @leave KErrSIPResourceNotAvailable if a required SIP Client API
		*	object has been deleted
		*/
		IMPORT_C CSIPTransactionBase::TState StateL();

		/**
		* Checks the if the actual object
		* is of type CSIPClientTransaction.
		* @return ETrue if object is of type CSIPClientTransaction and
		*         EFalse otherwise
		*/
		IMPORT_C TBool IsSIPClientTransaction() const;

		/**
		* Compares this object to another object also having
		* CSIPTransactionBase base class
		* The function has to be implemented in each of the sub-classes.
		* @param aTransaction a CSIPTransactionBase object to compare
		* @return ETrue if the objects are equal otherwise EFalse
		*/
        IMPORT_C TBool
            operator==(const CSIPTransactionBase& aTransaction) const;

	public: // New functions, for internal use
        /**
		* Obtains the RequestId of the transaction.
		*
        * @return RequestId
		*/
        TUint32 RequestId() const;

        /**
		* Clears the MTransactionAssociation. After this the object can't be
        * used anymore and it is expected that user will delete it soon.
        *
        * @param aAssociation Object requesting the detach
        * @internalComponent      
		*/
        virtual void Detach(const MTransactionAssociation& aAssociation);

        /**
		* Changes the transaction state.
        *
        * @param aNextState State into which transaction moves
		*/
        void ChangeState(CSIPTransactionBase::TState aNextState);

        /**
        * Determines whether this transaction has an effect on the associated
        * dialog's state.
        *
		* @return ETrue if transaction has an effect on the dialog's state,
        *   EFalse otherwise.
		*/
        TBool AffectsDialogState() const;

        /**
		* Sets this transaction to affect the dialog state.
		*/
        void SetAffectsDialogState();

        /**
		* Determines whether the transaction type is a target refresh request.
        *
        * @param aType Type of transaction
        * @return ETrue If the transaction is a target refresh request, EFalse
        *   otherwise.
		*/
        static TBool IsTargetRefresh(RStringF aType);

        /**
		* Stores response elements. Depending on the status code, transaction
        * may enter another state.
        *
        * @param aElements Response elements, ownership is transferred.
		*/
        void SetResponseElements(CSIPResponseElements* aElements);

    protected: // Constructors
        CSIPTransactionBase(TBool aIsClientTransaction,
                            TUint32 aRequestId,
                            MTransactionAssociation& aAssociation);

        void ConstructL(RStringF aType);

	protected: // New functions, for internal use
        /**
		* Checks that iAssociation is available (not NULL). If iAssociation is
        * NULL, it means user has deleted a resource needed by
        * CSIPTransactionBase, and this function leaves.
		*/
        void CheckAssociationL() const;

        /**
		* Gets response elements.
        *
		* @return Response elements. Ownership isn't transferred.
		*/
        const CSIPResponseElements* ResponseElements() const;

	protected: // Data
	
        /**
        * RequestId received from SIP client
        * @internalComponent
        */       
        TUint32 iRequestId;

        /**
        * Every transaction is associated to exactly one other object:
        * CSIP, CSIPConnection, CSIPRegistrationBinding or CSIPDialogAssocBase
        * @internalComponent
        */        
        MTransactionAssociation* iAssociation;

    private: // Data
		RStringF iType;

        //ETrue is the transaction is a client transaction, EFalse otherwise
        TBool iIsClientTransaction;

        //Current transaction state
        CSIPTransactionBase::TState iState;

        //ETrue if the transaction has an effect on the dialog state in case
        //the transaction is associated with a dialog.
        //EFalse otherwise.
        TBool iAffectsDialogState;

        //SIP response elements
        CSIPResponseElements* iResponseElements;

	private: // For testing purposes
#ifdef CPPUNIT_TEST
	    friend class CSIP_Test;
        friend class CSIPServerTransaction_Test;
        friend class CSIPSubscribeDialogAssoc_Test;
        friend class CSIPInviteDialogAssoc_Test;
        friend class CSIPNotifyDialogAssoc_Test;
        friend class CSIPConnection_Test;
#endif
		void __DbgTestInvariant() const;

    };

#endif