2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : siptransactionbase.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
24 #ifndef CSIPTRANSACTIONBASE_H
25 #define CSIPTRANSACTIONBASE_H
29 #include <stringpool.h>
31 // FORWARD DECLARATIONS
32 class CSIPResponseElements;
33 class MTransactionAssociation;
41 * Base class for managing SIP transactions.
42 * It provides services for querying transaction type and its state.
44 * This class is an abstract class and cannot be instantiated.
47 class CSIPTransactionBase: public CBase
50 /** SIP transaction state */
57 /** Proceeding state */
59 /** Completed state */
61 /** Confirmed state */
63 /** Terminated state */
65 /** Object is being constructed and is not yet ready for use */
74 virtual ~CSIPTransactionBase();
76 public: // New functions
78 * Gets the SIP transaction type
79 * @return SIP transaction type
81 IMPORT_C RStringF Type() const;
84 * Gets SIP transaction state
85 * @return SIP transaction state
86 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
87 * object has been deleted
89 IMPORT_C CSIPTransactionBase::TState StateL();
92 * Checks the if the actual object
93 * is of type CSIPClientTransaction.
94 * @return ETrue if object is of type CSIPClientTransaction and
97 IMPORT_C TBool IsSIPClientTransaction() const;
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
107 operator==(const CSIPTransactionBase& aTransaction) const;
109 public: // New functions, for internal use
111 * Obtains the RequestId of the transaction.
115 TUint32 RequestId() const;
118 * Clears the MTransactionAssociation. After this the object can't be
119 * used anymore and it is expected that user will delete it soon.
121 * @param aAssociation Object requesting the detach
124 virtual void Detach(const MTransactionAssociation& aAssociation);
127 * Changes the transaction state.
129 * @param aNextState State into which transaction moves
131 void ChangeState(CSIPTransactionBase::TState aNextState);
134 * Determines whether this transaction has an effect on the associated
137 * @return ETrue if transaction has an effect on the dialog's state,
140 TBool AffectsDialogState() const;
143 * Sets this transaction to affect the dialog state.
145 void SetAffectsDialogState();
148 * Determines whether the transaction type is a target refresh request.
150 * @param aType Type of transaction
151 * @return ETrue If the transaction is a target refresh request, EFalse
154 static TBool IsTargetRefresh(RStringF aType);
157 * Stores response elements. Depending on the status code, transaction
158 * may enter another state.
160 * @param aElements Response elements, ownership is transferred.
162 void SetResponseElements(CSIPResponseElements* aElements);
164 protected: // Constructors
165 CSIPTransactionBase(TBool aIsClientTransaction,
167 MTransactionAssociation& aAssociation);
169 void ConstructL(RStringF aType);
171 protected: // New functions, for internal use
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.
177 void CheckAssociationL() const;
180 * Gets response elements.
182 * @return Response elements. Ownership isn't transferred.
184 const CSIPResponseElements* ResponseElements() const;
189 * RequestId received from SIP client
195 * Every transaction is associated to exactly one other object:
196 * CSIP, CSIPConnection, CSIPRegistrationBinding or CSIPDialogAssocBase
199 MTransactionAssociation* iAssociation;
204 //ETrue is the transaction is a client transaction, EFalse otherwise
205 TBool iIsClientTransaction;
207 //Current transaction state
208 CSIPTransactionBase::TState iState;
210 //ETrue if the transaction has an effect on the dialog state in case
211 //the transaction is associated with a dialog.
213 TBool iAffectsDialogState;
215 //SIP response elements
216 CSIPResponseElements* iResponseElements;
218 private: // For testing purposes
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;
227 void __DbgTestInvariant() const;