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