1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/sipsubscribedialogassoc.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,354 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* 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
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Name : sipsubscribedialogassoc.h
1.19 +* Part of : SIP Client
1.20 +* Interface : SDK API, SIP Client API
1.21 +* Version : 1.0
1.22 +*
1.23 +*/
1.24 +
1.25 +
1.26 +
1.27 +#ifndef CSIPSUBSCRIBEDIALOGASSOC_H
1.28 +#define CSIPSUBSCRIBEDIALOGASSOC_H
1.29 +
1.30 +// INCLUDES
1.31 +#include "sipdialogassocbase.h"
1.32 +
1.33 +// CONSTANTS
1.34 +
1.35 +// FORWARD DECLARATIONS
1.36 +class CUri8;
1.37 +class CSIPToHeader;
1.38 +class CSIPFromHeader;
1.39 +class CSIPContactHeader;
1.40 +class CSIPEventHeader;
1.41 +class CSIPMessageElements;
1.42 +class MSIPRegistrationContext;
1.43 +class CSIPConnection;
1.44 +
1.45 +// CLASS DECLARATION
1.46 +
1.47 +/**
1.48 +* @publishedAll
1.49 +* @released
1.50 +*
1.51 +* Class for managing SIP SUBSCRIBE dialog associations.
1.52 +* It provides services for creating, using and terminating SIP SUBSCRIBE
1.53 +* dialog associations. The client can have multiple SUBSRIBE dialog
1.54 +* associations per same SIP dialog.
1.55 +* Implementation handles SUBSCRIBE on the dialog level defined by Call-Id,
1.56 +* local and remote tags; "Event" header semantics are client's responsibility
1.57 +*
1.58 +* @lib sipclient.lib
1.59 +*/
1.60 +class CSIPSubscribeDialogAssoc : public CSIPDialogAssocBase
1.61 + {
1.62 + public: // Constructors and destructor
1.63 + /**
1.64 + * Two-phased constructor.
1.65 + * Should be used if response to the SIP request to be sent
1.66 + * will create a SIP dialog association.
1.67 + * @pre aEvent != 0
1.68 + * @param aDialog a dialog to be associated with
1.69 + * @param aEvent an event to subscribe to; the ownership is transferred
1.70 + * @return New object; the ownership is transferred
1.71 + * @leave KErrArgument if aEvent == 0
1.72 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.73 + * object has been deleted
1.74 + */
1.75 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.76 + NewL(CSIPDialog& aDialog,
1.77 + CSIPEventHeader* aEvent);
1.78 +
1.79 + /**
1.80 + * Two-phased constructor.
1.81 + * Must be used if response to the SIP request to be sent
1.82 + * will create a SIP dialog association.
1.83 + * @param aDialog a dialog to be associated with
1.84 + * @param aEvent an event to subscribe to; the ownership is transferred
1.85 + * @return New object, ownership is transferred
1.86 + * @leave KErrArgument if aEvent == 0
1.87 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.88 + * object has been deleted
1.89 + */
1.90 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.91 + NewLC(CSIPDialog& aDialog,
1.92 + CSIPEventHeader* aEvent);
1.93 +
1.94 + /**
1.95 + * Two-phased constructor
1.96 + * @pre aFrom != 0
1.97 + * @pre aRemoteUri != 0
1.98 + * @pre aEvent != 0
1.99 + * The user of the class must not define tags in From-header and
1.100 + * To-header.
1.101 + * @param aConnection a SIP connection to be used with
1.102 + * dialog association
1.103 + * @param aFrom originator's address; the ownership is transfered
1.104 + * @param aRemoteUri a remote target URI that identifies a resource that
1.105 + * the request is addressed to.
1.106 + * @param aEvent an event to subscribe to; the ownership is transferred
1.107 + * @param aTo logical recipient's address; if not defined
1.108 + * the remote target uri will be used for To-header
1.109 + * construction; the ownership is transfered
1.110 + * @param aContact a contact to be used in dialog creation. Must be
1.111 + * given only if user intends to re-direct future requests;
1.112 + * the ownership is transfered
1.113 + * @return New object; the ownership is transferred.
1.114 + * @leave KErrArgument if aFrom == 0, aRemoteUri == 0 or aEvent == 0
1.115 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.116 + * object has been deleted
1.117 + */
1.118 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.119 + NewL(CSIPConnection& aConnection,
1.120 + CSIPFromHeader* aFrom,
1.121 + CUri8* aRemoteUri,
1.122 + CSIPEventHeader* aEvent,
1.123 + CSIPToHeader* aTo=0,
1.124 + CSIPContactHeader* aContact=0);
1.125 +
1.126 + /**
1.127 + * Two-phased constructor
1.128 + * @pre aFrom != 0
1.129 + * @pre aRemoteUri != 0
1.130 + * @pre aEvent != 0
1.131 + * The user of the class must not define tags in From-header and
1.132 + * To-header.
1.133 + * @param aConnection a SIP connection to be used with
1.134 + * dialog association
1.135 + * @param aFrom originator's address; the ownership is transfered
1.136 + * @param aRemoteUri a remote target URI that identifies a resource that
1.137 + * the request is addressed to.
1.138 + * @param aEvent an event to subscribe to; the ownership is transferred
1.139 + * @param aTo logical recipient's address; if not defined
1.140 + * the remote target uri will be used for To-header
1.141 + * construction; the ownership is transfered
1.142 + * @param aContact a contact to be used in dialog creation. Must be
1.143 + * given only if user intends to re-direct future requests;
1.144 + * the ownership is transfered
1.145 + * @return New object; the ownership is transferred.
1.146 + * @leave KErrArgument if aFrom == 0, aRemoteUri == 0 or aEvent == 0
1.147 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.148 + * object has been deleted
1.149 + */
1.150 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.151 + NewLC(CSIPConnection& aConnection,
1.152 + CSIPFromHeader* aFrom,
1.153 + CUri8* aRemoteUri,
1.154 + CSIPEventHeader* aEvent,
1.155 + CSIPToHeader* aTo =0,
1.156 + CSIPContactHeader* aContact=0);
1.157 +
1.158 + /**
1.159 + * Two-phased constructor
1.160 + * @pre aRemoteUri != 0
1.161 + * @pre aEvent != 0
1.162 + * The user of the class must not define tags in From-header
1.163 + * and To-header.
1.164 + * @pre aContext.IsContextActive()==ETrue
1.165 + * @param aConnection a SIP connection to be used with
1.166 + * dialog association
1.167 + * @param aRemoteUri a remote target URI that identifies a resource that
1.168 + * the request is targeted to.
1.169 + * @param aContext used for selecting outbound
1.170 + * proxy and originator's address (AOR) and contact
1.171 + * @param aEvent an event to subscribe to; the ownership is transferred
1.172 + * @param aFrom originator's address. If not defined it will be
1.173 + * constructed using registration context (User's AOR);
1.174 + * the ownership is transfered
1.175 + * @param aTo logical recipient's address; if not defined
1.176 + * the remote target uri will be used for To-header
1.177 + * construction; the ownership is transfered
1.178 + * @param aContact a contact to be used in dialog creation. Must be
1.179 + * given only if user intends to re-direct future requests;
1.180 + * the ownership is transfered
1.181 + * @return New object; the ownership is transferred.
1.182 + * @leave KErrArgument if aRemoteUri == 0 or aEvent == 0
1.183 + * @leave KErrSIPInvalidRegistrationState
1.184 + * if aContext.IsContextActive()==EFalse
1.185 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.186 + * object has been deleted
1.187 + */
1.188 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.189 + NewL(CSIPConnection& aConnection,
1.190 + CUri8* aRemoteUri,
1.191 + const MSIPRegistrationContext& aContext,
1.192 + CSIPEventHeader* aEvent,
1.193 + CSIPFromHeader* aFrom = 0,
1.194 + CSIPToHeader* aTo = 0,
1.195 + CSIPContactHeader* aContact = 0);
1.196 +
1.197 + /**
1.198 + * Two-phased constructor
1.199 + * @pre aRemoteUri != 0
1.200 + * @pre aEvent != 0
1.201 + * The user of the class must not define tags in From-header
1.202 + * and To-header.
1.203 + * @pre aContext.IsContextActive()==ETrue
1.204 + * @param aConnection a SIP connection to be used with
1.205 + * dialog association
1.206 + * @param aRemoteUri a remote target URI that identifies a resource that
1.207 + * the request is targeted to.
1.208 + * @param aContext used for selecting outbound
1.209 + * proxy and originator's address (AOR) and contact
1.210 + * @param aEvent an event to subscribe to; the ownership is transferred
1.211 + * @param aFrom originator's address. If not defined it will be
1.212 + * constructed using registration context (User's AOR);
1.213 + * the ownership is transfered
1.214 + * @param aTo logical recipient's address; if not defined
1.215 + * the remote target uri will be used for To-header
1.216 + * construction; the ownership is transfered
1.217 + * @param aContact a contact to be used in dialog creation. Must be
1.218 + * given only if user intends to re-direct future requests;
1.219 + * the ownership is transfered
1.220 + * @return New object; the ownership is transferred.
1.221 + * @leave KErrArgument if aRemoteUri == 0 or aEvent == 0
1.222 + * @leave KErrSIPInvalidRegistrationState
1.223 + * if aContext.IsContextActive()==EFalse
1.224 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.225 + * object has been deleted
1.226 + */
1.227 + IMPORT_C static CSIPSubscribeDialogAssoc*
1.228 + NewLC(CSIPConnection& aConnection,
1.229 + CUri8* aRemoteUri,
1.230 + const MSIPRegistrationContext& aContext,
1.231 + CSIPEventHeader* aEvent,
1.232 + CSIPFromHeader* aFrom = 0,
1.233 + CSIPToHeader* aTo = 0,
1.234 + CSIPContactHeader* aContact = 0);
1.235 +
1.236 + /**
1.237 + * Destructor
1.238 + */
1.239 + IMPORT_C ~CSIPSubscribeDialogAssoc();
1.240 +
1.241 + public: //New functions
1.242 + /**
1.243 + * Creates SUBSCRIBE and sends it to the remote target.
1.244 + * 101-199 or 2xx response to SUBSCRIBE will create a dialog association
1.245 + * in case of the first SUBSCRIBE request within this dialog.
1.246 + * Client must not provide Event-header in the optional message headers.
1.247 + *
1.248 + * @pre Dialog().Connection().State()==EActive
1.249 + * @pre Dialog().State()==CSIPDialog::EInit ||
1.250 + * Dialog().State()==CSIPDialog::EConfirmed
1.251 + * @param aElements optional SIP message headers and body. Ownership is
1.252 + * transferred.
1.253 + * @param aRefresh if set the transaction will be refreshed at given
1.254 + * interval. Interval must be defined by including
1.255 + * Expires-header. Ownership is transferred.
1.256 + * @return SUBSCRIBE SIP transaction. Ownership is transferred.
1.257 + * @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
1.258 + * @capability NetworkServices
1.259 + */
1.260 + IMPORT_C CSIPClientTransaction*
1.261 + SendSubscribeL(CSIPMessageElements* aElements=0,
1.262 + CSIPRefresh* aRefresh=0);
1.263 +
1.264 + /**
1.265 + * Updates the subscription. Note that update can be done when 2xx
1.266 + * response is received to the initial SUBSCRIBE or to update.
1.267 + * Client must not provide Event-header in the optional message headers.
1.268 + * @pre aElements != 0
1.269 + * @pre Dialog().Connection().State()==EActive
1.270 + * Dialog().State()==CSIPDialog::EConfirmed
1.271 + * @param aElements contains user SIP headers and content; the ownership
1.272 + * is transferred
1.273 + * @return SUBSCRIBE SIP client transaction; the ownership is transferred
1.274 + * @leave KErrArgument if aElements == 0 or aElements contain
1.275 + * Event-header
1.276 + * @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
1.277 + * @capability NetworkServices
1.278 + */
1.279 + IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements);
1.280 +
1.281 + /**
1.282 + * Creates (un)SUBSCRIBE and sends it to the remote target.
1.283 + * Possible associated refresh will be terminated as well.
1.284 + * Client must not provide Event-header in the optional message headers.
1.285 + * @pre Dialog().Connection().State()==EActive
1.286 + * @pre Dialog().State()==CSIPDialog::EConfirmed
1.287 + * @param aElements optional SIP message headers and body. Ownership is
1.288 + * transferred.
1.289 + * @return SUBSCRIBE SIP transaction. Ownership is transferred.
1.290 + * @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
1.291 + * @capability NetworkServices
1.292 + */
1.293 + IMPORT_C CSIPClientTransaction*
1.294 + SendUnsubscribeL(CSIPMessageElements* aElements=0);
1.295 +
1.296 + /**
1.297 + * Gets associated refresh in case the user has requested
1.298 + * the refresh of the SIP subscription.
1.299 + * Note that refreshed SUBSCRIBE dialog association cannot be
1.300 + * terminated nor updated using the returned object.
1.301 + * @return Associated refresh or 0 pointer if the user has not requested
1.302 + * a refresh. Ownership is not transferred.
1.303 + */
1.304 + IMPORT_C const CSIPRefresh* SIPRefresh() const;
1.305 +
1.306 + /**
1.307 + * Gets an event to which the subscription is done
1.308 + * @return an event
1.309 + */
1.310 + IMPORT_C const CSIPEventHeader& Event() const;
1.311 +
1.312 + public: // New functions, for internal use
1.313 +
1.314 + /**
1.315 + * @internalComponent
1.316 + */
1.317 + CSIPRefresh* FindRefresh(TUint32 aRefreshId);
1.318 +
1.319 + static CSIPSubscribeDialogAssoc* NewLC(CSIPConnection& aConnection,
1.320 + CUri8* aRemoteUri,
1.321 + CSIPEventHeader* aEvent,
1.322 + CSIPFromHeader* aFrom,
1.323 + CSIPToHeader* aTo,
1.324 + CSIPContactHeader* aContact,
1.325 + const MSIPRegistrationContext* aContext);
1.326 +
1.327 + void ConnectionLost();
1.328 +
1.329 + CSIPClientTransaction*
1.330 + DoSendSubscribeL(CSIPMessageElements* aElements,
1.331 + CSIPRefresh* aRefresh,
1.332 + TBool aWithinDialog);
1.333 +
1.334 + CSIPClientTransaction*
1.335 + DoSendUnsubscribeL(CSIPMessageElements* aElements);
1.336 +
1.337 + /**
1.338 + * @internalComponent
1.339 + */
1.340 + void DeletingRefresh(CSIPRefresh& aRefresh, TUint32 aRefreshId);
1.341 +
1.342 + private: // Constructors
1.343 + CSIPSubscribeDialogAssoc();
1.344 +
1.345 + private: // Data
1.346 + //If the subscription is refreshed, this is the used CSIPRefresh
1.347 + //instance, otherwise this is NULL. CSIPSubscribeDialogAssoc owns this.
1.348 + CSIPRefresh* iRefresh;
1.349 +
1.350 + CSIPEventHeader* iEvent;
1.351 +
1.352 + private: // For testing purposes
1.353 + UNIT_TEST(CSIP_Test)
1.354 + UNIT_TEST(CSIPSubscribeDialogAssoc_Test)
1.355 + };
1.356 +
1.357 +#endif