|
1 /* |
|
2 * Copyright (c) 2008-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 "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 * Name : TransactionInfo.h |
|
16 * Part of : TransactionUser |
|
17 * Version : SIP/6.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef TRANSACTIONINFO_H |
|
29 #define TRANSACTIONINFO_H |
|
30 |
|
31 // INCLUDES |
|
32 #include "TransactionBase.h" |
|
33 #include <e32base.h> |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class RStringF; |
|
37 class CURIContainer; |
|
38 class CSIPToHeader; |
|
39 class CSIPFromHeader; |
|
40 class CSIPViaHeader; |
|
41 class CSIPMessage; |
|
42 class CSIPCallIDHeader; |
|
43 class CSIPRecordRouteHeader; |
|
44 class CSIPContactHeader; |
|
45 |
|
46 class CUserAgent; |
|
47 class MTransactionHeaders; |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 /** |
|
52 * This class contains information identifying a transaction (=certain headers |
|
53 * from the SIP request that initiated the transaction), together with the |
|
54 * addresses of the CUserAgent and CTransaction objects created for handling |
|
55 * that transaction. |
|
56 */ |
|
57 class CTransactionInfo : public CBase |
|
58 { |
|
59 public: // Constructor and destructor |
|
60 |
|
61 /** |
|
62 * Creates a new object. |
|
63 * @param aType Identifies the transaction type |
|
64 * @param aIapId IAP-id |
|
65 * @return value New CTransactionInfo object, ownership is transferred. |
|
66 */ |
|
67 static CTransactionInfo* NewL(CTransactionBase::TTransactionType aType, |
|
68 TUint32 aIapId); |
|
69 |
|
70 /** |
|
71 * Destructor. Deletes the owned resources, except does NOT delete UA or |
|
72 * transaction. |
|
73 * @see FreeContents |
|
74 */ |
|
75 ~CTransactionInfo(); |
|
76 |
|
77 public: // New functions |
|
78 |
|
79 /** |
|
80 * Deletes the stored UA and/or transaction. |
|
81 * @see ~CTransactionStore |
|
82 */ |
|
83 void FreeContents(); |
|
84 |
|
85 /** |
|
86 * Checks whether all the required headers for transaction matching and |
|
87 * constructing a SIP response are present. |
|
88 * @return ETrue if required headers exist, EFalse otherwise |
|
89 */ |
|
90 TBool RequiredHeadersPresent() const; |
|
91 |
|
92 /** |
|
93 * Compares the stored iTransactionType to aType. |
|
94 * @param aType TransactionType which is compared |
|
95 * @return ETrue if types are same, EFalse otherwise |
|
96 */ |
|
97 TBool CompareType(CTransactionBase::TTransactionType aType) const; |
|
98 |
|
99 /** |
|
100 * Compares the aMethod to the iMethod for determining if the SIP message |
|
101 * with the aMethod belongs to the same transaction. |
|
102 * |
|
103 * If the SIP message that created the transaction was a request, iMethod |
|
104 * is the request method, otherwise it is the method from CSeq. |
|
105 * @param aMethod If the SIP message is request, this is the request |
|
106 * method. Otherwise, this is the method from CSeq. |
|
107 * @return value ETrue if the methods can belong to same transaction |
|
108 */ |
|
109 TBool CompareMethod(RStringF aMethod) const; |
|
110 |
|
111 /** |
|
112 * Compares the Request-URI and request method to the stored values. |
|
113 * @see CompareMethod |
|
114 * @param aReqURI Request-URI |
|
115 * @param aMethod Request method |
|
116 * @param aSearchCanceledUas ETrue: search is done to find an UAS to be |
|
117 * canceled. EFalse: search is done to find a transaction to receive an |
|
118 * incoming SIP message. |
|
119 * @return value ETrue: If both aReqURI and aMethod match the stored values |
|
120 * EFalse: otherwise |
|
121 */ |
|
122 TBool CompareRequestLine(const CURIContainer& aReqUri, |
|
123 RStringF aMethod, |
|
124 TBool aSearchCanceledUas) const; |
|
125 |
|
126 /** |
|
127 * Compares the SIP headers of aReq to the stored headers, and determines |
|
128 * if the transactions match. |
|
129 * @param aReq SIP request |
|
130 * @return ETrue if match, EFalse otherwise |
|
131 */ |
|
132 TBool CompareHeaders(CSIPRequest& aReq) const; |
|
133 |
|
134 /** |
|
135 * Obtains a MTransactionReceiver that should handle events received from |
|
136 * the network. Returns transaction, if it exists, or UA if transaction does |
|
137 * not exist. |
|
138 * @return MTransactionReceiver Pointer to the receiver interface. |
|
139 * Ownership isn't transferred. |
|
140 */ |
|
141 MTransactionReceiver* Receiver(); |
|
142 |
|
143 /** |
|
144 * Returns the UA. |
|
145 * @return Pointer to UA instance. Can be NULL. Ownership isn't transferred. |
|
146 */ |
|
147 CUserAgent* UserAgent(); |
|
148 |
|
149 /** |
|
150 * Sets the stored UA. |
|
151 * @post iUserAgent == aUserAgent |
|
152 * @param aUserAgent UA instance, can be NULL. Ownership is transferred. |
|
153 */ |
|
154 void SetUserAgent(CUserAgent* aUserAgent); |
|
155 |
|
156 /** |
|
157 * Sets the stored transaction. |
|
158 * @post iTransaction == aTransaction |
|
159 * @return Pointer to transaction. Can be NULL. Ownership isn't transferred. |
|
160 */ |
|
161 void SetTransaction(CTransactionBase* aTransaction); |
|
162 |
|
163 /** |
|
164 * Obtain the TransactionId |
|
165 * @return TransactionId |
|
166 */ |
|
167 TTransactionId TransactionId() const; |
|
168 |
|
169 /** |
|
170 * Set new value for TransactionId |
|
171 * @param aTransactionId TransactionId |
|
172 */ |
|
173 void SetTransactionId(TTransactionId aTransactionId); |
|
174 |
|
175 /** |
|
176 * Obtain the IAP-id. |
|
177 * @return IAP-id |
|
178 */ |
|
179 TUint32 IapId() const; |
|
180 |
|
181 /** |
|
182 * Returns the topmost of the stored Via headers. Caller must not modify |
|
183 * the Via header. |
|
184 * @pre iViaHeaders.Count() > 0 |
|
185 * @return Topmost Via header |
|
186 */ |
|
187 CSIPViaHeader& TopVia() const; |
|
188 |
|
189 /** |
|
190 * Copies and stores the transaction related headers from the SIP message. |
|
191 * The possibly existing old headers are removed from CTransactionInfo, |
|
192 * regardless whether the same header is present in the aMsg, so that |
|
193 * CTransactionInfo won't contain headers from more than one different SIP |
|
194 * message. |
|
195 * @param aMsg SIP message from where the headers are copied, can be NULL. |
|
196 * Ownership isn't transferred. If aMsg is NULL, nothing is done. |
|
197 */ |
|
198 void UpdateMessageHeadersL(CSIPMessage* aMsg); |
|
199 |
|
200 /** |
|
201 * Updates the To tag. |
|
202 * @pre iTo != NULL, iTo->HasTag() == EFalse |
|
203 * @param aTag To tag |
|
204 */ |
|
205 void UpdateToTagL(RStringF aTag); |
|
206 |
|
207 void StoreRecordRouteHeadersL(CSIPRequest& aReq); |
|
208 void FreeRecordRouteHeaders(); |
|
209 |
|
210 void StoreContactHeadersL(CSIPRequest& aReq); |
|
211 void FreeContactHeaders(); |
|
212 |
|
213 /** |
|
214 * Checks a request with the aFrom, aCallID, aCSeqNbr and aCSeqMethod is a |
|
215 * merged request by comparing these values to CTransactionInfo's similar |
|
216 * values. |
|
217 * @param aUserAgent UA initiating the search |
|
218 * @param aFrom From header of a received request |
|
219 * @param aCallID Call-ID header of a received request |
|
220 * @param aCSeqNbr CSeq sequence number of a received request |
|
221 * @param aCSeqMethod CSeq method of a received request |
|
222 * @return ETrue if the request is a merged request, EFalse otherwise. |
|
223 */ |
|
224 TBool IsMergedRequest(const CUserAgent& aUserAgent, |
|
225 CSIPFromHeader& aFrom, |
|
226 CSIPCallIDHeader& aCallID, |
|
227 TUint aCSeqNbr, |
|
228 RStringF aCSeqMethod) const; |
|
229 |
|
230 MTransactionHeaders* TransactionHeadersL(); |
|
231 |
|
232 /** |
|
233 * Copies To, From, Call-ID and CSeq headers from CTransactionInfo into the |
|
234 * SIP message. If some headers already exist in the aMsg, they are not |
|
235 * replaced. |
|
236 * @param aMsg SIP message to which the headers are copied |
|
237 */ |
|
238 void CopyToFromCallIDCSeqToMsgL(CSIPMessage& aMsg) const; |
|
239 |
|
240 /** |
|
241 * Copies the stored Via headers into the SIP message. |
|
242 * @param aMsg SIP message into which where the Vias are copied |
|
243 */ |
|
244 void CopyViaHeadersToMsgL(CSIPMessage& aMsg) const; |
|
245 |
|
246 void CopyRequestUriToRequestL(CSIPRequest& aReq) const; |
|
247 |
|
248 /** |
|
249 * Creates a SIP request from the stored headers. |
|
250 * @return SIP request, or NULL if there is not enough information to |
|
251 * create it. Ownership is transferred. |
|
252 */ |
|
253 CSIPRequest* BuildRequestFromStoredInfoL() const; |
|
254 |
|
255 /** |
|
256 * Returns the request method. |
|
257 * @return Request method |
|
258 */ |
|
259 RStringF RequestMethod() const; |
|
260 |
|
261 TSglQueLink iLink; |
|
262 |
|
263 private: // New functions, for internal use |
|
264 |
|
265 /** |
|
266 * Constructor |
|
267 * @param aType Identifies the transaction type |
|
268 * @param aIapId IAP-id |
|
269 */ |
|
270 CTransactionInfo(CTransactionBase::TTransactionType aType, TUint32 aIapId); |
|
271 |
|
272 /** |
|
273 * Clears the SIP message related members |
|
274 */ |
|
275 void ClearMessageHeaders(); |
|
276 |
|
277 /** |
|
278 * Checks if the method has been stored. |
|
279 * @param ETrue method has been stored, EFalse otherwise |
|
280 */ |
|
281 TBool MethodExists() const; |
|
282 |
|
283 /** |
|
284 * Copies and stores the Via headers from aMsg, maintaining their order. |
|
285 * @param aMsg SIP message |
|
286 */ |
|
287 void CopyViaHeadersFromMsgL(CSIPMessage& aMsg); |
|
288 |
|
289 private: // Data |
|
290 |
|
291 TTransactionId iTransactionId; |
|
292 CTransactionBase::TTransactionType iTransactionType; |
|
293 |
|
294 // IAP-id |
|
295 TUint32 iIapId; |
|
296 |
|
297 // UA, owned. NULL if iTransaction has been detached from UA. |
|
298 CUserAgent* iUserAgent; |
|
299 |
|
300 // Transaction, can be NULL. Not owned. |
|
301 CTransactionBase* iTransaction; |
|
302 |
|
303 // Request-URI, owned. |
|
304 CURIContainer* iRequestURI; |
|
305 |
|
306 // To header, can be NULL. Owned. |
|
307 CSIPToHeader* iTo; |
|
308 // From header, can be NULL. Owned. |
|
309 CSIPFromHeader* iFrom; |
|
310 // Call-ID header, can be NULL. Owned. |
|
311 CSIPCallIDHeader* iCallID; |
|
312 |
|
313 // Method from Request line (=same as CSeq method), can be NULL |
|
314 RStringF iMethod; |
|
315 |
|
316 // CSeq sequence number |
|
317 TUint iCSeq; |
|
318 |
|
319 // All Via headers of the SIP request are copied here. |
|
320 RPointerArray<CSIPViaHeader> iViaHeaders; |
|
321 |
|
322 // Record-route headers, owned. |
|
323 // Stored only for incoming requests outside of a dialog. |
|
324 RPointerArray<CSIPRecordRouteHeader> iRecordRoute; |
|
325 |
|
326 // Contact headers, owned. |
|
327 // Stored only for incoming requests outside of a dialog. |
|
328 RPointerArray<CSIPContactHeader> iContact; |
|
329 |
|
330 |
|
331 #ifdef CPPUNIT_TEST |
|
332 friend class CTransactionStore_Test; |
|
333 friend class CNormalUAC_ResolveAddress_Test; |
|
334 friend class CNormalUAC_WaitResponse_Test; |
|
335 friend class CTransactionUser_Test; |
|
336 friend class CUserAgentServer_Test; |
|
337 friend class CTransactionInfo_Test; |
|
338 #endif |
|
339 }; |
|
340 |
|
341 #endif // end of TRANSACTIONINFO_H |
|
342 |
|
343 // End of File |