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