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 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".
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>
30 #include "_sipcodecdefs.h"
32 // FORWARD DECLARATIONS
33 class CSIPResponseElements;
34 class MTransactionAssociation;
42 * Base class for managing SIP transactions.
43 * It provides services for querying transaction type and its state.
45 * This class is an abstract class and cannot be instantiated.
48 class CSIPTransactionBase: public CBase
51 /** SIP transaction state */
58 /** Proceeding state */
60 /** Completed state */
62 /** Confirmed state */
64 /** Terminated state */
66 /** Object is being constructed and is not yet ready for use */
75 virtual ~CSIPTransactionBase();
77 public: // New functions
79 * Gets the SIP transaction type
80 * @return SIP transaction type
82 IMPORT_C RStringF Type() const;
85 * Gets SIP transaction state
86 * @return SIP transaction state
87 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
88 * object has been deleted
90 IMPORT_C CSIPTransactionBase::TState StateL();
93 * Checks the if the actual object
94 * is of type CSIPClientTransaction.
95 * @return ETrue if object is of type CSIPClientTransaction and
98 IMPORT_C TBool IsSIPClientTransaction() const;
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
108 operator==(const CSIPTransactionBase& aTransaction) const;
110 public: // New functions, for internal use
112 * Obtains the RequestId of the transaction.
116 TUint32 RequestId() const;
119 * Clears the MTransactionAssociation. After this the object can't be
120 * used anymore and it is expected that user will delete it soon.
122 * @param aAssociation Object requesting the detach
125 virtual void Detach(const MTransactionAssociation& aAssociation);
128 * Changes the transaction state.
130 * @param aNextState State into which transaction moves
132 void ChangeState(CSIPTransactionBase::TState aNextState);
135 * Determines whether this transaction has an effect on the associated
138 * @return ETrue if transaction has an effect on the dialog's state,
141 TBool AffectsDialogState() const;
144 * Sets this transaction to affect the dialog state.
146 void SetAffectsDialogState();
149 * Determines whether the transaction type is a target refresh request.
151 * @param aType Type of transaction
152 * @return ETrue If the transaction is a target refresh request, EFalse
155 static TBool IsTargetRefresh(RStringF aType);
158 * Stores response elements. Depending on the status code, transaction
159 * may enter another state.
161 * @param aElements Response elements, ownership is transferred.
163 void SetResponseElements(CSIPResponseElements* aElements);
165 protected: // Constructors
166 CSIPTransactionBase(TBool aIsClientTransaction,
168 MTransactionAssociation& aAssociation);
170 void ConstructL(RStringF aType);
172 protected: // New functions, for internal use
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.
178 void CheckAssociationL() const;
181 * Gets response elements.
183 * @return Response elements. Ownership isn't transferred.
185 const CSIPResponseElements* ResponseElements() const;
190 * RequestId received from SIP client
196 * Every transaction is associated to exactly one other object:
197 * CSIP, CSIPConnection, CSIPRegistrationBinding or CSIPDialogAssocBase
200 MTransactionAssociation* iAssociation;
205 //ETrue is the transaction is a client transaction, EFalse otherwise
206 TBool iIsClientTransaction;
208 //Current transaction state
209 CSIPTransactionBase::TState iState;
211 //ETrue if the transaction has an effect on the dialog state in case
212 //the transaction is associated with a dialog.
214 TBool iAffectsDialogState;
216 //SIP response elements
217 CSIPResponseElements* iResponseElements;
219 private: // For testing purposes
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)