|
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 : CSIPRegistrationMgr.h |
|
16 * Part of : Registration |
|
17 * Version : SIP/5.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef CSIPREGISTRATIONMGR_H |
|
29 #define CSIPREGISTRATIONMGR_H |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <in_sock.h> |
|
33 #include "MSipRegistrations.h" |
|
34 #include "MSipRegistrationContact.h" |
|
35 #include "MConnectionStateObserver.h" |
|
36 #include "SipStackServerDefs.h" |
|
37 #include "_sipcodecdefs.h" |
|
38 |
|
39 class CSIPRegistrationBindingStore; |
|
40 class CSIPRegistrarStore; |
|
41 class CSIPRouteHeader; |
|
42 class CSIPFromHeader; |
|
43 class CSIPRequest; |
|
44 class CSIPContactHeader; |
|
45 class CURIContainer; |
|
46 class CSIPURI; |
|
47 class MTransactionUser; |
|
48 class MSipRefreshMgr; |
|
49 class MTimerManager; |
|
50 class CSIPSec; |
|
51 class MSIPSecUser; |
|
52 class MSigComp; |
|
53 class MSIPTransportMgr; |
|
54 class MRegistrationOwner; |
|
55 class TSIPTransportParams; |
|
56 class MTransactionOwner; |
|
57 |
|
58 |
|
59 /** |
|
60 * This class implements interface functions of Sip Registration subsystem. |
|
61 */ |
|
62 class CSIPRegistrationMgr : public CBase, |
|
63 public MSipRegistrations, |
|
64 public MSipRegistrationContact, |
|
65 public MConnectionStateObserver |
|
66 { |
|
67 public: // Constructors and destructor |
|
68 |
|
69 static CSIPRegistrationMgr* NewL(MTransactionUser& aTU, |
|
70 MSipRefreshMgr& aRefreshMgr, |
|
71 MTimerManager& aTimerManager, |
|
72 CSIPSec& aSIPSec, |
|
73 MSigComp& aSigComp, |
|
74 MSIPTransportMgr& aTransportMgr); |
|
75 |
|
76 ~CSIPRegistrationMgr(); |
|
77 |
|
78 |
|
79 public: // From MSipRegistrations |
|
80 |
|
81 TBool CheckRequestURI(CURIContainer& aRequestUri); |
|
82 |
|
83 const CSIPRouteHeader* OutboundProxy(TRegistrationId aRegistrationId); |
|
84 |
|
85 TBool HasOutboundProxy(TRegistrationId aRegistrationId) const; |
|
86 |
|
87 TBool IsOutboundProxy(const CURIContainer& aUri); |
|
88 |
|
89 void URIFailed(CURIContainer& aUri); |
|
90 |
|
91 TBool IsCacheOutboundProxyIPEanbled( |
|
92 TRegistrationId aRegistrationId) const; |
|
93 |
|
94 CSIPRouteHeader& OutboundProxyIPL( |
|
95 TRegistrationId aRegistrationId) const; |
|
96 |
|
97 public: // From MSipRegistrationContact |
|
98 |
|
99 void ContactL(TUint32 aIapId, |
|
100 TRegistrationId aRegistrationId, |
|
101 const CSIPFromToHeaderBase* aFromToHeader, |
|
102 CSIPContactHeader& aContact); |
|
103 |
|
104 |
|
105 public: // From MConnectionStateObserver |
|
106 |
|
107 void ConnectionStateChangedL (TUint32 aIapId, |
|
108 CSIPConnection::TState aState); |
|
109 |
|
110 |
|
111 public: // New functions |
|
112 |
|
113 /** |
|
114 * Function sends a Register request to registration subsystem. |
|
115 * |
|
116 * @pre aRequest!=0 |
|
117 * @pre aRegistrationOwner!=0 |
|
118 * |
|
119 * @param aTransactionId; On return contains the id |
|
120 * of the created transaction. |
|
121 * @param aRegistrationId; On return contains the id |
|
122 * of the created registration binding object. |
|
123 * @param aRequest; a sip request. the ownership is transferred. |
|
124 * @param aRemoteTarget; a remote target to be copied to the |
|
125 * registrar if it the registrar does not already exist. |
|
126 * The ownership is NOT transferred. |
|
127 * @param aOwner; the ownership is NOT transferred. |
|
128 * @param aSIPSecUser a user for SIPSec |
|
129 * @param aOutboundProxy; an outbound proxy to be used with the |
|
130 * binding to be created. The ownership is transferred. |
|
131 * If 0 no outbound proxy will be used. |
|
132 * @param aSendWithExpires when set to EFalse REGISTER message is sent |
|
133 * without expires value |
|
134 * @param aCacheOutboundProxyIP when set to ETrue outbiund proxy IP |
|
135 * of REGISTER message is cached in registration context |
|
136 * @param aRefresh; If ETrue, the request will be refreshed. |
|
137 */ |
|
138 void RegisterL(TTransactionId& aTransactionId, |
|
139 TRegistrationId& aRegistrationId, |
|
140 CSIPRequest* aRequest, |
|
141 CURIContainer& aRemoteTarget, |
|
142 MRegistrationOwner* aOwner, |
|
143 MSIPSecUser& aSIPSecUser, |
|
144 CSIPRouteHeader* aOutboundProxy=0, |
|
145 TBool aRefresh=EFalse, |
|
146 TBool aSendWithExpires=ETrue, |
|
147 TBool aCacheOutboundProxyIP=EFalse); |
|
148 |
|
149 /** |
|
150 * Function sends an update request. |
|
151 * Registration fills To, From, Call-ID and CSeq. |
|
152 * Also Contact will be filled if not present. |
|
153 * If a different CSIPAddress is provided in Contact, leaves |
|
154 * with KErrArgument. Leaves with KErrSIPInvalidRegistrationState |
|
155 * if no registration binding was found. |
|
156 * |
|
157 * @pre aRequest!=0 |
|
158 * @param aRegistrationId; the id of the registration binding to be |
|
159 * updated. |
|
160 * @param aTransactionId; an empty transaction id that will |
|
161 * be filled by TU. |
|
162 * @param aRequest; a sip request. The ownership is transferred. |
|
163 * @param aOwner the owner that must match to the original owner |
|
164 */ |
|
165 void UpdateRegistrationL(const TRegistrationId& aRegistrationId, |
|
166 TTransactionId& aTransactionId, |
|
167 CSIPRequest* aRequest, |
|
168 const MRegistrationOwner* aOwner); |
|
169 |
|
170 /** |
|
171 * Function sends an unregister request. |
|
172 * Registration fills To, From, Contact, Call-ID, CSeq. |
|
173 * Contact-header's expire-parameter is updated to 0 by |
|
174 * registration before added to the request. |
|
175 * Leaves with CSIPClient::ENonExistingRegistrationId if |
|
176 * no registration binding was found. |
|
177 * |
|
178 * @pre aRequest!=0 |
|
179 * @param aRegistrationId; the id of the registration binding to be |
|
180 * removed by unregistering. |
|
181 * @param aTransactionId; an empty transaction id that will be |
|
182 * filled by TU. |
|
183 * @param aRequest; a sip request. The ownership is transferred. |
|
184 * No Contact is allowed to be present. Panics if there is. |
|
185 * @param aOwner the owner that must match to the original owner |
|
186 */ |
|
187 void UnRegisterL(const TRegistrationId& aRegistrationId, |
|
188 TTransactionId& aTransactionId, |
|
189 CSIPRequest* aRequest, |
|
190 const MRegistrationOwner* aOwner); |
|
191 |
|
192 /** |
|
193 * Function sets an outbound proxy for a registration binding. |
|
194 * Leaves if the binding was not found. |
|
195 * |
|
196 * @pre aOutboundProxy != 0 |
|
197 * @param aRegistrationId; the id of the registration binding |
|
198 * for which the outbound proxy should be set. |
|
199 * @param aOutboundProxy; an outbound proxy to be used with the |
|
200 * binding to be created. The ownership is transferred. |
|
201 * @param aOwner the owner that must match to the original owner |
|
202 */ |
|
203 void SetOutboundProxyL(const TRegistrationId& aRegistrationId, |
|
204 CSIPRouteHeader* aOutboundProxy, |
|
205 const MRegistrationOwner* aOwner); |
|
206 |
|
207 /** |
|
208 * Function removes an outbound proxy for a specified registration |
|
209 * binding. |
|
210 * |
|
211 * @param aRegistrationId; the id of the registration binding |
|
212 * from where the outbound proxy should be removed. |
|
213 * |
|
214 * @param aOwner the owner that must match to the original owner |
|
215 * |
|
216 * @return KErrNotFound if the binding |
|
217 * with a given id was not found, otherwise KErrNone. |
|
218 */ |
|
219 TInt RemoveOutboundProxy(const TRegistrationId& aRegistrationId, |
|
220 const MRegistrationOwner* aOwner); |
|
221 |
|
222 /** |
|
223 * Fetch all the registrations. Leaves on failure. |
|
224 * |
|
225 * @pre aRequest!=0 |
|
226 * @pre !aRequest.HasHeader(KContactHeaderFullName) |
|
227 * @pre aRemoteTarget!=0 |
|
228 * @pre aTransactionOwner!=0 |
|
229 * |
|
230 * @param aTransportParams transport parameters to be used by TU |
|
231 * @param aTransactionId; an empty transaction id that is filled by TU. |
|
232 * @param aRequest; a sip request. the ownership is transferred. |
|
233 * @param aRemoteTarget; The remote target to be used. |
|
234 * @param aTransactionOwner; To be passed as such to TU. |
|
235 * The ownership is NOT transferred. |
|
236 * |
|
237 */ |
|
238 void FetchRegistrationsL(const TSIPTransportParams& aTransportParams, |
|
239 TTransactionId& aTransactionId, |
|
240 CSIPRequest* aRequest, |
|
241 CURIContainer& aRemoteTarget, |
|
242 MTransactionOwner* aTransactionOwner); |
|
243 |
|
244 |
|
245 /** |
|
246 * Copies the POINTERS of the Route-set objects for |
|
247 * the given registration-id to the givena array. |
|
248 * If a Route-set was not found, the function silently returns |
|
249 * without filling anything. |
|
250 * |
|
251 * @param aRegistrationId; the id of the registration |
|
252 * for which the Route-set should be filled. |
|
253 * @param aRouteSet. IN: empty array, OUT: array filled with pointers |
|
254 * to the stored Route-headers. |
|
255 * @param aAddOutboundProxy |
|
256 * If ETrue, add pointer to the outbound proxy as the FIRST entry. |
|
257 * If ETrue and there is no Service-Route but an outbound proxy, |
|
258 * do NOT add anything. |
|
259 * If EFalse ignore outbound proxy, but add Service-Route if any. |
|
260 * |
|
261 */ |
|
262 void GetRouteL(const TRegistrationId& aRegistrationId, |
|
263 RPointerArray<CSIPRouteHeader>& aRouteSet, |
|
264 TBool aAddOutboundProxy=EFalse); |
|
265 |
|
266 /** |
|
267 * Creates a from header by giving registration Id. |
|
268 * |
|
269 * @param aRegistrationId; a registrationId of existing registration, |
|
270 * |
|
271 * @returns a new From-header instance. The ownership is transferred. |
|
272 */ |
|
273 CSIPFromHeader* CreateFromLC(const TRegistrationId& aRegistrationId); |
|
274 |
|
275 /** |
|
276 * Delete all the registration bindings related to the registration |
|
277 * owner passed as parameter. Does NOT delete the registration owner. |
|
278 * |
|
279 * @param aOwner; a owner |
|
280 * |
|
281 * @return KErrNone if the owner was found and all related bindings |
|
282 * were detached. |
|
283 */ |
|
284 TInt ClearRegistrationOwner(const MRegistrationOwner* aOwner); |
|
285 |
|
286 /* Terminates a registration with a given registration id abnormally. |
|
287 * Deletes the binding immediately. |
|
288 * |
|
289 * @param aRegistrationId; a registration Id of an existing registration. |
|
290 * |
|
291 * @param aOwner the owner that must match to the original owner |
|
292 * |
|
293 * @returns KErrNotFound if no registration |
|
294 * with the given id was found, otherwise KErrNone. |
|
295 */ |
|
296 TInt TerminateRegistration (const TRegistrationId& aRegistrationId, |
|
297 const MRegistrationOwner* aOwner); |
|
298 |
|
299 /** |
|
300 * Gets a pointer to the contact header related |
|
301 * to the registration binding having the given ID |
|
302 * |
|
303 * @param aRegistrationId a ID of a registration binding |
|
304 * |
|
305 * @returns a pointer to a Contact-header if the binding was found. |
|
306 * NULL if the binding was not found |
|
307 * The ownership is not transferred. |
|
308 */ |
|
309 const CSIPContactHeader* Contact(const TRegistrationId& aRegistrationId); |
|
310 |
|
311 /** |
|
312 * Gets the transport parameters used for a registration binding. |
|
313 * |
|
314 * @param aRegistrationId a ID of a registration binding |
|
315 * @param aTransportParams on return contains the |
|
316 * transport parameters if found |
|
317 * |
|
318 * @returns ETrue if the registration binding was found and |
|
319 * the transport parameters were filled, otherwise EFalse. |
|
320 */ |
|
321 TBool FillTransportParams( |
|
322 const TRegistrationId& aRegistrationId, |
|
323 TSIPTransportParams& aTransportParams); |
|
324 |
|
325 /** |
|
326 * Gets the MSIPSecUser related to the given registration id. |
|
327 * |
|
328 * @param aRegistrationId the registration id |
|
329 * |
|
330 * @returns the user related to the given registration id if found, |
|
331 * otherwise NULL. |
|
332 */ |
|
333 const MSIPSecUser* SIPSecUser(const TRegistrationId& aRegistrationId); |
|
334 |
|
335 /** |
|
336 * Gets a MSIPSecUser related to a transaction. |
|
337 * |
|
338 * @param aTransactionId the transaction id |
|
339 * |
|
340 * @return MSIPSecUser related to the given transaction id, if found, |
|
341 * otherwise NULL. |
|
342 */ |
|
343 const MSIPSecUser* SIPSecUserForTransaction( |
|
344 const TTransactionId& aTransactionId); |
|
345 |
|
346 |
|
347 private: // New functions |
|
348 |
|
349 CSIPRegistrationMgr(MTransactionUser& aTU, |
|
350 MSipRefreshMgr& aRefreshMgr, |
|
351 MTimerManager& aTimerManager, |
|
352 CSIPSec& aSIPSec, |
|
353 MSigComp& aSigComp, |
|
354 MSIPTransportMgr& aTransportMgr); |
|
355 |
|
356 void ConstructL(); |
|
357 |
|
358 void FillHostWithLocalIPL (TUint32 aIapId, CSIPURI& aSipUri); |
|
359 |
|
360 static void DetachBinding(TAny* aBinding); |
|
361 |
|
362 |
|
363 private: // Data |
|
364 |
|
365 MTransactionUser& iTU; |
|
366 MSipRefreshMgr& iRefreshMgr; |
|
367 MTimerManager& iTimerMgr; |
|
368 CSIPSec& iSIPSec; |
|
369 MSigComp& iSigComp; |
|
370 MSIPTransportMgr& iTransportMgr; |
|
371 CSIPRegistrationBindingStore* iBindingStore; |
|
372 CSIPRegistrarStore* iRegistrarStore; |
|
373 |
|
374 private: // For testing purposes |
|
375 |
|
376 UNIT_TEST(CSIPRegistrationMgrTest) |
|
377 }; |
|
378 |
|
379 #endif // CSIPREGISTRATIONMGR_H |
|
380 |
|
381 // End of File |