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 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 : 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 * @return New object; the ownership is transferred
68 * @leave KErrArgument if aReferTo == 0
70 IMPORT_C static CSIPReferDialogAssoc*
71 NewL(CSIPDialog& aDialog,
72 CSIPReferToHeader* aReferTo);
75 * Two-phased constructor.
76 * Must be used if response to the SIP request to be sent
77 * will create a SIP dialog association.
79 * @param aDialog a dialog to be associated with
80 * @param aReferTo referred-to resource
81 * @return New object; the ownership is transferred
82 * @leave KErrArgument if aReferTo == 0
84 IMPORT_C static CSIPReferDialogAssoc*
85 NewLC(CSIPDialog& aDialog,
86 CSIPReferToHeader* aReferTo);
89 * Two-phased constructor
92 * @pre aRemoteUri != 0
93 * The user of the class must not define tags in From-header
95 * @param aConnection a SIP connection to be used with
97 * @param aFrom originator's address; the ownership is transfered
98 * @param aRemoteUri a remote target URI that identifies a resource that
99 * the request is addressed to.
100 * @param aReferTo referred-to resource
101 * @param aTo logical recipient's address; if not defined
102 * the remote target uri will be used for To-header
103 * construction; the ownership is transfered
104 * @param aContact a contact to be used in dialog creation. Must be
105 * given only if user intends to re-direct future requests;
106 * the ownership is transfered
107 * @return New object; the ownership is transferred.
108 * @leave KErrArgument if aFrom == 0 or aRemoteuri == 0 or aReferTo == 0
110 IMPORT_C static CSIPReferDialogAssoc*
111 NewL(CSIPConnection& aConnection,
112 CSIPFromHeader* aFrom,
114 CSIPReferToHeader* aReferTo,
116 CSIPContactHeader* aContact=0);
119 * Two-phased constructor
122 * @pre aRemoteUri != 0
123 * The user of the class must not define tags in From-header
125 * @param aConnection a SIP connection to be used with
127 * @param aFrom originator's address; the ownership is transfered
128 * @param aRemoteUri a remote target URI that identifies a resource that
129 * the request is addressed to.
130 * @param aReferTo referred-to resource
131 * @param aTo logical recipient's address; if not defined
132 * the remote target uri will be used for To-header
133 * construction; the ownership is transfered
134 * @param aContact a contact to be used in dialog creation. Must be
135 * given only if user intends to re-direct future requests;
136 * the ownership is transfered
137 * @return New object; the ownership is transferred.
138 * @leave KErrArgument if aFrom == 0 or aRemoteuri == 0 or aReferTo == 0
140 IMPORT_C static CSIPReferDialogAssoc*
141 NewLC(CSIPConnection& aConnection,
142 CSIPFromHeader* aFrom,
144 CSIPReferToHeader* aReferTo,
146 CSIPContactHeader* aContact=0);
149 * Two-phased constructor
151 * @pre aRemoteUri != 0
152 * The user of the class must not define tags in From-header
154 * @pre aContext.IsContextActive() == ETrue
155 * @param aConnection a SIP connection to be used with
157 * @param aRemoteUri a remote target URI that identifies a resource that
158 * the request is targeted to.
159 * @param aContext used for selecting outbound
160 * proxy and originator's address (AOR) and contact
161 * @param aReferTo referred-to resource
162 * @param aFrom originator's address. If not defined it will
163 * constructed using registration context (User's AOR);
164 * the ownership is transfered
165 * @param aTo logical recipient's address; if not defined
166 * the remote target uri will be used for To-header
167 * construction; the ownership is transfered
168 * @param aContact a contact to be used in dialog creation. Must be
169 * given only if user intends to re-direct future requests;
170 * the ownership is transfered
171 * @return New object: the ownership is transferred.
172 * @leave KErrArgument if aRemoteuri == 0 or aReferTo == 0
173 * @leave KErrSIPInvalidRegistrationState
174 * if aContext.IsContextActive() == EFalse
176 IMPORT_C static CSIPReferDialogAssoc*
177 NewL(CSIPConnection& aConnection,
179 const MSIPRegistrationContext& aContext,
180 CSIPReferToHeader* aReferTo,
181 CSIPFromHeader* aFrom=0,
183 CSIPContactHeader* aContact=0);
186 * Two-phased constructor
188 * @pre aRemoteUri != 0
189 * The user of the class must not define tags in From-header
191 * @pre aContext.IsContextActive()==ETrue
192 * @param aConnection a SIP connection to be used with
194 * @param aRemoteUri a remote target URI that identifies a resource that
195 * the request is targeted to.
196 * @param aContext used for selecting outbound
197 * proxy and originator's address (AOR) and contact
198 * @param aReferTo referred-to resource
199 * @param aFrom originator's address. If not defined it will
200 * constructed using registration context (User's AOR);
201 * the ownership is transfered
202 * @param aTo logical recipient's address; if not defined
203 * the remote target uri will be used for To-header
204 * construction; the ownership is transfered
205 * @param aContact a contact to be used in dialog creation. Must be
206 * given only if user intends to re-direct future requests;
207 * the ownership is transfered
208 * @return New object; the ownership is transferred.
209 * @leave KErrArgument if aRemoteuri == 0 or aReferTo == 0
210 * @leave KErrSIPInvalidRegistrationState
211 * if aContext.IsContextActive() == EFalse
213 IMPORT_C static CSIPReferDialogAssoc*
214 NewLC(CSIPConnection& aConnection,
216 const MSIPRegistrationContext& aContext,
217 CSIPReferToHeader* aReferTo,
218 CSIPFromHeader* aFrom=0,
220 CSIPContactHeader* aContact=0);
225 IMPORT_C ~CSIPReferDialogAssoc();
227 public: //New functions
230 * Creates REFER and sends it to the remote target.
232 * 101-199 or 2xx response will create REFER dialog
233 * association in case of first REFER request within
234 * this dialog association.
235 * @pre Dialog().Connection().State()==EActive
236 * @pre Dialog().State()==CSIPDialog::EInit ||
237 * Dialog().State()==CSIPDialog::EConfirmed
238 * @param aElements optional SIP message headers and body. Ownership is
240 * @return REFER SIP transaction. Ownership is transferred.
241 * @leave KErrSIPInvalidDialogState if dialog is in wrong state
242 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
243 * object has been deleted.
244 * @capability NetworkServices
246 IMPORT_C CSIPClientTransaction*
247 SendReferL(CSIPMessageElements* aElements=0);
250 * Gets referred-to resouce
251 * @return referred-to resource
253 IMPORT_C const CSIPReferToHeader& ReferTo() const;
255 public: // New functions, for internal use
258 * Sends a REFER request.
260 * @pre Dialog().Connection().State()==EActive
261 * @param aElements optional SIP message headers and body.
262 * Ownership is transferred.
263 * @param aWithinDialog ETrue if REFER is sent within dialog,
264 * EFalse if REFER creates the dialog.
265 * @return REFER SIP transaction. Ownership is transferred.
267 CSIPClientTransaction* DoSendReferL(CSIPMessageElements* aElements,
268 TBool aWithinDialog);
270 private: // Constructors
272 CSIPReferDialogAssoc();
274 static CSIPReferDialogAssoc* NewLC(CSIPConnection& aConnection,
276 CSIPReferToHeader* aReferTo,
277 CSIPFromHeader* aFrom,
279 CSIPContactHeader* aContact,
280 const MSIPRegistrationContext* aContext);
284 CSIPReferToHeader* iReferTo;