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.
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
30 #include <stringpool.h>
32 // FORWARD DECLARATIONS
34 class CSIPConnectionImplementation;
35 class MSIPRegistrationContext;
36 class CSIPDialogAssocBase;
39 class CSIPCallIDHeader;
41 class CSIPDialogImplementation;
49 * Class for managing SIP dialogs.
50 * It provides services querying dialog state, obtaining the dialog related
51 * SIP headers and getting all dialog associations.
53 * The user of the class cannot instantiate this class.
57 class CSIPDialog: public CBase
63 /** Initiliazed state */
67 /** Confirmed state */
69 /** Terminated state */
73 public: //New functions
76 * @return dialog state
78 IMPORT_C CSIPDialog::TState State() const;
81 * Gets all dialog associations.
82 * @return All dialog associations. Ownership of the array or the items
83 * inside it, is not transferred.
85 IMPORT_C const RPointerArray<CSIPDialogAssocBase>&
86 SIPDialogAssociations() const;
89 * Gets used registration context for this dialog
90 * @return associated registration or 0-pointer otherwise.
91 * Ownership is not transferred.
93 IMPORT_C const MSIPRegistrationContext* RegistrationContext() const;
96 * Checks if the dialog association belongs to this dialog
97 * @param aDialogAssoc a dialog association
98 * @return ETrue if belongs, EFalse otherwise
101 IsAssociated(const CSIPDialogAssocBase& aDialogAssoc) const;
104 * Gets the SIP connection used for this dialog
105 * @return SIP connection used for the dialog, or 0-pointer if the
106 * connection has been deleted. Ownership isn't transferred.
108 IMPORT_C CSIPConnection* Connection();
111 * Gets the SIP connection used for this dialog.
112 * @return SIP connection used for the dialog, or 0-pointer if the
113 * connection has been deleted. Ownership isn't transferred.
115 IMPORT_C const CSIPConnection* Connection() const;
118 * Gets originator's address
119 * @return originator's address (From-header)
121 IMPORT_C const CSIPFromHeader& FromHeader() const;
124 * Gets recipient's address
125 * @return recipient's address (To-header)
127 IMPORT_C const CSIPToHeader& ToHeader() const;
130 * Gets remote-uri used during dialog creation
131 * @return Remote target uri
133 IMPORT_C const CUri8& RemoteURI() const;
136 * Gets Call-ID of SIP dialog
137 * @pre State()==CSIPDialog::EEarly || State()==CSIPDialog::EConfirmed
138 * @return Call-ID of SIP dialog
139 * @leave KErrSIPInvalidDialogState if dialog doesn't yet have a Call-ID
141 IMPORT_C const CSIPCallIDHeader& CallIdL() const;
144 * Compares this object to another object
145 * @param aDialog CSIPDialog object to compare
146 * @returns ETrue if the objects are equal, otherwise EFalse
148 IMPORT_C TBool operator==(const CSIPDialog& aDialog) const;
151 * Sets the dialog to state to CSIPDialog::EInit.
152 * The local dialog identifier data
153 * (Call-ID, CSeq and From-header's tag) will be reused.
154 * After calling this function, the dialog that was already terminated
155 * can be used for sending the dialog initiating request such as
156 * INVITE or SUBSCRIBE reusing the stored Call-ID and From-header's tag
157 * and the stored CSeq incremented by one.
158 * @pre State()==CSIPDialog::ETerminated
159 * @returns KErrNone if succesful and KErrNoMemory if the memory is low.
161 IMPORT_C TInt ReuseInitialRequestData();
163 public: //Constructors and destructor, for internal use
165 * Two-phased constructor.
166 * This constructor should be used if the user has received
167 * SIP request that creates a SIP dialog association.
169 * @param aConnImplementation Implementation of the used SIP connection
170 * @return New object, ownership is transferred.
173 NewL(CSIPConnectionImplementation& aConnImplementation);
176 * Two-phased constructor
177 * This constructor should be used if the user has received
178 * SIP request that creates a SIP dialog association.
180 * @param aConnImplementation Implementation of the used SIP connection
181 * @return New object, ownership is transferred.
184 NewLC(CSIPConnectionImplementation& aConnImplementation);
187 * Two-phased constructor
188 * This constructor should be used if the user has received
189 * SIP request that creates a SIP dialog association.
191 * @param aConnImplementation Implementation of the used SIP connection
192 * @param aContext Registration context whose outbound proxy and other
193 * parameters are to be used.
194 * @return New object, ownership is transferred.
197 NewL(CSIPConnectionImplementation& aConnImplementation,
198 const MSIPRegistrationContext& aContext);
201 * Two-phased constructor
202 * This constructor should be used if the user has received
203 * SIP request that creates a SIP dialog association.
205 * @param aConnImplementation Implementation of the used SIP connection
206 * @param aContext Registration context whose outbound proxy and other
207 * parameters are to be used.
208 * @return New object, ownership is transferred.
211 NewLC(CSIPConnectionImplementation& aConnImplementation,
212 const MSIPRegistrationContext& aContext);
219 public: // New functions, for internal use
222 * Returns the CSIPDialogImplementation.
223 * @return CSIPDialogImplementation
225 CSIPDialogImplementation& Implementation();
227 private: // Constructors
231 void ConstructL(CSIPConnectionImplementation& aConnImplementation);
233 void ConstructL(CSIPConnectionImplementation& aConnImplementation,
234 const MSIPRegistrationContext& aContext);
238 //Implementation instance, CSIPDialog doesn't own it
239 CSIPDialogImplementation* iImplementation;
241 private: // For testing purposes
243 friend class CSIP_Test;
244 friend class CSIPInviteDialogAssoc_Test;
245 friend class CSIPSubscribeDialogAssoc_Test;
246 friend class CSIPReferDialogAssoc_Test;
248 void __DbgTestInvariant() const;