|
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 : sipregistrationbinding.h |
|
16 * Part of : SIP Client |
|
17 * Interface : SDK API, SIP Client API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSIPREGISTRATIONBINDING_H |
|
25 #define CSIPREGISTRATIONBINDING_H |
|
26 |
|
27 // INCLUDES |
|
28 #include "sipregistrationcontext.h" |
|
29 |
|
30 //CONSTANTS |
|
31 |
|
32 /** Property to modify the registration behaviour of the SIP stack. |
|
33 * Property value is of type boolean. When the value is set to false, |
|
34 * registration will be attempted without expires value. |
|
35 * Default value for this property is true. |
|
36 */ |
|
37 const TUint32 KSIPSendWithExpires = 200; |
|
38 |
|
39 /** Property to modify the registration behaviour of the SIP stack. |
|
40 * Property value is of type boolean. When the value is set to true, |
|
41 * resolved outbound proxy ip of the registration will be used for all |
|
42 * transactions which uses this registration context(id). The resolved ip is |
|
43 * updated on every successful registration in that context. |
|
44 * Default value for this property is false. |
|
45 */ |
|
46 const TUint32 KSIPCacheOutboundProxyIP = 201; |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 class CUri8; |
|
50 class CSIPToHeader; |
|
51 class CSIPFromHeader; |
|
52 class CSIPContactHeader; |
|
53 class CSIPRouteHeader; |
|
54 class CSIPMessageElements; |
|
55 class CSIPConnection; |
|
56 class CSIPRefresh; |
|
57 class CSIPClientTransaction; |
|
58 class CRegBindingImplementation; |
|
59 |
|
60 // CLASS DECLARATION |
|
61 |
|
62 /** |
|
63 * @publishedAll |
|
64 * @released |
|
65 * |
|
66 * Class for managing SIP registration binding. |
|
67 * Class provides functions for creating and updating SIP registration bindings. |
|
68 * |
|
69 * @lib sipclient.lib |
|
70 */ |
|
71 class CSIPRegistrationBinding : |
|
72 public CBase, |
|
73 public MSIPRegistrationContext |
|
74 { |
|
75 public: // Constructors and destructor |
|
76 |
|
77 /** |
|
78 * Two-phased constructor. |
|
79 * @pre aAor != 0 && |
|
80 * aContact != 0 |
|
81 * @pre "Expires" parameter in aContact must be >= KSIPMinExpirationValue |
|
82 * @param aConnection a SIP connection to be used |
|
83 * @param aAor contains user's address-of-record to register; |
|
84 * the ownership is transfered |
|
85 * @param aContact contact(s) to be registered. The "expires" parameter |
|
86 * indicates how long the client would like the binding to be |
|
87 * valid. |
|
88 * "expires" parameter value must be >= KSIPMinExpirationValue; |
|
89 * the ownership is transfered |
|
90 * @param aRefresh if set, created binding will be refreshed; |
|
91 * the ownership is transfered |
|
92 * @param aOutboundProxy an outbound proxy address; |
|
93 * the ownership is transfered |
|
94 * @param aRemoteUri if set, will be used in request-uri construction; |
|
95 * the ownership is transfered |
|
96 * @param aFrom From header, the ownership is transferred |
|
97 * @return New object, ownership is transferred. |
|
98 * @leave KErrArgument if aAor == 0, aContact == 0 or if "Expires" |
|
99 * parameter in aContact is less than KSIPMinExpirationValue |
|
100 */ |
|
101 IMPORT_C static CSIPRegistrationBinding* |
|
102 NewL(CSIPConnection& aConnection, |
|
103 CSIPToHeader* aAor, |
|
104 CSIPContactHeader* aContact, |
|
105 CSIPRefresh* aRefresh=0, |
|
106 CSIPRouteHeader* aOutboundProxy=0, |
|
107 CUri8* aRemoteUri=0, |
|
108 CSIPFromHeader* aFrom=0); |
|
109 |
|
110 /** |
|
111 * Two-phased constructor. |
|
112 * @pre aAor != 0 && |
|
113 * aContact != 0 |
|
114 * @pre "Expires" parameter in aContact must be >= KSIPMinExpirationValue |
|
115 * @param aConnection a SIP connection to be used |
|
116 * @param aAor contains user's address-of-record to register; |
|
117 * the ownership is transfered |
|
118 * @param aContact contact to be registered; The "expires" parameter |
|
119 * indicates how long the client would like the binding to be |
|
120 * valid. |
|
121 * "expires" parameter value must be >= KSIPMinExpirationValue; |
|
122 * the ownership is transfered |
|
123 * @param aRefresh if set, created binding will be refreshed; |
|
124 * the ownership is transfered |
|
125 * @param aOutboundProxy an outbound proxy address; |
|
126 * the ownership is transfered |
|
127 * @param aRemoteUri if set, will be used in request-uri construction; |
|
128 * the ownership is transfered |
|
129 * @param aFrom From header, the ownership is transferred |
|
130 * @return New object, ownership is transferred. |
|
131 * @leave KErrArgument if aAor == 0, aContact == 0 or if "Expires" |
|
132 * parameter in aContact is less than KSIPMinExpirationValue |
|
133 */ |
|
134 IMPORT_C static CSIPRegistrationBinding* |
|
135 NewLC(CSIPConnection& aConnection, |
|
136 CSIPToHeader* aAor, |
|
137 CSIPContactHeader* aContact, |
|
138 CSIPRefresh* aRefresh=0, |
|
139 CSIPRouteHeader* aOutboundProxy=0, |
|
140 CUri8* aRemoteUri=0, |
|
141 CSIPFromHeader* aFrom=0); |
|
142 |
|
143 /** |
|
144 * Destructor |
|
145 */ |
|
146 IMPORT_C ~CSIPRegistrationBinding(); |
|
147 |
|
148 public: //From MSIPRegistrationContext: |
|
149 |
|
150 /** |
|
151 * Checks if the registration context can be |
|
152 * used for creating SIP messages/dialogs |
|
153 * @return ETrue if the registration binding exists; EFalse |
|
154 * otherwise |
|
155 */ |
|
156 IMPORT_C TBool IsContextActive() const; |
|
157 |
|
158 /** |
|
159 * Gets the context id |
|
160 * @return context id |
|
161 * For internal use only |
|
162 */ |
|
163 IMPORT_C TUint32 ContextId() const; |
|
164 |
|
165 public: // New functions |
|
166 /** |
|
167 * Creates SIP REGISTER request, sends it to the given destination. |
|
168 * Received 2xx response will create at least one registration |
|
169 * binding. |
|
170 * @pre Connection().State()==EActive |
|
171 * @param aElements contains user SIP headers and content; the ownership |
|
172 * is taken |
|
173 * @return SIP REGISTER transaction; the ownership is transfered |
|
174 * @leave KErrSIPMalformedMessage if aElements contains contact or |
|
175 * expires headers |
|
176 * @leave KErrSIPInvalidRegistrationState if already registered or |
|
177 * registering is in progress or deregistering is in progress. |
|
178 * @capability NetworkServices |
|
179 */ |
|
180 IMPORT_C CSIPClientTransaction* |
|
181 RegisterL(CSIPMessageElements* aElements=0); |
|
182 |
|
183 /** |
|
184 * Creates SIP (de)REGISTER request, sends it to the given destination. |
|
185 * This function will remove registration binding. |
|
186 * Any SIP response (2xx - 6xx) to this request removes the binding. |
|
187 * Note that deregistration can be done then the 2xx is received to the |
|
188 * initial REGISTER transaction and there is no on-going registration |
|
189 * updates. |
|
190 * @pre Connection().State()==EActive |
|
191 * @pre IsContextActive()==ETrue |
|
192 * @param aElements contains user SIP headers and content; the ownership |
|
193 * is transfered. If set, user SIP headers must not contain any |
|
194 * Contact-header nor Expires-header |
|
195 * @return SIP REGISTER transaction; the ownership is transfered |
|
196 * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse |
|
197 * @capability NetworkServices |
|
198 */ |
|
199 IMPORT_C CSIPClientTransaction* |
|
200 DeregisterL(CSIPMessageElements* aElements=0); |
|
201 |
|
202 /** |
|
203 * Updates the registration binding. Note that update can be done |
|
204 * then the 2xx is received to the REGISTER transaction that relates |
|
205 * to the initial registration or to update. |
|
206 * @pre aElements!=0 |
|
207 * @pre Connection().State()==EActive |
|
208 * @pre IsContextActive()==ETrue |
|
209 * @param aElements contains user SIP header and content, must not |
|
210 * contain any Contact-header nor Expires-header; |
|
211 * the ownership is transferred. |
|
212 * @return SIP REGISTER transaction; the ownership is transfered |
|
213 * @leave KErrArgument if aElements == NULL |
|
214 * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse |
|
215 * @capability NetworkServices |
|
216 */ |
|
217 IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements); |
|
218 |
|
219 /** |
|
220 * Updates the regisration binding. Note that update can be done |
|
221 * then the 2xx is received to the REGISTER transaction that relates |
|
222 * to the initial registration or to update. |
|
223 * @pre aExpirationValue >= KSIPMinExpirationValue |
|
224 * @pre Connection().State()==EActive |
|
225 * @pre IsContextActive()==ETrue |
|
226 * @param aExpirationValue a new expiration value in seconds |
|
227 * @param aElements contains user SIP headers and content; must not |
|
228 * contain any Contact-header nor Expires-header; |
|
229 * the ownership is transferred. |
|
230 * @return SIP REGISTER transaction; the ownership is transfered |
|
231 * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse |
|
232 * @capability NetworkServices |
|
233 */ |
|
234 IMPORT_C CSIPClientTransaction* |
|
235 UpdateL(TUint aExpirationValue, CSIPMessageElements* aElements=0); |
|
236 |
|
237 /** |
|
238 * Gets the SIP connection used for the registration. |
|
239 * @return SIP connection used for the registration, or 0-pointer if the |
|
240 * connection has been deleted. Ownership is not transferred. |
|
241 */ |
|
242 IMPORT_C CSIPConnection* Connection(); |
|
243 |
|
244 /** |
|
245 * Gets the SIP connection used for the registration. |
|
246 * @return SIP connection used for the registration, or 0-pointer if the |
|
247 * connection has been deleted. Ownership is not transferred. |
|
248 */ |
|
249 IMPORT_C const CSIPConnection* Connection() const; |
|
250 |
|
251 /** |
|
252 * Sets/resets outbound proxy. |
|
253 * If a 0-pointer is given the outbound proxy will be reset. |
|
254 * @param aOutboundProxy an outbound proxy. Ownership is transferred. |
|
255 * @leave KErrSIPResourceNotAvailable if a required SIP Client API |
|
256 * object has been deleted |
|
257 */ |
|
258 IMPORT_C void SetOutboundProxyL(CSIPRouteHeader* aOutboundProxy); |
|
259 |
|
260 /** |
|
261 * Gets the address-of-record (AOR) used for creating binding |
|
262 * @return address-of-record (AOR) |
|
263 */ |
|
264 IMPORT_C const CSIPToHeader& Aor() const; |
|
265 |
|
266 /** |
|
267 * Gets Contact header associated with the registration binding |
|
268 * @return Contact header |
|
269 */ |
|
270 IMPORT_C const CSIPContactHeader& ContactHeader() const; |
|
271 |
|
272 /** |
|
273 * Gets Contact header associated with the registration binding |
|
274 * @return Contact header |
|
275 */ |
|
276 IMPORT_C CSIPContactHeader& ContactHeader(); |
|
277 |
|
278 /** |
|
279 * Gets used outbound proxy |
|
280 * @return outbound proxy or a 0-pointer if not set. Ownership is not |
|
281 * transferred. |
|
282 */ |
|
283 IMPORT_C const CSIPRouteHeader* OutboundProxy() const; |
|
284 |
|
285 /** |
|
286 * Gets associated refresh in case the user has requested the refresh of |
|
287 * the registration. Note that client cannot use update or terminate |
|
288 * functions defined in the CSIPRefresh class. |
|
289 * @return Associated refresh or a 0-pointer if the user has not |
|
290 * requested a refresh of registration binding. Ownership is not |
|
291 * transferred. |
|
292 */ |
|
293 IMPORT_C const CSIPRefresh* SIPRefresh() const; |
|
294 |
|
295 /** |
|
296 * Gets associated refresh in case the user has requested the refresh of |
|
297 * the registration. Note that client cannot use update or terminate |
|
298 * functions defined in the CSIPRefresh class. |
|
299 * @return Associated refresh or a 0-pointer if the user has not |
|
300 * requested a refresh of registration binding. Ownership is not |
|
301 * transferred. |
|
302 */ |
|
303 IMPORT_C CSIPRefresh* SIPRefresh(); |
|
304 |
|
305 /** |
|
306 * Compares this object to another object |
|
307 * @param aRegistration CSIPRegistrationBinding object to compare |
|
308 * @return ETrue if the objects are equal, otherwise EFalse |
|
309 */ |
|
310 IMPORT_C TBool |
|
311 operator==(const CSIPRegistrationBinding& aRegistration) const; |
|
312 |
|
313 /** |
|
314 * Gets the registered Contact-header received in the 200 OK response. |
|
315 * @return Contact header, or NULL if IsContextActive() is EFalse. |
|
316 * Ownership is not transferred. |
|
317 */ |
|
318 IMPORT_C const CSIPContactHeader* RegisteredContact() const; |
|
319 |
|
320 /** |
|
321 * Sets/resets properties. |
|
322 * @param aProperty. Property name |
|
323 * @param aValue. Property value |
|
324 * @return KErrSIPInvalidRegistrationState if IsContextActive() is ETrue |
|
325 * @return KErrNotFound if property is not found, KErrNone otherwise |
|
326 */ |
|
327 IMPORT_C TInt SetProperty(TUint32 aProperty,TBool aValue); |
|
328 |
|
329 public: // New functions, for internal use |
|
330 /** |
|
331 * Returns the implementation instance. |
|
332 * |
|
333 * @return CRegBindingImplementation |
|
334 */ |
|
335 CRegBindingImplementation& Implementation(); |
|
336 |
|
337 private: // Constructors |
|
338 CSIPRegistrationBinding(); |
|
339 |
|
340 void ConstructL(CSIPConnection& aConnection, |
|
341 CSIPToHeader* aAor, |
|
342 CSIPContactHeader* aContacts, |
|
343 CSIPRefresh* aRefresh, |
|
344 CSIPRouteHeader* aOutboundProxy, |
|
345 CUri8* aRemoteUri, |
|
346 CSIPFromHeader* aFrom); |
|
347 |
|
348 private: // Data |
|
349 CRegBindingImplementation* iImplementation; |
|
350 |
|
351 private: // For testing purposes |
|
352 #ifdef CPPUNIT_TEST |
|
353 friend class CSIP_Test; |
|
354 friend class CSIPRegistrationBinding_Test; |
|
355 friend class CSIPInviteDialogAssoc_Test; |
|
356 friend class CSIPSubscribeDialogAssoc_Test; |
|
357 friend class CSIPReferDialogAssoc_Test; |
|
358 #endif |
|
359 void __DbgTestInvariant() const; |
|
360 |
|
361 }; |
|
362 |
|
363 #endif |