|
1 /* |
|
2 * Copyright (c) 2006-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 : CTransactionUser.h |
|
16 * Part of : TransactionUser |
|
17 * Version : SIP/5.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef CTRANSACTIONUSER_H |
|
29 #define CTRANSACTIONUSER_H |
|
30 |
|
31 // INCLUDES |
|
32 #include <e32base.h> |
|
33 #include <bamdesca.h> |
|
34 #include <stringpool.h> |
|
35 #include <commsdattypesv1_1.h> |
|
36 |
|
37 #include "sipinternalstates.h" |
|
38 |
|
39 #include "MTransactionUser.h" |
|
40 #include "MServerTaFactory.h" |
|
41 #include "MConnectionStateObserver.h" |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class MSIPRequestRouter; |
|
45 class MTimerManager; |
|
46 class CSipConnectionMgr; |
|
47 class MSipDialogs; |
|
48 class MSipRegistrations; |
|
49 class MSipRegistrationContact; |
|
50 class CDeleteMgr; |
|
51 class CSIPSec; |
|
52 class CTransactionMgr; |
|
53 |
|
54 class MTransactionOwner; |
|
55 class CTransactionStore; |
|
56 class CUserAgent; |
|
57 class CCancelUAC; |
|
58 class CUserAgentCreateParams; |
|
59 class CTimerValueRetriever; |
|
60 class CSIPMessageUtility; |
|
61 class CInviteUAC_Start; |
|
62 class CInviteUAC_ResolveAddress; |
|
63 class CInviteUAC_WaitResponse; |
|
64 class CInviteUAC_WaitAckFromApp; |
|
65 class CInviteUAC_ResolveAckAddress; |
|
66 class CInviteUAC_SendingAck; |
|
67 class CInviteUAC_WaitTransactionToEnd; |
|
68 class CInviteUAC_WaitAuthentication; |
|
69 class CNormalUAC_Start; |
|
70 class CNormalUAC_ResolveAddress; |
|
71 class CNormalUAC_WaitResponse; |
|
72 class CNormalUAC_WaitAuthentication; |
|
73 class CInviteUAS_Start; |
|
74 class CInviteUAS_GetTxOwner; |
|
75 class CInviteUAS_WaitRespFromApp; |
|
76 class CInviteUAS_Accepted; |
|
77 class CInviteUAS_Rejected; |
|
78 class CNormalUAS_Start; |
|
79 class CNormalUAS_GetTxOwner; |
|
80 class CNormalUAS_WaitRespFromApp; |
|
81 class CNormalUAS_FinalRespSent; |
|
82 class CCancelUAC_Start; |
|
83 class CCancelUAC_ResolveAddress; |
|
84 class CCancelUAC_WaitResponse; |
|
85 class CCancelUAC_WaitAuthentication; |
|
86 class CCancelUAS_Start; |
|
87 class CCancelUAS_FinalRespSent; |
|
88 |
|
89 // CLASS DECLARATION |
|
90 |
|
91 /** |
|
92 * CTransactionUser class is the interface for using TransactionUser subsystem. |
|
93 */ |
|
94 class CTransactionUser : |
|
95 public CBase, |
|
96 public MTransactionUser, |
|
97 public MServerTaFactory, |
|
98 public MConnectionStateObserver |
|
99 { |
|
100 public: // Constructors and destructor |
|
101 |
|
102 /** |
|
103 * Creates TransactionUser subsystem. |
|
104 * |
|
105 * @pre aRouter != NULL, aTimers != NULL |
|
106 * |
|
107 * @param aRouter Router interface. Ownership isn't transferred. |
|
108 * @param aTimers Lwtimer interface. Ownership isn't transferred. |
|
109 * @param aObserver Callback to pass connection state information |
|
110 * @return value New CTransactionUser object, ownership is transferred. |
|
111 */ |
|
112 static CTransactionUser* NewL(MSIPRequestRouter* aRouter, |
|
113 MTimerManager* aTimers, |
|
114 MConnectionStateObserver& aObserver); |
|
115 |
|
116 /** |
|
117 * Destructor. All existing transactions are immediately stopped. |
|
118 */ |
|
119 ~CTransactionUser(); |
|
120 |
|
121 public : // From MTransactionUser |
|
122 |
|
123 void SendL(TTransactionId& aTransactionId, |
|
124 TRegistrationId aRegistrationId, |
|
125 CSIPRequest* aRequest, |
|
126 MTransactionOwner* aObserver, |
|
127 CURIContainer& aRemoteTarget, |
|
128 const TSIPTransportParams& aTransportParams, |
|
129 TBool aDeleteRequest); |
|
130 |
|
131 MTransactionHeaders* SendAndGetHeadersL( |
|
132 TTransactionId& aTransactionId, |
|
133 TRegistrationId aRegistrationId, |
|
134 CSIPRequest* aRequest, |
|
135 MTransactionOwner* aObserver, |
|
136 CURIContainer& aRemoteTarget, |
|
137 const TSIPTransportParams& aTransportParams, |
|
138 TBool aDeleteRequest); |
|
139 |
|
140 void SendL(TTransactionId aTransactionId, |
|
141 CSIPResponse* aResponse, |
|
142 const TSIPTransportParams& aTransportParams) const; |
|
143 |
|
144 void SendL(TTransactionId aTransactionId, |
|
145 CSIPResponse* aResponse, |
|
146 MTransactionOwner* aObserver, |
|
147 const TSIPTransportParams& aTransportParams) const; |
|
148 |
|
149 void SendCancelL(TTransactionId aInviteTaId, |
|
150 TTransactionId& aCancelTaId, |
|
151 MTransactionOwner* aObserver); |
|
152 |
|
153 TInt ClearTransactionOwner(TTransactionId aTransactionId) const; |
|
154 |
|
155 TInt ClearTransactionOwner(MTransactionOwner* aObserver) const; |
|
156 |
|
157 |
|
158 void GetLocalAddress(TUint32 aIapId, TInetAddr& aAddr) const; |
|
159 |
|
160 void FreeResources(MSIPNATBindingObserver& aSIPNATBindingObserver ); |
|
161 |
|
162 MTransactionHeaders* |
|
163 TransactionHeadersL(TTransactionId aTransactionId) const; |
|
164 |
|
165 void MakeTagL(TDes8& aTag) const; |
|
166 |
|
167 virtual TInt NextHopIP( |
|
168 const TTransactionId& aTransactionId, TInetAddr& aAddr); |
|
169 |
|
170 public: // From MServerTaFactory |
|
171 |
|
172 virtual MReceiverObserver* |
|
173 NewTransactionL(CSIPRequest& aRequest, |
|
174 const TSIPTransportParams& aParams, |
|
175 TTransactionId& aTransactionId); |
|
176 |
|
177 public: // From MConnectionStateObserver |
|
178 |
|
179 void ConnectionStateChangedL(TUint32 aIapId, CSIPConnection::TState aState); |
|
180 |
|
181 public: // New functions |
|
182 |
|
183 /** |
|
184 * Returns a reference to SIPSec. |
|
185 * |
|
186 * @returns SIPSec |
|
187 */ |
|
188 CSIPSec& SIPSec(); |
|
189 |
|
190 /** |
|
191 * Returns a reference to SIP ConnnectionMgr. |
|
192 * |
|
193 * @returns ConnectionMgr |
|
194 */ |
|
195 CSipConnectionMgr& SipConnectionMgr(); |
|
196 |
|
197 /** |
|
198 * Gives the address of SIP Dialogs subsystem to TransactionUser subsystem. |
|
199 * |
|
200 * @pre aSipDialogs != NULL |
|
201 * |
|
202 * @param aSipDialogs IN: address of SIP Dialogs subsystem. Ownership isn't |
|
203 * transferred |
|
204 */ |
|
205 void SetDialogs(MSipDialogs* aSipDialogs); |
|
206 |
|
207 /** |
|
208 * Gives the interfaces of SIP Registrations subsystem for TransactionUser |
|
209 * subsystem. |
|
210 * |
|
211 * @pre aSipRegistrations != NULL, aRegistrationContact != NULL |
|
212 * |
|
213 * @param aSipRegistrations IN: interface for checking AORs. Ownership |
|
214 * isn't transferred |
|
215 * @param aRegistrationContact IN: interface for obtaining Contact header. |
|
216 * Ownership isn't transferred |
|
217 */ |
|
218 void SetRegistrations(MSipRegistrations* aSipRegistrations, |
|
219 MSipRegistrationContact* aRegistrationContact); |
|
220 |
|
221 /** |
|
222 * Obtains the state of the specified transaction. |
|
223 * |
|
224 * @param aTransactionId TransactionId of the transaction whose state is |
|
225 * requested. |
|
226 * @param aState OUT: Transaction state |
|
227 * @leave KErrNotFound if no such transaction exists. |
|
228 */ |
|
229 void GetStateL(TTransactionId aTransactionId, |
|
230 CSIPInternalStates::TState& aState) const; |
|
231 |
|
232 private: // Constructors, for internal use |
|
233 |
|
234 CTransactionUser(MSIPRequestRouter* aRouter, |
|
235 MTimerManager* aTimers, |
|
236 MConnectionStateObserver& aStateObserver); |
|
237 |
|
238 void ConstructL(); |
|
239 |
|
240 private: // New functions, for internal use |
|
241 |
|
242 /** |
|
243 * Builds UA state machines by creating the state objects and linking them |
|
244 * together. |
|
245 */ |
|
246 void ConstructUaStateMachinesL(); |
|
247 |
|
248 /** |
|
249 * Generate a new value to be used as a CSeq sequence number. |
|
250 * |
|
251 * @return value Sequence number |
|
252 */ |
|
253 TUint32 NewCSeqValue(); |
|
254 |
|
255 /** |
|
256 * Fills the common parameters for creating a new UA. |
|
257 * |
|
258 * @param aTransactionId Transaction id for the new UserAgent |
|
259 * @param aObserver Callback to the upper layer. Can be NULL. Ownership |
|
260 * isn't transferred. |
|
261 * @param aDeleteOutgoingMsg If ETrue, UserAgent deletes iOutgoingMsg when |
|
262 * UserAgent itself is deleted. |
|
263 * @param aParams IN: Transport parameters to be used when handing a SIP |
|
264 * message to SIP Connection Mgr. |
|
265 * @return Object containing the common parameters for all UserAgent types. |
|
266 * Ownership is transferred. |
|
267 */ |
|
268 CUserAgentCreateParams* FillUserAgentParamsLC(TTransactionId aTransactionId, |
|
269 MTransactionOwner* aObserver, |
|
270 TBool aDeleteOutgoingMsg, |
|
271 const TSIPTransportParams& aParams) const; |
|
272 |
|
273 /** |
|
274 * Creates an UAS for handling a SIP request received from network. |
|
275 * |
|
276 * @param aTaId TransactionId for the UAS |
|
277 * @param aMethod Method of the SIP request |
|
278 * @param aParams IN: Transport parameters to be used when handing a SIP |
|
279 * message to SIP Connection Mgr. |
|
280 * @return value New UA object, ownership is transferred |
|
281 */ |
|
282 CUserAgent* CreateUasL(TTransactionId aTaId, |
|
283 RStringF aMethod, |
|
284 const TSIPTransportParams& aParams) const; |
|
285 |
|
286 /** |
|
287 * Creates an UAC for sending a new SIP request to network. |
|
288 * |
|
289 * @param aTaId TransactionId for the UAC |
|
290 * @param aMethod Method of the SIP request |
|
291 * @param aObserver Callback where UAC sends the response and other events |
|
292 * @param aDeleteRequest If ETrue, UAC will delete the SIP request when UAC |
|
293 * ends. If EFalse, UAC doesn't delete the SIP request. In either case, |
|
294 * UAC can modify the request. |
|
295 * @param aCSeqNumber CSeq sequence number for UAC to use, unless filled by |
|
296 * upper layer. |
|
297 * @param aParams IN: Transport parameters to be used when handing a SIP |
|
298 * request to SIP Connection Mgr. |
|
299 * @return value New UA object, ownership is transferred |
|
300 */ |
|
301 CUserAgent* CreateUacL(TTransactionId aTaId, |
|
302 RStringF aMethod, |
|
303 MTransactionOwner& aObserver, |
|
304 TBool aDeleteRequest, |
|
305 TUint32 aCSeqNumber, |
|
306 const TSIPTransportParams& aParams) const; |
|
307 |
|
308 /** |
|
309 * Creates UAC for sending CANCEL request to network. |
|
310 * |
|
311 * @param aTaId TransactionId for the UAC |
|
312 * @param aObserver Callback where UAC sends the response an other events |
|
313 * @param aCSeqNumber CSeq sequence number for UAC to use, unless filled by |
|
314 * upper layer. |
|
315 * @param aParams IN: Transport parameters to be used when handing a SIP |
|
316 * request to SIP Connection Mgr. |
|
317 * @return value New CancelUAC object, ownership is transferred |
|
318 */ |
|
319 CCancelUAC* |
|
320 CreateCancelUacL(TTransactionId aTaId, |
|
321 MTransactionOwner& aObserver, |
|
322 TUint32 aCSeqNumber, |
|
323 const TSIPTransportParams& aParams) const; |
|
324 |
|
325 /** |
|
326 * Returns the Timer Retriever Mapped bearer type |
|
327 * @param aIapID IapID for which bearer type needs to be determined |
|
328 */ |
|
329 TInt TimerRetrieverMappedBearerTypeL(TUint32 aIapID) const; |
|
330 |
|
331 private: // Data |
|
332 |
|
333 //Determines where incoming requests are routed. Not owned. |
|
334 MSIPRequestRouter* iRouter; |
|
335 |
|
336 //Timer services. Not owned. |
|
337 MTimerManager* iTimers; |
|
338 |
|
339 //Connection state changes are reported to this callback |
|
340 MConnectionStateObserver& iStateObserver; |
|
341 |
|
342 //Dialog subsystem. Not owned. |
|
343 MSipDialogs* iDialogs; |
|
344 |
|
345 //Registration subsystem. Not owned. |
|
346 MSipRegistrations* iRegistrations; |
|
347 |
|
348 //Used for filling in information to Contact-headers of outgoing SIP |
|
349 //messages. Not owned. |
|
350 MSipRegistrationContact* iRegistrationContact; |
|
351 |
|
352 //Transport layer. Owned. |
|
353 CSipConnectionMgr* iConnectionMgr; |
|
354 |
|
355 //Contains information of all existing transactions and UAs. Owned. |
|
356 CTransactionStore* iTransactionStore; |
|
357 |
|
358 //Used for freeing memory asynchronously. Owned. |
|
359 CDeleteMgr* iDeleteMgr; |
|
360 |
|
361 |
|
362 //There is one instance of each UA state object. They're all owned. |
|
363 |
|
364 //Invite user agent client states |
|
365 CInviteUAC_Start* iInviteUAC_Start; |
|
366 CInviteUAC_ResolveAddress* iInviteUAC_ResolveAddress; |
|
367 CInviteUAC_WaitResponse* iInviteUAC_WaitResponse; |
|
368 CInviteUAC_WaitAckFromApp* iInviteUAC_WaitAckFromApp; |
|
369 CInviteUAC_ResolveAckAddress* iInviteUAC_ResolveAckAddress; |
|
370 CInviteUAC_SendingAck* iInviteUAC_SendingAck; |
|
371 CInviteUAC_WaitTransactionToEnd* iInviteUAC_WaitTransactionToEnd; |
|
372 CInviteUAC_WaitAuthentication* iInviteUAC_WaitAuthentication; |
|
373 |
|
374 //Non-Invite user agent client states |
|
375 CNormalUAC_Start* iNormalUAC_Start; |
|
376 CNormalUAC_ResolveAddress* iNormalUAC_ResolveAddress; |
|
377 CNormalUAC_WaitResponse* iNormalUAC_WaitResponse; |
|
378 CNormalUAC_WaitAuthentication* iNormalUAC_WaitAuthentication; |
|
379 |
|
380 //Cancel user agent client states |
|
381 CCancelUAC_Start* iCancelUAC_Start; |
|
382 CCancelUAC_ResolveAddress* iCancelUAC_ResolveAddress; |
|
383 CCancelUAC_WaitResponse* iCancelUAC_WaitResponse; |
|
384 CCancelUAC_WaitAuthentication* iCancelUAC_WaitAuthentication; |
|
385 |
|
386 //Invite user agent server states |
|
387 CInviteUAS_Start* iInviteUAS_Start; |
|
388 CInviteUAS_GetTxOwner* iInviteUAS_GetTxOwner; |
|
389 CInviteUAS_WaitRespFromApp* iInviteUAS_WaitRespFromApp; |
|
390 CInviteUAS_Accepted* iInviteUAS_Accepted; |
|
391 CInviteUAS_Rejected* iInviteUAS_Rejected; |
|
392 |
|
393 //Non-Invite user agent server states |
|
394 CNormalUAS_Start* iNormalUAS_Start; |
|
395 CNormalUAS_GetTxOwner* iNormalUAS_GetTxOwner; |
|
396 CNormalUAS_WaitRespFromApp* iNormalUAS_WaitRespFromApp; |
|
397 CNormalUAS_FinalRespSent* iNormalUAS_FinalRespSent; |
|
398 |
|
399 //Cancel user agent server states |
|
400 CCancelUAS_Start* iCancelUAS_Start; |
|
401 CCancelUAS_FinalRespSent* iCancelUAS_FinalRespSent; |
|
402 |
|
403 |
|
404 //Counter used to produce CSeq numbers for outgoing requests when the upper |
|
405 //layers have not filled the CSeq number. |
|
406 TUint32 iCSeqCounter; |
|
407 |
|
408 //Transaction layer. Owned. |
|
409 CTransactionMgr* iTransactionMgr; |
|
410 |
|
411 //Timer values, owned. |
|
412 CTimerValueRetriever* iTimerValueRetriever; |
|
413 |
|
414 //SIP message manipulating utilities. Owned. |
|
415 CSIPMessageUtility* iSIPMsgUtility; |
|
416 |
|
417 //SIP Security subsystem. Owned. |
|
418 CSIPSec* iSIPSec; |
|
419 |
|
420 private: // For testing purposes |
|
421 |
|
422 #ifdef CPPUNIT_TEST |
|
423 friend class CTransactionUser_Test; |
|
424 #endif |
|
425 |
|
426 void __DbgTestInvariant() const; |
|
427 |
|
428 }; |
|
429 |
|
430 #endif // end of CTRANSACTIONUSER_H |
|
431 |
|
432 // End of File |