2 * Copyright (c) 2005-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 : sipreferdialogassoc.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
24 #ifndef CSIPREFERDIALOGASSOC_H
25 #define CSIPREFERDIALOGASSOC_H
28 #include "sipdialogassocbase.h"
32 // FORWARD DECLARATIONS
36 class CSIPContactHeader;
37 class CSIPReferToHeader;
38 class MSIPRegistrationContext;
47 * Class for managing SIP REFER dialog associations.
48 * It provides services for creating, using and terminating SIP REFER
49 * dialog associations. User can have multiple REFER dialog associations
50 * per same SIP dialog.
51 * Implementation handles SUBSCRIBE on the dialog level defined by Call-Id,
52 * local and remote tags;
53 * User is responsible for "Refer-to" header semantics.
56 class CSIPReferDialogAssoc: public CSIPDialogAssocBase
58 public: // Constructors and destructor
61 * Two-phased constructor.
62 * Should be used if response to the SIP request to be sent
63 * will create a SIP dialog association.
65 * @param aDialog a dialog to be associated with
66 * @param aReferTo referred-to resource;
67 * Ownership is transferred
68 * @return New object; the ownership is transferred
69 * @leave KErrArgument if aReferTo == 0
71 IMPORT_C static CSIPReferDialogAssoc*
72 NewL(CSIPDialog& aDialog,
73 CSIPReferToHeader* aReferTo);
76 * Two-phased constructor.
77 * Must be used if response to the SIP request to be sent
78 * will create a SIP dialog association.
80 * @param aDialog a dialog to be associated with
81 * @param aReferTo referred-to resource;
82 * Ownership is transferred
83 * @return New object; the ownership is transferred
84 * @leave KErrArgument if aReferTo == 0
86 IMPORT_C static CSIPReferDialogAssoc*
87 NewLC(CSIPDialog& aDialog,
88 CSIPReferToHeader* aReferTo);
91 * Two-phased constructor
94 * @pre aRemoteUri != 0
95 * The user of the class must not define tags in From-header
97 * @param aConnection a SIP connection to be used with
99 * @param aFrom originator's address; the ownership is transfered
100 * @param aRemoteUri a remote target URI that identifies a resource that
101 * the request is addressed to.
102 * @param aReferTo referred-to resource;
103 * Ownership is transferred
104 * @param aTo logical recipient's address; if not defined
105 * the remote target uri will be used for To-header
106 * construction; the ownership is transfered
107 * @param aContact a contact to be used in dialog creation. Must be
108 * given only if user intends to re-direct future requests;
109 * the ownership is transfered
110 * @return New object; the ownership is transferred.
111 * @leave KErrArgument if aFrom == 0 or aRemoteuri == 0 or aReferTo == 0
113 IMPORT_C static CSIPReferDialogAssoc*
114 NewL(CSIPConnection& aConnection,
115 CSIPFromHeader* aFrom,
117 CSIPReferToHeader* aReferTo,
119 CSIPContactHeader* aContact=0);
122 * Two-phased constructor
125 * @pre aRemoteUri != 0
126 * The user of the class must not define tags in From-header
128 * @param aConnection a SIP connection to be used with
130 * @param aFrom originator's address; the ownership is transfered
131 * @param aRemoteUri a remote target URI that identifies a resource that
132 * the request is addressed to.
133 * @param aReferTo referred-to resource;
134 * Ownership is transferred
135 * @param aTo logical recipient's address; if not defined
136 * the remote target uri will be used for To-header
137 * construction; the ownership is transfered
138 * @param aContact a contact to be used in dialog creation. Must be
139 * given only if user intends to re-direct future requests;
140 * the ownership is transfered
141 * @return New object; the ownership is transferred.
142 * @leave KErrArgument if aFrom == 0 or aRemoteuri == 0 or aReferTo == 0
144 IMPORT_C static CSIPReferDialogAssoc*
145 NewLC(CSIPConnection& aConnection,
146 CSIPFromHeader* aFrom,
148 CSIPReferToHeader* aReferTo,
150 CSIPContactHeader* aContact=0);
153 * Two-phased constructor
155 * @pre aRemoteUri != 0
156 * The user of the class must not define tags in From-header
158 * @pre aContext.IsContextActive() == ETrue
159 * @param aConnection a SIP connection to be used with
161 * @param aRemoteUri a remote target URI that identifies a resource that
162 * the request is targeted to.
163 * @param aContext used for selecting outbound
164 * proxy and originator's address (AOR) and contact
165 * @param aReferTo referred-to resource;
166 * Ownership is transferred
167 * @param aFrom originator's address. If not defined it will
168 * constructed using registration context (User's AOR);
169 * the ownership is transfered
170 * @param aTo logical recipient's address; if not defined
171 * the remote target uri will be used for To-header
172 * construction; the ownership is transfered
173 * @param aContact a contact to be used in dialog creation. Must be
174 * given only if user intends to re-direct future requests;
175 * the ownership is transfered
176 * @return New object: the ownership is transferred.
177 * @leave KErrArgument if aRemoteuri == 0 or aReferTo == 0
178 * @leave KErrSIPInvalidRegistrationState
179 * if aContext.IsContextActive() == EFalse
181 IMPORT_C static CSIPReferDialogAssoc*
182 NewL(CSIPConnection& aConnection,
184 const MSIPRegistrationContext& aContext,
185 CSIPReferToHeader* aReferTo,
186 CSIPFromHeader* aFrom=0,
188 CSIPContactHeader* aContact=0);
191 * Two-phased constructor
193 * @pre aRemoteUri != 0
194 * The user of the class must not define tags in From-header
196 * @pre aContext.IsContextActive()==ETrue
197 * @param aConnection a SIP connection to be used with
199 * @param aRemoteUri a remote target URI that identifies a resource that
200 * the request is targeted to.
201 * @param aContext used for selecting outbound
202 * proxy and originator's address (AOR) and contact
203 * @param aReferTo referred-to resource;
204 * Ownership is transferred
205 * @param aFrom originator's address. If not defined it will
206 * constructed using registration context (User's AOR);
207 * the ownership is transfered
208 * @param aTo logical recipient's address; if not defined
209 * the remote target uri will be used for To-header
210 * construction; the ownership is transfered
211 * @param aContact a contact to be used in dialog creation. Must be
212 * given only if user intends to re-direct future requests;
213 * the ownership is transfered
214 * @return New object; the ownership is transferred.
215 * @leave KErrArgument if aRemoteuri == 0 or aReferTo == 0
216 * @leave KErrSIPInvalidRegistrationState
217 * if aContext.IsContextActive() == EFalse
219 IMPORT_C static CSIPReferDialogAssoc*
220 NewLC(CSIPConnection& aConnection,
222 const MSIPRegistrationContext& aContext,
223 CSIPReferToHeader* aReferTo,
224 CSIPFromHeader* aFrom=0,
226 CSIPContactHeader* aContact=0);
231 IMPORT_C ~CSIPReferDialogAssoc();
233 public: //New functions
236 * Creates REFER and sends it to the remote target.
238 * 101-199 or 2xx response will create REFER dialog
239 * association in case of first REFER request within
240 * this dialog association.
241 * @pre Dialog().Connection().State()==EActive
242 * @pre Dialog().State()==CSIPDialog::EInit ||
243 * Dialog().State()==CSIPDialog::EConfirmed
244 * @param aElements optional SIP message headers and body. Ownership is
246 * @return REFER SIP transaction. Ownership is transferred.
247 * @leave KErrSIPInvalidDialogState if dialog is in wrong state
248 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
249 * object has been deleted.
250 * @capability NetworkServices
252 IMPORT_C CSIPClientTransaction*
253 SendReferL(CSIPMessageElements* aElements=0);
256 * Gets referred-to resouce
257 * @return referred-to resource
259 IMPORT_C const CSIPReferToHeader& ReferTo() const;
261 public: // New functions, for internal use
264 * Sends a REFER request.
266 * @pre Dialog().Connection().State()==EActive
267 * @param aElements optional SIP message headers and body.
268 * Ownership is transferred.
269 * @param aWithinDialog ETrue if REFER is sent within dialog,
270 * EFalse if REFER creates the dialog.
271 * @return REFER SIP transaction. Ownership is transferred.
273 CSIPClientTransaction* DoSendReferL(CSIPMessageElements* aElements,
274 TBool aWithinDialog);
276 private: // Constructors
278 CSIPReferDialogAssoc();
280 static CSIPReferDialogAssoc* NewLC(CSIPConnection& aConnection,
282 CSIPReferToHeader* aReferTo,
283 CSIPFromHeader* aFrom,
285 CSIPContactHeader* aContact,
286 const MSIPRegistrationContext* aContext);
290 CSIPReferToHeader* iReferTo;