|
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 "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 : CSIPRegistrationBindingStore.h |
|
16 * Part of : Registration |
|
17 * Version : SIP/4.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef CSIPREGISTRATIONBINDINGSTORE_H |
|
29 #define CSIPREGISTRATIONBINDINGSTORE_H |
|
30 |
|
31 #include <e32base.h> |
|
32 #include "SipStackServerDefs.h" |
|
33 #include "_sipcodecdefs.h" |
|
34 |
|
35 class CSIPRegistrarStore; |
|
36 class CSIPRegistrationBindingBase; |
|
37 class CSIPFromToHeaderBase; |
|
38 class CSIPRequest; |
|
39 class CSIPContactHeader; |
|
40 class CURIContainer; |
|
41 class CSIPRouteHeader; |
|
42 class CDeleteMgr; |
|
43 class MRegistrationOwner; |
|
44 |
|
45 |
|
46 class CSIPRegistrationBindingStore : public CBase |
|
47 { |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Create a instance of CSIPRegistrationBindingStore. |
|
52 * |
|
53 * @param aRegistrarStore; a refrence of CSIPRegistrarStore. |
|
54 * |
|
55 * @return a CSIPRegistrationBindingStore object. |
|
56 */ |
|
57 static CSIPRegistrationBindingStore* NewL(CSIPRegistrarStore& |
|
58 aRegistrarStore); |
|
59 |
|
60 /** |
|
61 * Create a instance of CSIPRegistrationBindingStore |
|
62 * and push it to CleanupStack. |
|
63 * |
|
64 * @param aRegistrarStore; a refrence of CSIPRegistrarStore. |
|
65 * |
|
66 * @return a CSIPRegistrationBindingStore object. |
|
67 */ |
|
68 static CSIPRegistrationBindingStore* NewLC(CSIPRegistrarStore& |
|
69 aRegistrarStore); |
|
70 |
|
71 ~CSIPRegistrationBindingStore(); |
|
72 |
|
73 /** |
|
74 * Find the binding by giving the MTransactionOwner and register request. |
|
75 * |
|
76 * @param aRegistrationOwner; a reference of MRegistrationOwner. |
|
77 * @param aSIPRequest; a request. |
|
78 * |
|
79 * @return CSIPRegistrationBindingBase object. |
|
80 * the ownership is not transferred. |
|
81 */ |
|
82 CSIPRegistrationBindingBase* FindBinding( |
|
83 const MRegistrationOwner& aRegistrationOwner, |
|
84 CSIPRequest& aSIPRequest); |
|
85 |
|
86 /** |
|
87 * Find the binding by ID and owner. |
|
88 * |
|
89 * @param aRegistrationId; a TRegistrationId. |
|
90 * @param aOwner the owner that must match to the original owner |
|
91 * used if not NULL. |
|
92 * @return CSIPRegistrationBindingBase object. |
|
93 * the ownership is not transferred. |
|
94 */ |
|
95 CSIPRegistrationBindingBase* FindBinding( |
|
96 const TRegistrationId& aRegistrationId, |
|
97 const MRegistrationOwner* aOwner=NULL); |
|
98 |
|
99 /** |
|
100 * Find a registration binding by transaction id. |
|
101 * @param aTransactionId transaction id. |
|
102 * @return CSIPRegistrationBindingBase instance or NULL if not found, |
|
103 * the ownership is not transferred. |
|
104 */ |
|
105 const CSIPRegistrationBindingBase* FindBindingForTransaction( |
|
106 const TTransactionId& aTransactionId); |
|
107 |
|
108 /** |
|
109 * Remove the binding by giving a CSIPRegistrationBaseClass. |
|
110 * |
|
111 * @param aBinding; a CSIPRegistrationBindingBase object. |
|
112 * |
|
113 * @return KErrNone if the binding was found and removed. |
|
114 * KErrNotFound otherwise |
|
115 */ |
|
116 TInt RemoveBinding(const CSIPRegistrationBindingBase* aBinding); |
|
117 |
|
118 /** |
|
119 * Remove the binding by giving a IAP id. |
|
120 * |
|
121 * @param aIapId. |
|
122 */ |
|
123 void RemoveBindingByIAPId(const TUint32 aIapId); |
|
124 |
|
125 /** |
|
126 * Remove the binding by giving a registraion id. |
|
127 * |
|
128 * @param aRegistrationId |
|
129 * @param aOwner the owner that must match to the original owner |
|
130 * @return KErrNone if the binding was found and removed. |
|
131 * KErrNotFound otherwise |
|
132 */ |
|
133 TInt RemoveBinding(const TRegistrationId& aRegistrationId, |
|
134 const MRegistrationOwner* aOwner); |
|
135 |
|
136 /** |
|
137 * when registration owner stored in binding is same as the |
|
138 * one passed as parameter. remove the binding if the binding |
|
139 * is not pending, otherwise assign RegistrationOwner contained in |
|
140 * binding to 0. |
|
141 * |
|
142 * @param aRegistrationOwner; a refernce of MRegistrationOwner. |
|
143 * |
|
144 * @return KErrNone when RegistrationOwner is found, |
|
145 * KErrNotFound otherwise. |
|
146 */ |
|
147 TInt ClearRegistrationOwner(const MRegistrationOwner* aRegistrationOwner); |
|
148 |
|
149 /** |
|
150 * Fills the hostport in the Contact-header. |
|
151 * If the user part is not filled in the Contact-header, |
|
152 * fills it with a copy from a registration binding found |
|
153 * |
|
154 * @param aFromToHeader; a CSIPFromToHeaderBase object. |
|
155 * @param aContact; a reference of CSIPContactHeader. |
|
156 * |
|
157 * @return ETrue, if binding was found, EFalse otherwise. |
|
158 */ |
|
159 TBool FindContactByFromL(const CSIPFromToHeaderBase* aFromToHeader, |
|
160 CSIPContactHeader& aContact); |
|
161 |
|
162 /** |
|
163 * Get registrar store. |
|
164 * |
|
165 * @return CSIPRegistrarStore; a refrence of CSIPRegistrarStore. |
|
166 */ |
|
167 CSIPRegistrarStore& RegistrarStore(); |
|
168 |
|
169 /** |
|
170 * Get next TRegistrationId. |
|
171 * |
|
172 * @return TRegistrationId. |
|
173 */ |
|
174 TRegistrationId NextRegistrationId (); |
|
175 |
|
176 /** |
|
177 * Checks if the RequestURI passed as a parameter |
|
178 * equals to the Uri in one of contact headers in the bindings. |
|
179 * |
|
180 * @param aRequestUri; a refrence of CURIContainer |
|
181 * |
|
182 * @return ETrue if the parameter equals the uri in contact of binding. |
|
183 * EFalse if none of uri in contact of binding equals the |
|
184 * parameter uri. |
|
185 */ |
|
186 TBool CheckRequestURI(CURIContainer& aRequestUri); |
|
187 |
|
188 /** |
|
189 * Function sets an outbound proxy for a registration binding. |
|
190 * Leaves if the binding was not found. |
|
191 * |
|
192 * @pre aOutboundProxy != 0 |
|
193 * @param aRegistrationId; the id of the registration binding |
|
194 * for which the outbound proxy should be set. |
|
195 * @param aOutboundProxy; an outbound proxy to be used with the |
|
196 * binding to be created. The ownership is transferred. |
|
197 * @param aOwner the owner that must match to the original owner |
|
198 */ |
|
199 void SetOutboundProxyL(const TRegistrationId& aRegistrationId, |
|
200 CSIPRouteHeader* aOutboundProxy, |
|
201 const MRegistrationOwner* aOwner); |
|
202 |
|
203 /** |
|
204 * Get OutboundProxy from the binding found by passing TRegistrationId. |
|
205 * |
|
206 * @pre HasOutboundProxy(aRegistrationId) == ETrue |
|
207 * @param aRegistrationId; TRegistrationId |
|
208 * @return outbound proxy or NULL if not found, |
|
209 * the ownership is not transferred |
|
210 */ |
|
211 const CSIPRouteHeader* OutboundProxy(TRegistrationId aRegistrationId); |
|
212 |
|
213 /** |
|
214 * check if OutboundProxy exists from the binding by passing |
|
215 * TRegistrationId. |
|
216 * |
|
217 * @param aRegistrationId; TRegistrationId |
|
218 * @return ETrue if out bound proxy exits for the binding found by |
|
219 * TRegistrationId, EFalse otherwise. |
|
220 */ |
|
221 TBool HasOutboundProxy(TRegistrationId aRegistrationId); |
|
222 |
|
223 /** |
|
224 * Function checks if the given SIP-URI |
|
225 * is a URI of ANY outbound proxy stored in Registrations. |
|
226 * |
|
227 * @param aUri the URI to check |
|
228 * @return ETrue if the URI is a URI of an outbound proxy, |
|
229 * otherwise EFalse. |
|
230 */ |
|
231 TBool IsOutboundProxy(const CURIContainer& aUri); |
|
232 |
|
233 /** |
|
234 * Remove the OutboundProxy from the binding if it can be found by |
|
235 * using the registrationid passed as parameter. |
|
236 * |
|
237 * @param aRegistrationId; TRegistrationId |
|
238 * @param aOwner the owner that must match to the original owner |
|
239 * @return KErrNone if the binding can be found and removed. |
|
240 */ |
|
241 TInt RemoveOutboundProxy(const TRegistrationId& aRegistrationId, |
|
242 const MRegistrationOwner* aOwner); |
|
243 |
|
244 /** |
|
245 * Resolving or sending a SIP request to a URI has failed. |
|
246 * If this is an outbound proxy URI of an existing registration binding, |
|
247 * removes the corresponding binding immediately. |
|
248 * |
|
249 * @param aUri the failed URI before resolving |
|
250 */ |
|
251 void URIFailed(CURIContainer& aUri); |
|
252 |
|
253 /** |
|
254 * find pending registrtions to the same AOR given as parameter. |
|
255 */ |
|
256 TBool RegisterPendingToAOR (const CURIContainer& aAOR); |
|
257 |
|
258 void AddBindingL(CSIPRegistrationBindingBase* aBinding); |
|
259 |
|
260 void DetachBinding(CSIPRegistrationBindingBase* aBinding); |
|
261 |
|
262 private: |
|
263 |
|
264 CSIPRegistrationBindingStore(CSIPRegistrarStore& aRegistrarStore); |
|
265 void ConstructL(); |
|
266 |
|
267 /** |
|
268 * Compares the two URIs |
|
269 * It checks the host part and port part of the URI |
|
270 * If the port is default port, the check is ignored |
|
271 * |
|
272 * @param aProxy the outboundproxy in the reg binding |
|
273 * @param aUri the failed URI before resolving |
|
274 */ |
|
275 TBool CompareUri(const CURIContainer& aProxy, CURIContainer& aUri); |
|
276 |
|
277 |
|
278 private: // Data |
|
279 |
|
280 // bindings array |
|
281 RPointerArray<CSIPRegistrationBindingBase> iBindings; |
|
282 |
|
283 // a refrence to store of registrars array |
|
284 CSIPRegistrarStore& iRegistrarStore; |
|
285 |
|
286 // new registrationId given to new binding |
|
287 TRegistrationId iNextRegistrationId; |
|
288 |
|
289 CDeleteMgr* iDeleteMgr; |
|
290 |
|
291 private: // For testing purposes |
|
292 |
|
293 UNIT_TEST(CSIPRegistrationMgrTest) |
|
294 UNIT_TEST(CSIPRegistrationBindingStoreTest) |
|
295 UNIT_TEST(CSIPRegistrationUtilityTest) |
|
296 }; |
|
297 |
|
298 #endif // CSIPREGISTRATIONBINDINGSTORE_H |
|
299 |
|
300 // End of File |