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 : sipnotifydialogassoc.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
25 #ifndef CSIPNOTIFYDIALOGASSOC_H
26 #define CSIPNOTIFYDIALOGASSOC_H
30 #include "sipdialogassocbase.h"
34 // FORWARD DECLARATIONS
35 class CSIPEventHeader;
36 class CSIPSubscriptionStateHeader;
37 class MSIPRegistrationContext;
45 * Class for managing SIP NOTIFY dialog associations.
46 * It provides services for creating, using and
47 * terminating SIP NOTIFY dialog associations. The user can have multiple
48 * NOTIFY dialog associations per same SIP dialog.
49 * Implementation handles SUBSCRIBE on the dialog level defined by Call-Id,
50 * local and remote tags; user is responsible for "Event" and
51 * "Subscription-State" header semantics.
54 class CSIPNotifyDialogAssoc: public CSIPDialogAssocBase
56 public: // Constructors and destructor
59 * Two-phased constructor.
60 * The response to the received SIP request will create a SIP NOTIFY
61 * dialog association that will be correlated with the SIP dialog in
62 * which SIP server transaction was received. If the server transaction
63 * was not received within a SIP dialog, a new SIP dialog is created.
64 * The server transaction must be either SUBSCRIBE or REFER transaction.
65 * @pre aTransaction.State()==ETrying || EProceeding
66 * @pre aTransaction.Type() ==
67 * SipStrConsts::ESubscribe || SipStrConsts::ERefer
68 * @pre aEvent != 0 && aState != 0
69 * @param aTransaction a SIP server transaction
70 * @param aEvent an event to send a notification about; the ownership
72 * @param aState a subscription state; the ownership is transferred.
73 * @return New object; the ownership is transferred
74 * @leave KErrArgument if aTransaction is not a SUBSCRIBE or REFER
75 * transaction, or aEvent == 0 or aState == 0.
76 * @leave KErrSIPInvalidTransactionState if aTransaction is in a wrong
79 IMPORT_C static CSIPNotifyDialogAssoc*
80 NewL(CSIPServerTransaction& aTransaction,
81 CSIPEventHeader* aEvent,
82 CSIPSubscriptionStateHeader* aState);
85 * Two-phased constructor.
86 * The response to the received SIP request will create a SIP NOTIFY
87 * dialog association that will be correlated with the SIP dialog in
88 * which SIP server transaction was received. If the server transaction
89 * was not received within a SIP dialog, a new SIP dialog is created.
90 * The server transaction must be either SUBSCRIBE or REFER transaction.
91 * @pre aTransaction.State()==ETrying || EProceeding
92 * @pre aTransaction.Type() ==
93 * SipStrConsts::ESubscribe || SipStrConsts::ERefer
94 * @pre aEvent != 0 && aState != 0
95 * @param aTransaction a SIP server transaction
96 * @param aEvent an event to send a notification about; the ownership
98 * @param aState a subscription state; the ownership is transferred.
99 * @return New object; the ownership is transferred
100 * @leave KErrArgument if aTransaction is not a SUBSCRIBE or REFER
101 * transaction, or aEvent == 0 or aState == 0.
102 * @leave KErrSIPInvalidTransactionState if aTransaction is in a wrong
105 IMPORT_C static CSIPNotifyDialogAssoc*
106 NewLC(CSIPServerTransaction& aTransaction,
107 CSIPEventHeader* aEvent,
108 CSIPSubscriptionStateHeader* aState);
111 * Two-phased constructor.
112 * The response to the received SIP request will create a SIP NOTIFY
113 * dialog association that will be correlated with the SIP dialog in
114 * which SIP server transaction was received. If the server transaction
115 * was not received within a SIP dialog, a new SIP dialog is created.
116 * The server transaction must be either SUBSCRIBE or REFER transaction.
117 * @pre aTransaction.State()==ETrying || EProceeding
118 * @pre aTransaction.Type() ==
119 * SipStrConsts::ESubscribe || SipStrConsts::ERefer
120 * @pre aContext.IsContextActive() == ETrue
121 * @pre aEvent != 0 && aState != 0
122 * @param aTransaction a SIP server transaction
123 * @param aContext that will be used for populating
124 * the Contact-header of the response to aTransaction
125 * @param aEvent an event to send a notification about; the ownership
127 * @param aState a subscription state; the ownership is transferred.
128 * @return New object; the ownership is transferred
129 * @leave KErrArgument if aTransaction is not a SUBSCRIBE or REFER
130 * transaction, or aEvent == 0 or aState == 0.
131 * @leave KErrSIPInvalidTransactionState if aTransaction is in a wrong
134 IMPORT_C static CSIPNotifyDialogAssoc*
135 NewL(CSIPServerTransaction& aTransaction,
136 const MSIPRegistrationContext& aContext,
137 CSIPEventHeader* aEvent,
138 CSIPSubscriptionStateHeader* aState);
141 * Two-phased constructor.
142 * The response to the received SIP request will create a SIP NOTIFY
143 * dialog association that will be correlated with the SIP dialog in
144 * which SIP server transaction was received. If the server transaction
145 * was not received within a SIP dialog, a new SIP dialog is created.
146 * The server transaction must be either SUBSCRIBE or REFER transaction.
147 * @pre aTransaction.State()==ETrying || EProceeding
148 * @pre aTransaction.Type() ==
149 * SipStrConsts::ESubscribe || SipStrConsts::ERefer
150 * @pre aContext.IsContextActive() == ETrue
151 * @pre aEvent != 0 && aState != 0
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 * @param aEvent an event to send a notification about; the ownership
157 * @param aState a subscription state; the ownership is transferred.
158 * @return New object; the ownership is transferred
159 * @leave KErrArgument if aTransaction is not a SUBSCRIBE or REFER
160 * transaction, or aEvent == 0 or aState == 0.
161 * @leave KErrSIPInvalidTransactionState if aTransaction is in a wrong
164 IMPORT_C static CSIPNotifyDialogAssoc*
165 NewLC(CSIPServerTransaction& aTransaction,
166 const MSIPRegistrationContext& aContext,
167 CSIPEventHeader* aEvent,
168 CSIPSubscriptionStateHeader* aState);
173 IMPORT_C ~CSIPNotifyDialogAssoc();
175 public: // New functions
178 * Creates NOTIFY and sends it to the remote target.
179 * If client provides optional SIP headers they must
180 * not contain Event and Subscription-State headers.
181 * @pre Dialog().Connection().State()==EActive
182 * @pre Dialog().State()==CSIPDialog::TState::EConfirmed
183 * @param aElements optional SIP message headers and body.
184 * Ownership is transferred.
185 * @return NOTIFY SIP UAC transaction
186 * @leave KErrSIPInvalidDialogState if dialog's state is incorrect
187 * @leave KErrSIPResourceNotAvailable if a required SIP Client API
188 * object has been deleted.
189 * @capability NetworkServices
191 IMPORT_C CSIPClientTransaction*
192 SendNotifyL(CSIPMessageElements* aElements=0);
195 * Gets an event about which the notification is done
198 IMPORT_C const CSIPEventHeader& Event() const;
201 * Gets subscription state
202 * @return subscription state
204 IMPORT_C CSIPSubscriptionStateHeader& SubscriptionState();
207 * Gets subscription state
208 * @return subscription state
210 IMPORT_C const CSIPSubscriptionStateHeader& SubscriptionState() const;
212 public: // New functions, for internal use
214 CSIPClientTransaction*
215 DoSendNotifyWithinDialogL(CSIPMessageElements* aElements);
217 private: // Constructors
219 CSIPNotifyDialogAssoc();
221 void ConstructL(CSIPServerTransaction& aTransaction,
222 const MSIPRegistrationContext* aContext,
223 CSIPEventHeader* aEvent,
224 CSIPSubscriptionStateHeader* aState);
228 CSIPEventHeader* iEvent;
229 CSIPSubscriptionStateHeader* iSubscriptionState;