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