2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : sipregistrationbinding.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
24 #ifndef CSIPREGISTRATIONBINDING_H
25 #define CSIPREGISTRATIONBINDING_H
28 #include "sipregistrationcontext.h"
29 #include "_sipcodecdefs.h"
31 // FORWARD DECLARATIONS
35 class CSIPContactHeader;
36 class CSIPRouteHeader;
37 class CSIPMessageElements;
40 class CSIPClientTransaction;
41 class CRegBindingImplementation;
49 * Class for managing SIP registration binding.
50 * Class provides functions for creating and updating SIP registration bindings.
54 class CSIPRegistrationBinding :
56 public MSIPRegistrationContext
58 public: // Constructors and destructor
61 * Two-phased constructor.
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
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
84 IMPORT_C static CSIPRegistrationBinding*
85 NewL(CSIPConnection& aConnection,
87 CSIPContactHeader* aContact,
88 CSIPRefresh* aRefresh=0,
89 CSIPRouteHeader* aOutboundProxy=0,
91 CSIPFromHeader* aFrom=0);
94 * Two-phased constructor.
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
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
117 IMPORT_C static CSIPRegistrationBinding*
118 NewLC(CSIPConnection& aConnection,
120 CSIPContactHeader* aContact,
121 CSIPRefresh* aRefresh=0,
122 CSIPRouteHeader* aOutboundProxy=0,
124 CSIPFromHeader* aFrom=0);
129 IMPORT_C ~CSIPRegistrationBinding();
131 public: //From MSIPRegistrationContext:
134 * Checks if the registration context can be
135 * used for creating SIP messages/dialogs
136 * @return ETrue if the registration binding exists; EFalse
139 IMPORT_C TBool IsContextActive() const;
142 * Gets the context id
144 * For internal use only
146 IMPORT_C TUint32 ContextId() const;
148 public: // New functions
150 * Creates SIP REGISTER request, sends it to the given destination.
151 * Received 2xx response will create at least one registration
153 * @pre Connection().State()==EActive
154 * @param aElements contains user SIP headers and content; the ownership
156 * @return SIP REGISTER transaction; the ownership is transfered
157 * @leave KErrSIPMalformedMessage if aElements contains contact or
159 * @leave KErrSIPInvalidRegistrationState if already registered or
160 * registering is in progress or deregistering is in progress.
161 * @capability NetworkServices
163 IMPORT_C CSIPClientTransaction*
164 RegisterL(CSIPMessageElements* aElements=0);
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
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
182 IMPORT_C CSIPClientTransaction*
183 DeregisterL(CSIPMessageElements* aElements=0);
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.
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
200 IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements);
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
217 IMPORT_C CSIPClientTransaction*
218 UpdateL(TUint aExpirationValue, CSIPMessageElements* aElements=0);
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.
225 IMPORT_C CSIPConnection* Connection();
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.
232 IMPORT_C const CSIPConnection* Connection() const;
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
241 IMPORT_C void SetOutboundProxyL(CSIPRouteHeader* aOutboundProxy);
244 * Gets the address-of-record (AOR) used for creating binding
245 * @return address-of-record (AOR)
247 IMPORT_C const CSIPToHeader& Aor() const;
250 * Gets Contact header associated with the registration binding
251 * @return Contact header
253 IMPORT_C const CSIPContactHeader& ContactHeader() const;
256 * Gets Contact header associated with the registration binding
257 * @return Contact header
259 IMPORT_C CSIPContactHeader& ContactHeader();
262 * Gets used outbound proxy
263 * @return outbound proxy or a 0-pointer if not set. Ownership is not
266 IMPORT_C const CSIPRouteHeader* OutboundProxy() const;
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
276 IMPORT_C const CSIPRefresh* SIPRefresh() const;
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
286 IMPORT_C CSIPRefresh* SIPRefresh();
289 * Compares this object to another object
290 * @param aRegistration CSIPRegistrationBinding object to compare
291 * @return ETrue if the objects are equal, otherwise EFalse
294 operator==(const CSIPRegistrationBinding& aRegistration) const;
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.
301 IMPORT_C const CSIPContactHeader* RegisteredContact() const;
303 public: // New functions, for internal use
305 * Returns the implementation instance.
307 * @return CRegBindingImplementation
309 CRegBindingImplementation& Implementation();
311 private: // Constructors
312 CSIPRegistrationBinding();
314 void ConstructL(CSIPConnection& aConnection,
316 CSIPContactHeader* aContacts,
317 CSIPRefresh* aRefresh,
318 CSIPRouteHeader* aOutboundProxy,
320 CSIPFromHeader* aFrom);
323 CRegBindingImplementation* iImplementation;
325 private: // For testing purposes
328 UNIT_TEST(CSIPRegistrationBinding_Test)
329 UNIT_TEST(CSIPInviteDialogAssoc_Test)
330 UNIT_TEST(CSIPSubscribeDialogAssoc_Test)
331 UNIT_TEST(CSIPReferDialogAssoc_Test)