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 : sipservertransaction.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP API
24 #ifndef CSIPSERVERTRANSACTION_H
25 #define CSIPSERVERTRANSACTION_H
28 #include "siptransactionbase.h"
30 // FORWARD DECLARATIONS
31 class CSIPRequestElements;
32 class MSIPResponseSender;
34 class CSIPDialogImplementation;
42 * Class for managing SIP server transactions.
43 * It provides services for creating, ending
44 * and getting SIP transaction parameters.
45 * Client cannot instantiate this class.
49 class CSIPServerTransaction: public CSIPTransactionBase
56 IMPORT_C ~CSIPServerTransaction();
58 public: // New functions
61 * Sends response and ends the transaction;
62 * The user must not send 100 Trying response. Leaves on failure.
64 * @pre State()==ETrying || State()==EProceeding
65 * @pre CSIPConnection::State()==EActive
66 * @pre ResponseAllowed()==ETrue
67 * @param aElements contains Status Code, optional Reason Phrase and
68 * optional SIP message headers and body. Ownership is transferred.
69 * @leave KErrArgument if aElements == NULL
70 * @leave KErrGeneral if ResponseAllowed() == EFalse
71 * @leave KErrSIPInvalidTransactionState if State()!=ETrying and
72 * State()!=EProceeding
73 * @leave KErrSIPInvalidDialogState if sending response to a request
74 * within dialog, and the dialog is in terminated state.
75 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
76 * object has been deleted
77 * @capability NetworkServices
79 IMPORT_C void SendResponseL(CSIPResponseElements *aElements);
82 * Gets the request elements
83 * @return Request elements. Ownership is not transferred.
85 IMPORT_C const CSIPRequestElements* RequestElements() const;
88 * Checks if the response sending is allowed for this server
89 * transaction. For instance response is not allowed in ACK transaction.
90 * @return ETrue if response sending is allowed, EFalse otherwise
92 IMPORT_C TBool ResponseAllowed() const;
94 public: // New functions, for internal use
97 * Sets a new respose sender, replacing the current sender.
99 * @param aSender Response sender to be used from now on. Ownership is
102 void SetResponseSender(MSIPResponseSender* aSender);
105 * If the request was received inside a dialog, returns the dialog.
107 * @return CSIPDialogImplementation* The dialog inside which the request
108 * was received, or NULL. Ownership is not transferred.
110 CSIPDialogImplementation* Dialog() const;
113 * Obtains the associated CSIPConnection instance. If connection can't
114 * be accessed anymore, this function leaves.
116 * @return CSIPConnection
118 CSIPConnection& SIPConnectionL();
121 * Update the MTransactionAssociation to point to aAssociation.
123 * @param aAssociation Associated object
125 void ReAssociateL(MTransactionAssociation& aAssociation);
128 * Removes, but does not delete, request elements from
129 * aServerTransaction.
131 * @param aServerTransaction Server transaction from which response
132 * elements are removed. Ownership is not transferred.
134 static void DetachRequestElements(TAny* aServerTransaction);
136 public: // Constructors, for internal use
138 * Creates a server transaction.
140 * @param aRequestId RequestId for the transaction to use
141 * @param aAssociation Object with which the transaction is associated
142 * @param aElements Request elements. Ownership is transferred.
143 * @return New object. Ownership is transferred.
145 static CSIPServerTransaction*
146 NewL(TUint32 aRequestId,
147 MTransactionAssociation& aAssociation,
148 CSIPRequestElements* aElements);
151 * Creates a server transaction and pushes it to cleanup stack.
153 * @param aRequestId RequestId for the transaction to use
154 * @param aAssociation Object with which the transaction is associated
155 * @param aElements Request elements. Ownership is transferred.
156 * @return New object. Ownership is transferred.
158 static CSIPServerTransaction*
159 NewLC(TUint32 aRequestId,
160 MTransactionAssociation& aAssociation,
161 CSIPRequestElements* aElements);
163 private: // Constructors
164 CSIPServerTransaction(TUint32 aRequestId,
165 MTransactionAssociation& aAssociation);
168 * Second phase constructor.
171 * @param aElements Request elements. Ownership is transferred.
173 void ConstructL(CSIPRequestElements* aElements);
176 CSIPRequestElements* iRequestElements;
178 //This interface is used for sending the response.
179 //CSIPServerTransaction owns iResponseSender.
180 MSIPResponseSender* iResponseSender;
182 private: // For testing purposes
184 UNIT_TEST(CSIPServerTransaction_Test)