1 sipservertransaction.h |
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 : sipservertransaction.h |
|
16 * Part of : SIP Client |
|
17 * Interface : SDK API, SIP API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSIPSERVERTRANSACTION_H |
|
25 #define CSIPSERVERTRANSACTION_H |
|
26 |
|
27 // INCLUDES |
|
28 #include "siptransactionbase.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CSIPRequestElements; |
|
32 class MSIPResponseSender; |
|
33 class CSIPConnection; |
|
34 class CSIPDialogImplementation; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * @publishedAll |
|
40 * @released |
|
41 * |
|
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. |
|
46 * |
|
47 * @lib sipclient |
|
48 */ |
|
49 class CSIPServerTransaction: public CSIPTransactionBase |
|
50 { |
|
51 public: // Destructor |
|
52 |
|
53 /** |
|
54 * Destructor |
|
55 */ |
|
56 IMPORT_C ~CSIPServerTransaction(); |
|
57 |
|
58 public: // New functions |
|
59 |
|
60 /** |
|
61 * Sends response and ends the transaction; |
|
62 * The user must not send 100 Trying response. Leaves on failure. |
|
63 * @pre aElements!=0 |
|
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 |
|
78 */ |
|
79 IMPORT_C void SendResponseL(CSIPResponseElements *aElements); |
|
80 |
|
81 /** |
|
82 * Gets the request elements |
|
83 * @return Request elements. Ownership is not transferred. |
|
84 */ |
|
85 IMPORT_C const CSIPRequestElements* RequestElements() const; |
|
86 |
|
87 /** |
|
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 |
|
91 */ |
|
92 IMPORT_C TBool ResponseAllowed() const; |
|
93 |
|
94 public: // New functions, for internal use |
|
95 |
|
96 /** |
|
97 * Sets a new respose sender, replacing the current sender. |
|
98 * |
|
99 * @param aSender Response sender to be used from now on. Ownership is |
|
100 * transferred. |
|
101 */ |
|
102 void SetResponseSender(MSIPResponseSender* aSender); |
|
103 |
|
104 /** |
|
105 * If the request was received inside a dialog, returns the dialog. |
|
106 * |
|
107 * @return CSIPDialogImplementation* The dialog inside which the request |
|
108 * was received, or NULL. Ownership is not transferred. |
|
109 */ |
|
110 CSIPDialogImplementation* Dialog() const; |
|
111 |
|
112 /** |
|
113 * Obtains the associated CSIPConnection instance. If connection can't |
|
114 * be accessed anymore, this function leaves. |
|
115 * |
|
116 * @return CSIPConnection |
|
117 */ |
|
118 CSIPConnection& SIPConnectionL(); |
|
119 |
|
120 /** |
|
121 * Update the MTransactionAssociation to point to aAssociation. |
|
122 * |
|
123 * @param aAssociation Associated object |
|
124 */ |
|
125 void ReAssociateL(MTransactionAssociation& aAssociation); |
|
126 |
|
127 /** |
|
128 * Removes, but does not delete, request elements from |
|
129 * aServerTransaction. |
|
130 * |
|
131 * @param aServerTransaction Server transaction from which response |
|
132 * elements are removed. Ownership is not transferred. |
|
133 */ |
|
134 static void DetachRequestElements(TAny* aServerTransaction); |
|
135 |
|
136 public: // Constructors, for internal use |
|
137 /** |
|
138 * Creates a server transaction. |
|
139 * |
|
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. |
|
144 */ |
|
145 static CSIPServerTransaction* |
|
146 NewL(TUint32 aRequestId, |
|
147 MTransactionAssociation& aAssociation, |
|
148 CSIPRequestElements* aElements); |
|
149 |
|
150 /** |
|
151 * Creates a server transaction and pushes it to cleanup stack. |
|
152 * |
|
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. |
|
157 */ |
|
158 static CSIPServerTransaction* |
|
159 NewLC(TUint32 aRequestId, |
|
160 MTransactionAssociation& aAssociation, |
|
161 CSIPRequestElements* aElements); |
|
162 |
|
163 private: // Constructors |
|
164 CSIPServerTransaction(TUint32 aRequestId, |
|
165 MTransactionAssociation& aAssociation); |
|
166 |
|
167 /** |
|
168 * Second phase constructor. |
|
169 * |
|
170 * @pre aElements!=0 |
|
171 * @param aElements Request elements. Ownership is transferred. |
|
172 */ |
|
173 void ConstructL(CSIPRequestElements* aElements); |
|
174 |
|
175 private: // Data |
|
176 CSIPRequestElements* iRequestElements; |
|
177 |
|
178 //This interface is used for sending the response. |
|
179 //CSIPServerTransaction owns iResponseSender. |
|
180 MSIPResponseSender* iResponseSender; |
|
181 |
|
182 private: // For testing purposes |
|
183 |
|
184 UNIT_TEST(CSIPServerTransaction_Test) |
|
185 UNIT_TEST(CSIP_Test) |
|
186 |
|
187 __DECLARE_TEST; |
|
188 }; |
|
189 |
|
190 #endif |