realtimenetprots/sipfw/SIP/sipapi/api/siptransactionbase.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        : siptransactionbase.h
       
    16 * Part of     : SIP Client
       
    17 * Interface   : SDK API, SIP Client API
       
    18 * Version     : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CSIPTRANSACTIONBASE_H
       
    25 #define CSIPTRANSACTIONBASE_H
       
    26 
       
    27 // INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CSIPResponseElements;
       
    33 class MTransactionAssociation;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  @publishedAll
       
    39 *  @released
       
    40 *
       
    41 *  Base class for managing SIP transactions.
       
    42 *  It provides services for querying transaction type and its state.
       
    43 *
       
    44 *  This class is an abstract class and cannot be instantiated.
       
    45 *  @lib sipclient
       
    46 */
       
    47 class CSIPTransactionBase: public CBase
       
    48 	{
       
    49 	public:
       
    50 		/** SIP transaction state */
       
    51 		enum TState
       
    52 			{
       
    53 			/** Trying state */
       
    54 			ETrying,
       
    55 			/** Calling state */
       
    56 			ECalling,
       
    57 			/** Proceeding state */
       
    58 			EProceeding,
       
    59 			/** Completed state */
       
    60 			ECompleted,
       
    61 			/** Confirmed state */
       
    62 			EConfirmed,
       
    63 			/** Terminated state */
       
    64 			ETerminated,
       
    65 			/** Object is being constructed and is not yet ready for use */
       
    66 			EConstructing
       
    67 			};
       
    68 
       
    69 	public: // Destructor
       
    70         /**
       
    71         * Destructor
       
    72         * @internalComponent       
       
    73 		*/
       
    74 		virtual ~CSIPTransactionBase();
       
    75 
       
    76 	public: // New functions
       
    77         /**
       
    78         * Gets the SIP transaction type
       
    79         * @return SIP transaction type
       
    80         */
       
    81 		IMPORT_C RStringF Type() const;
       
    82 
       
    83 		/**
       
    84 		* Gets SIP transaction state
       
    85 		* @return SIP transaction state
       
    86 		* @leave KErrSIPResourceNotAvailable if a required SIP Client API
       
    87 		*	object has been deleted
       
    88 		*/
       
    89 		IMPORT_C CSIPTransactionBase::TState StateL();
       
    90 
       
    91 		/**
       
    92 		* Checks the if the actual object
       
    93 		* is of type CSIPClientTransaction.
       
    94 		* @return ETrue if object is of type CSIPClientTransaction and
       
    95 		*         EFalse otherwise
       
    96 		*/
       
    97 		IMPORT_C TBool IsSIPClientTransaction() const;
       
    98 
       
    99 		/**
       
   100 		* Compares this object to another object also having
       
   101 		* CSIPTransactionBase base class
       
   102 		* The function has to be implemented in each of the sub-classes.
       
   103 		* @param aTransaction a CSIPTransactionBase object to compare
       
   104 		* @return ETrue if the objects are equal otherwise EFalse
       
   105 		*/
       
   106         IMPORT_C TBool
       
   107             operator==(const CSIPTransactionBase& aTransaction) const;
       
   108 
       
   109 	public: // New functions, for internal use
       
   110         /**
       
   111 		* Obtains the RequestId of the transaction.
       
   112 		*
       
   113         * @return RequestId
       
   114 		*/
       
   115         TUint32 RequestId() const;
       
   116 
       
   117         /**
       
   118 		* Clears the MTransactionAssociation. After this the object can't be
       
   119         * used anymore and it is expected that user will delete it soon.
       
   120         *
       
   121         * @param aAssociation Object requesting the detach
       
   122         * @internalComponent      
       
   123 		*/
       
   124         virtual void Detach(const MTransactionAssociation& aAssociation);
       
   125 
       
   126         /**
       
   127 		* Changes the transaction state.
       
   128         *
       
   129         * @param aNextState State into which transaction moves
       
   130 		*/
       
   131         void ChangeState(CSIPTransactionBase::TState aNextState);
       
   132 
       
   133         /**
       
   134         * Determines whether this transaction has an effect on the associated
       
   135         * dialog's state.
       
   136         *
       
   137 		* @return ETrue if transaction has an effect on the dialog's state,
       
   138         *   EFalse otherwise.
       
   139 		*/
       
   140         TBool AffectsDialogState() const;
       
   141 
       
   142         /**
       
   143 		* Sets this transaction to affect the dialog state.
       
   144 		*/
       
   145         void SetAffectsDialogState();
       
   146 
       
   147         /**
       
   148 		* Determines whether the transaction type is a target refresh request.
       
   149         *
       
   150         * @param aType Type of transaction
       
   151         * @return ETrue If the transaction is a target refresh request, EFalse
       
   152         *   otherwise.
       
   153 		*/
       
   154         static TBool IsTargetRefresh(RStringF aType);
       
   155 
       
   156         /**
       
   157 		* Stores response elements. Depending on the status code, transaction
       
   158         * may enter another state.
       
   159         *
       
   160         * @param aElements Response elements, ownership is transferred.
       
   161 		*/
       
   162         void SetResponseElements(CSIPResponseElements* aElements);
       
   163 
       
   164     protected: // Constructors
       
   165         CSIPTransactionBase(TBool aIsClientTransaction,
       
   166                             TUint32 aRequestId,
       
   167                             MTransactionAssociation& aAssociation);
       
   168 
       
   169         void ConstructL(RStringF aType);
       
   170 
       
   171 	protected: // New functions, for internal use
       
   172         /**
       
   173 		* Checks that iAssociation is available (not NULL). If iAssociation is
       
   174         * NULL, it means user has deleted a resource needed by
       
   175         * CSIPTransactionBase, and this function leaves.
       
   176 		*/
       
   177         void CheckAssociationL() const;
       
   178 
       
   179         /**
       
   180 		* Gets response elements.
       
   181         *
       
   182 		* @return Response elements. Ownership isn't transferred.
       
   183 		*/
       
   184         const CSIPResponseElements* ResponseElements() const;
       
   185 
       
   186 	protected: // Data
       
   187 	
       
   188         /**
       
   189         * RequestId received from SIP client
       
   190         * @internalComponent
       
   191         */       
       
   192         TUint32 iRequestId;
       
   193 
       
   194         /**
       
   195         * Every transaction is associated to exactly one other object:
       
   196         * CSIP, CSIPConnection, CSIPRegistrationBinding or CSIPDialogAssocBase
       
   197         * @internalComponent
       
   198         */        
       
   199         MTransactionAssociation* iAssociation;
       
   200 
       
   201     private: // Data
       
   202 		RStringF iType;
       
   203 
       
   204         //ETrue is the transaction is a client transaction, EFalse otherwise
       
   205         TBool iIsClientTransaction;
       
   206 
       
   207         //Current transaction state
       
   208         CSIPTransactionBase::TState iState;
       
   209 
       
   210         //ETrue if the transaction has an effect on the dialog state in case
       
   211         //the transaction is associated with a dialog.
       
   212         //EFalse otherwise.
       
   213         TBool iAffectsDialogState;
       
   214 
       
   215         //SIP response elements
       
   216         CSIPResponseElements* iResponseElements;
       
   217 
       
   218 	private: // For testing purposes
       
   219 #ifdef CPPUNIT_TEST
       
   220 	    friend class CSIP_Test;
       
   221         friend class CSIPServerTransaction_Test;
       
   222         friend class CSIPSubscribeDialogAssoc_Test;
       
   223         friend class CSIPInviteDialogAssoc_Test;
       
   224         friend class CSIPNotifyDialogAssoc_Test;
       
   225         friend class CSIPConnection_Test;
       
   226 #endif
       
   227 		void __DbgTestInvariant() const;
       
   228 
       
   229     };
       
   230 
       
   231 #endif