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 : sipinvitedialogassoc.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
25 #ifndef CSIPINVITEDIALOGASSOC_H
26 #define CSIPINVITEDIALOGASSOC_H
29 #include "sipdialogassocbase.h"
33 // FORWARD DECLARATIONS
36 class CSIPServerTransaction;
39 class CSIPContactHeader;
40 class MSIPRegistrationContext;
48 * Class for managing SIP dialog association created with INVITE.
49 * It provides services for creating, using and
50 * terminating SIP INVITE dialog association.
52 * The user can have only one INVITE dialog association per dialog.
56 class CSIPInviteDialogAssoc : public CSIPDialogAssocBase
58 public: // Constructors and destructor
61 * Two-phased constructor.
62 * @param aDialog a dialog to be associated with
63 * @return New object, ownership is transferred.
65 IMPORT_C static CSIPInviteDialogAssoc* NewL(CSIPDialog& aDialog);
68 * Two-phased constructor.
69 * @param aDialog a dialog to be associated with
70 * @return New object, ownership is transferred.
72 IMPORT_C static CSIPInviteDialogAssoc* NewLC(CSIPDialog& aDialog);
75 * Two-phased constructor.
76 * Should be used if response to the received SIP request will create
77 * a SIP dialog association.
78 * The server transaction must be a INVITE transaction.
79 * If SIP server transaction was received within an existing SIP dialog
80 * the created SIP dialog association will be correlated to that SIP
81 * dialog. Otherwise a new SIP dialog is created.
82 * @pre aTransaction.State() == CSIPTransactionBase::EProceeding
83 * @pre aTransaction.Type() == SipStrConsts::EInvite
84 * @param aTransaction a SIP server transaction
85 * @return New object, ownership is transferred.
86 * @leave KErrArgument if aTransaction.Type() != SipStrConsts::EInvite
87 * @leave KErrSIPInvalidTransactionState if aTransaction.State() !=
88 * CSIPTransactionBase::EProceeding
89 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
90 * object has been deleted
92 IMPORT_C static CSIPInviteDialogAssoc*
93 NewL(CSIPServerTransaction& aTransaction);
96 * Two-phased constructor.
97 * Should be used if response to the received SIP request will create a
98 * SIP dialog association.
99 * The server transaction must be a INVITE transaction.
100 * If SIP server transaction was received within the existing SIP dialog
101 * the created SIP dialog association will be correlated to that
102 * SIP dialog. Otherwise a new SIP dialog is created.
103 * @pre aTransaction.State() == CSIPTransactionBase::EProceeding
104 * @pre aTransaction.Type() == SipStrConsts::EInvite
105 * @param aTransaction a SIP server transaction
106 * @return New object, ownership is transferred.
107 * @leave KErrArgument if aTransaction.Type() != SipStrConsts::EInvite
108 * @leave KErrSIPInvalidTransactionState if aTransaction.State() !=
109 * CSIPTransactionBase::EProceeding
110 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
111 * object has been deleted
113 IMPORT_C static CSIPInviteDialogAssoc*
114 NewLC(CSIPServerTransaction& aTransaction);
117 * Two-phased constructor.
118 * Should be used if response to the received SIP request will create
119 * a SIP dialog association.
120 * The server transaction must be a INVITE transaction.
121 * If SIP server transaction was received within an existing SIP dialog
122 * the created SIP dialog association will be correlated to that SIP
123 * dialog. Otherwise a new SIP dialog is created.
124 * @pre aTransaction.State() == CSIPTransactionBase::EProceeding
125 * @pre aTransaction.Type() == SipStrConsts::EInvite
126 * @pre aContext.IsContextActive() == ETrue
127 * @param aTransaction a SIP server transaction
128 * @param aContext that will be used for populating
129 * the Contact-header of the response to aTransaction
130 * @return New object, ownership is transferred.
131 * @leave KErrArgument if aTransaction.Type() != SipStrConsts::EInvite
132 * @leave KErrSIPInvalidTransactionState if aTransaction.State() !=
133 * CSIPTransactionBase::EProceeding
134 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
135 * object has been deleted
137 IMPORT_C static CSIPInviteDialogAssoc*
138 NewL(CSIPServerTransaction& aTransaction,
139 const MSIPRegistrationContext& aContext);
142 * Two-phased constructor.
143 * Should be used if response to the received SIP request will create a
144 * SIP dialog association.
145 * The server transaction must be a INVITE transaction.
146 * If SIP server transaction was received within the existing SIP dialog
147 * the created SIP dialog association will be correlated to that
148 * SIP dialog. Otherwise a new SIP dialog is created.
149 * @pre aTransaction.State() == CSIPTransactionBase::EProceeding
150 * @pre aTransaction.Type() == SipStrConsts::EInvite
151 * @pre aContext.IsContextActive() == ETrue
152 * @param aTransaction a SIP server transaction
153 * @param aContext that will be used for populating
154 * the Contact-header of the response to aTransaction
155 * @return New object, ownership is transferred.
156 * @leave KErrArgument if aTransaction.Type() != SipStrConsts::EInvite
157 * @leave KErrSIPInvalidTransactionState if aTransaction.State() !=
158 * CSIPTransactionBase::EProceeding
159 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
160 * object has been deleted
162 IMPORT_C static CSIPInviteDialogAssoc*
163 NewLC(CSIPServerTransaction& aTransaction,
164 const MSIPRegistrationContext& aContext);
167 * Two-phased constructor
169 * @pre aRemoteUri != 0
170 * The user of the class must not define tags in From-header
172 * @param aConnection a SIP connection to be used with
174 * @param aFrom originator's address; the ownership is transfered
175 * @param aRemoteUri a remote target URI that identifies a resource that
176 * the request is addressed to. The ownership is transferred.
177 * @param aTo logical recipient's address; if not defined
178 * the remote target uri will be used for To-header
179 * construction; the ownership is transfered
180 * @param aContact a contact to be used in dialog creation. Must be
181 * given only if user intends to re-direct future requests;
182 * the ownership is transfered
183 * @return New object, ownership is transferred.
184 * @leave KErrArgument if aFrom == 0 or aRemoteUri == 0
186 IMPORT_C static CSIPInviteDialogAssoc*
187 NewL(CSIPConnection& aConnection,
188 CSIPFromHeader* aFrom,
191 CSIPContactHeader* aContact=0);
194 * Two-phased constructor
196 * @pre aRemoteUri != 0
197 * The user of the class must not define tags in From-header
199 * @param aSIPConnection a SIP connection to be used with
201 * @param aFrom originator's address; the ownership is transfered
202 * @param aRemoteUri a remote target URI that identifies a resource that
203 * the request is addressed to. The ownership is transferred.
204 * @param aTo logical recipient's address; if not defined
205 * the remote target uri will be used for To-header
206 * construction; the ownership is transfered
207 * @param aContact a contact to be used in dialog creation. Must be
208 * given only if user intends to re-direct future requests;
209 * the ownership is transfered
210 * @return New object, ownership is transferred.
211 * @leave KErrArgument if aFrom == 0 or aRemoteUri == 0
213 IMPORT_C static CSIPInviteDialogAssoc*
214 NewLC(CSIPConnection& aConnection,
215 CSIPFromHeader* aFrom,
218 CSIPContactHeader* aContact=0);
221 * Two-phased constructor
222 * @pre aRemoteUri != 0
223 * The user of the class must not define tags in From-header
225 * @pre aContext.IsContextActive() == ETrue
226 * @param aConnection a SIP connection to be used with
228 * @param aRemoteUri a remote target URI that identifies a resource
229 * that the request is targeted to. The ownership is transferred.
230 * @param aContext used for selecting outbound
231 * proxy and originator's address (AOR) and contact
232 * @param aFrom originator's address. If not defined it will
233 * constructed using registration context (User's AOR);
234 * the ownership is transfered
235 * @param aTo logical recipient's address; if not defined
236 * the remote target uri will be used for To-header
237 * construction; the ownership is transfered
238 * @param aContact a contact to be used in dialog creation. Must be
239 * given only if user intends to re-direct future requests;
240 * the ownership is transfered
241 * @return New object, ownership is transferred.
242 * @leave KErrArgument if aRemoteUri == 0
243 * @leave KErrSIPInvalidRegistrationState
244 * if aContext.IsContextActive() == EFalse
246 IMPORT_C static CSIPInviteDialogAssoc*
247 NewL(CSIPConnection& aConnection,
249 const MSIPRegistrationContext& aContext,
250 CSIPFromHeader* aFrom=0,
252 CSIPContactHeader* aContact=0);
255 * Two-phased constructor
256 * @pre aRemoteUri != 0
257 * The user of the class must not define tags in From-header
259 * @pre aContext.IsContextActive() == ETrue
260 * @param aConnection a SIP connection to be used with
262 * @param aRemoteUri a remote target URI that identifies a resource
263 * that the request is targeted to. The ownership is transferred.
264 * @param aContext used for selecting outbound
265 * proxy and originator's address (AOR) and contact
266 * @param aFrom originator's address. If not defined it will
267 * constructed using registration context (User's AOR);
268 * the ownership is transfered
269 * @param aTo logical recipient's address; if not defined
270 * the remote target uri will be used for To-header
271 * construction; the ownership is transfered
272 * @param aContact a contact to be used in dialog creation. Must be
273 * given only if user intends to re-direct future requests;
274 * the ownership is transfered
275 * @return New object, ownership is transferred.
276 * @leave KErrArgument if aRemoteUri == 0
277 * @leave KErrSIPInvalidRegistrationState
278 * if aContext.IsContextActive() == EFalse
280 IMPORT_C static CSIPInviteDialogAssoc*
281 NewLC(CSIPConnection& aConnection,
283 const MSIPRegistrationContext& aContext,
284 CSIPFromHeader* aFrom=0,
286 CSIPContactHeader* aContact=0);
291 IMPORT_C ~CSIPInviteDialogAssoc();
293 public: // New functions
296 * Creates INVITE and sends it to the remote target.
297 * 101-199 or 2xx response will create INVITE dialog association in case
298 * of first INVITE within this dialog association. Subsequent INVITE
299 * requests are re-INVITEs.
300 * @pre Dialog().Connection().State()==EActive
301 * @pre Dialog().State()==CSIPDialog::EInit ||
302 * Dialog().State()==CSIPDialog::EConfirmed
303 * @param aElements contains user SIP headers and content. Ownership is
305 * @return INVITE SIP transaction. Ownership is transferred.
306 * @leave KErrSIPInvalidDialogState if dialog is not in a correct state
307 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
308 * object has been deleted
309 * @capability NetworkServices
311 IMPORT_C CSIPClientTransaction*
312 SendInviteL(CSIPMessageElements* aElements=0);
315 * Creates PRACK and sends it to the remote target.
316 * @pre Dialog().Connection().State()==EActive
317 * @pre Dialog().State()==CSIPDialog::EEarly ||
318 * Dialog().State()==CSIPDialog::EConfirmed
319 * @pre aElements must not contain Contact headers
320 * @param aElements contains user SIP headers and content. Ownership is
322 * @return PRACK SIP transaction. Ownership is transferred.
323 * @leave KErrSIPInvalidDialogState if dialog is not in a correct state
324 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
325 * object has been deleted
326 * @capability NetworkServices
328 IMPORT_C CSIPClientTransaction*
329 SendPrackL(CSIPMessageElements* aElements=0);
332 * Creates UPDATE and sends it to the remote target.
333 * @pre Dialog().Connection().State()==EActive
334 * @pre Dialog().State()==CSIPDialog::EEarly ||
335 * Dialog().State()==CSIPDialog::EConfirmed
336 * @param aElements contains user SIP headers and content. Ownership is
338 * @return UPDATE SIP transaction. Ownership is transferred.
339 * @leave KErrSIPInvalidDialogState if dialog is not in a correct state
340 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
341 * object has been deleted
342 * @capability NetworkServices
344 IMPORT_C CSIPClientTransaction*
345 SendUpdateL(CSIPMessageElements* aElements=0);
348 * Creates SIP ACK request and sends it to the remote target.
349 * The client transaction must be an INVITE transaction.
350 * @pre Dialog().Connection().State()==EActive
351 * @pre Dialog().State()==CSIPDialog::EConfirmed
352 * @param aTransaction a SIP INVITE client transaction to acknowledge
353 * @param aElements optional SIP message headers and body. Ownership is
355 * @leave KErrArgument if aTransaction is not an INVITE transaction.
356 * @leave KErrSIPInvalidDialogState if ACK can't be sent in the current
358 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
359 * object has been deleted
360 * @capability NetworkServices
362 IMPORT_C void SendAckL(const CSIPClientTransaction& aTransaction,
363 CSIPMessageElements* aElements=0);
366 * Creates SIP BYE request and sends it to the remote target.
367 * @pre Dialog().Connection().State()==EActive
368 * @pre Dialog().State()==CSIPDialog::EEarly ||
369 * Dialog().State()==CSIPDialog::EConfirmed
370 * @param aElements contains user SIP headers and content. Ownership is
372 * @return SIP BYE transaction. Ownership is transferred.
373 * @leave KErrSIPInvalidDialogState if BYE can't be sent in the current
375 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
376 * object has been deleted
377 * @capability NetworkServices
379 IMPORT_C CSIPClientTransaction*
380 SendByeL(CSIPMessageElements* aElements=0);
382 public: // New functions, for internal use
385 * Sends initial INVITE creating a dialog and creates a transaction for
387 * @param aElements contains user SIP headers and content. Ownership is
389 * @return INVITE SIP transaction. Ownership is transferred.
391 CSIPClientTransaction* DoSendInviteL(CSIPMessageElements* aElements);
395 * @param aTransaction a SIP INVITE client transaction to acknowledge
396 * @param aElements optional SIP message headers and body. Ownership is
399 void DoSendAckL(const CSIPClientTransaction& aTransaction,
400 CSIPMessageElements* aElements);
402 CSIPClientTransaction*
403 DoSendRequestWithinDialogL(RStringF aMethod,
404 CSIPMessageElements* aElements);
406 CSIPClientTransaction* DoSendCancelL(TUint32 aRequestId);
408 private: // Constructors
410 static CSIPInviteDialogAssoc* NewLC(CSIPConnection& aConnection,
412 CSIPFromHeader* aFrom,
414 CSIPContactHeader* aContact,
415 const MSIPRegistrationContext* aContext);
417 CSIPInviteDialogAssoc();
419 void ConstructL(CSIPServerTransaction& aTransaction,
420 const MSIPRegistrationContext* aContext);