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 "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".
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"
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.
37 const TUint32 KSIPSendWithExpires = 200;
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.
46 const TUint32 KSIPCacheOutboundProxyIP = 201;
48 // FORWARD DECLARATIONS
52 class CSIPContactHeader;
53 class CSIPRouteHeader;
54 class CSIPMessageElements;
57 class CSIPClientTransaction;
58 class CRegBindingImplementation;
66 * Class for managing SIP registration binding.
67 * Class provides functions for creating and updating SIP registration bindings.
71 class CSIPRegistrationBinding :
73 public MSIPRegistrationContext
75 public: // Constructors and destructor
78 * Two-phased constructor.
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
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
101 IMPORT_C static CSIPRegistrationBinding*
102 NewL(CSIPConnection& aConnection,
104 CSIPContactHeader* aContact,
105 CSIPRefresh* aRefresh=0,
106 CSIPRouteHeader* aOutboundProxy=0,
108 CSIPFromHeader* aFrom=0);
111 * Two-phased constructor.
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
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
134 IMPORT_C static CSIPRegistrationBinding*
135 NewLC(CSIPConnection& aConnection,
137 CSIPContactHeader* aContact,
138 CSIPRefresh* aRefresh=0,
139 CSIPRouteHeader* aOutboundProxy=0,
141 CSIPFromHeader* aFrom=0);
146 IMPORT_C ~CSIPRegistrationBinding();
148 public: //From MSIPRegistrationContext:
151 * Checks if the registration context can be
152 * used for creating SIP messages/dialogs
153 * @return ETrue if the registration binding exists; EFalse
156 IMPORT_C TBool IsContextActive() const;
159 * Gets the context id
161 * For internal use only
163 IMPORT_C TUint32 ContextId() const;
165 public: // New functions
167 * Creates SIP REGISTER request, sends it to the given destination.
168 * Received 2xx response will create at least one registration
170 * @pre Connection().State()==EActive
171 * @param aElements contains user SIP headers and content; the ownership
173 * @return SIP REGISTER transaction; the ownership is transfered
174 * @leave KErrSIPMalformedMessage if aElements contains contact or
176 * @leave KErrSIPInvalidRegistrationState if already registered or
177 * registering is in progress or deregistering is in progress.
178 * @capability NetworkServices
180 IMPORT_C CSIPClientTransaction*
181 RegisterL(CSIPMessageElements* aElements=0);
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
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
199 IMPORT_C CSIPClientTransaction*
200 DeregisterL(CSIPMessageElements* aElements=0);
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.
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
217 IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements);
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
234 IMPORT_C CSIPClientTransaction*
235 UpdateL(TUint aExpirationValue, CSIPMessageElements* aElements=0);
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.
242 IMPORT_C CSIPConnection* Connection();
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.
249 IMPORT_C const CSIPConnection* Connection() const;
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
258 IMPORT_C void SetOutboundProxyL(CSIPRouteHeader* aOutboundProxy);
261 * Gets the address-of-record (AOR) used for creating binding
262 * @return address-of-record (AOR)
264 IMPORT_C const CSIPToHeader& Aor() const;
267 * Gets Contact header associated with the registration binding
268 * @return Contact header
270 IMPORT_C const CSIPContactHeader& ContactHeader() const;
273 * Gets Contact header associated with the registration binding
274 * @return Contact header
276 IMPORT_C CSIPContactHeader& ContactHeader();
279 * Gets used outbound proxy
280 * @return outbound proxy or a 0-pointer if not set. Ownership is not
283 IMPORT_C const CSIPRouteHeader* OutboundProxy() const;
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
293 IMPORT_C const CSIPRefresh* SIPRefresh() const;
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
303 IMPORT_C CSIPRefresh* SIPRefresh();
306 * Compares this object to another object
307 * @param aRegistration CSIPRegistrationBinding object to compare
308 * @return ETrue if the objects are equal, otherwise EFalse
311 operator==(const CSIPRegistrationBinding& aRegistration) const;
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.
318 IMPORT_C const CSIPContactHeader* RegisteredContact() const;
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
327 IMPORT_C TInt SetProperty(TUint32 aProperty,TBool aValue);
329 public: // New functions, for internal use
331 * Returns the implementation instance.
333 * @return CRegBindingImplementation
335 CRegBindingImplementation& Implementation();
337 private: // Constructors
338 CSIPRegistrationBinding();
340 void ConstructL(CSIPConnection& aConnection,
342 CSIPContactHeader* aContacts,
343 CSIPRefresh* aRefresh,
344 CSIPRouteHeader* aOutboundProxy,
346 CSIPFromHeader* aFrom);
349 CRegBindingImplementation* iImplementation;
351 private: // For testing purposes
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;
359 void __DbgTestInvariant() const;