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