epoc32/include/mw/sipsubscribedialogassoc.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * Name        : sipsubscribedialogassoc.h
    16 * Part of     : SIP Client
    17 * Interface   : SDK API, SIP Client API
    18 * Version     : 1.0
    19 *
    20 */
    21 
    22 
    23 
    24 #ifndef CSIPSUBSCRIBEDIALOGASSOC_H
    25 #define CSIPSUBSCRIBEDIALOGASSOC_H
    26 
    27 // INCLUDES
    28 #include "sipdialogassocbase.h"
    29 
    30 // CONSTANTS
    31 
    32 // FORWARD DECLARATIONS
    33 class CUri8;
    34 class CSIPToHeader;
    35 class CSIPFromHeader;
    36 class CSIPContactHeader;
    37 class CSIPEventHeader;
    38 class CSIPMessageElements;
    39 class MSIPRegistrationContext;
    40 class CSIPConnection;
    41 
    42 // CLASS DECLARATION
    43 
    44 /** 
    45 * @publishedAll
    46 * @released
    47 *
    48 * Class for managing SIP SUBSCRIBE dialog associations.
    49 * It provides services for creating, using and terminating SIP SUBSCRIBE
    50 * dialog associations. The client can have multiple SUBSRIBE dialog 
    51 * associations per same SIP dialog.
    52 * Implementation handles SUBSCRIBE on the dialog level defined by Call-Id,
    53 * local and remote tags; "Event" header semantics are client's responsibility
    54 * 
    55 * @lib sipclient.lib
    56 */
    57 class CSIPSubscribeDialogAssoc : public CSIPDialogAssocBase    
    58 	{
    59 	public: // Constructors and destructor
    60 		/**
    61 		* Two-phased constructor.
    62 		* Should be used if response to the SIP request to be sent
    63 		* will create a SIP dialog association.
    64 		* @pre aEvent != 0
    65 		* @param aDialog a dialog to be associated with
    66 		* @param aEvent an event to subscribe to; the ownership is transferred
    67         * @return New object; the ownership is transferred
    68         * @leave KErrArgument if aEvent == 0
    69         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
    70 		*	object has been deleted
    71 		*/
    72 		IMPORT_C static CSIPSubscribeDialogAssoc*
    73 			NewL(CSIPDialog& aDialog,
    74 				 CSIPEventHeader* aEvent);
    75 
    76 		/**
    77 		* Two-phased constructor.
    78 		* Must be used if response to the SIP request to be sent
    79 		* will create a SIP dialog association.
    80 		* @param aDialog a dialog to be associated with
    81 		* @param aEvent an event to subscribe to; the ownership is transferred
    82         * @return New object, ownership is transferred
    83         * @leave KErrArgument if aEvent == 0
    84         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
    85 		*	object has been deleted
    86 		*/
    87 		IMPORT_C static CSIPSubscribeDialogAssoc*
    88 			NewLC(CSIPDialog& aDialog,
    89 				  CSIPEventHeader* aEvent);
    90 
    91         /**
    92         * Two-phased constructor
    93         * @pre aFrom != 0 
    94 		* @pre aRemoteUri != 0
    95 		* @pre aEvent != 0
    96 		* The user of the class must not define tags in From-header and
    97 		* To-header.
    98         * @param aConnection a SIP connection to be used with
    99         *        dialog association
   100         * @param aFrom originator's address; the ownership is transfered
   101         * @param aRemoteUri a remote target URI that identifies a resource that
   102         *		 the request is addressed to.
   103 		* @param aEvent an event to subscribe to; the ownership is transferred
   104         * @param aTo logical recipient's address; if not defined
   105         *        the remote target uri will be used for To-header
   106         *        construction; the ownership is transfered
   107         * @param aContact a contact to be used in dialog creation. Must be
   108         *        given only if user intends to re-direct future requests; 
   109         *        the ownership is transfered
   110         * @return New object; the ownership is transferred.
   111         * @leave KErrArgument if aFrom == 0, aRemoteUri == 0 or aEvent == 0
   112         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
   113 		*	object has been deleted
   114         */
   115         IMPORT_C static CSIPSubscribeDialogAssoc*
   116             NewL(CSIPConnection& aConnection,
   117                  CSIPFromHeader* aFrom,
   118 				 CUri8* aRemoteUri,
   119 				 CSIPEventHeader* aEvent,
   120                  CSIPToHeader* aTo=0,
   121                  CSIPContactHeader* aContact=0);
   122 
   123         /**
   124         * Two-phased constructor
   125         * @pre aFrom != 0 
   126 		* @pre aRemoteUri != 0
   127 		* @pre aEvent != 0
   128 		* The user of the class must not define tags in From-header and
   129 		* To-header.
   130         * @param aConnection a SIP connection to be used with
   131         *        dialog association
   132         * @param aFrom originator's address; the ownership is transfered
   133         * @param aRemoteUri a remote target URI that identifies a resource that
   134         *		 the request is addressed to.
   135 		* @param aEvent an event to subscribe to; the ownership is transferred
   136         * @param aTo logical recipient's address; if not defined
   137         *        the remote target uri will be used for To-header
   138         *        construction; the ownership is transfered
   139         * @param aContact a contact to be used in dialog creation. Must be
   140         *        given only if user intends to re-direct future requests; 
   141         *        the ownership is transfered
   142         * @return New object; the ownership is transferred.
   143         * @leave KErrArgument if aFrom == 0, aRemoteUri == 0 or aEvent == 0
   144         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
   145 		*	object has been deleted
   146         */
   147         IMPORT_C static CSIPSubscribeDialogAssoc*
   148             NewLC(CSIPConnection& aConnection,
   149                   CSIPFromHeader* aFrom,
   150 				  CUri8* aRemoteUri,
   151 				  CSIPEventHeader* aEvent,
   152                   CSIPToHeader* aTo =0,                 
   153                   CSIPContactHeader* aContact=0);
   154         
   155         /**
   156         * Two-phased constructor
   157 		* @pre aRemoteUri != 0
   158 		* @pre aEvent != 0
   159 		* The user of the class must not define tags in From-header
   160 		* and To-header.
   161         * @pre aContext.IsContextActive()==ETrue
   162         * @param aConnection a SIP connection to be used with
   163         *        dialog association 
   164         * @param aRemoteUri a remote target URI that identifies a resource that
   165         *		 the request is targeted to.
   166         * @param aContext used for selecting outbound 
   167         *        proxy and originator's address (AOR) and contact		
   168         * @param aEvent an event to subscribe to; the ownership is transferred
   169         * @param aFrom originator's address. If not defined it will be
   170         *        constructed using registration context (User's AOR);
   171         *        the ownership is transfered
   172         * @param aTo logical recipient's address; if not defined
   173         *        the remote target uri will be used for To-header
   174         *        construction; the ownership is transfered
   175         * @param aContact a contact to be used in dialog creation. Must be
   176         *        given only if user intends to re-direct future requests; 
   177         *        the ownership is transfered
   178         * @return New object; the ownership is transferred.
   179         * @leave KErrArgument if aRemoteUri == 0 or aEvent == 0
   180         * @leave KErrSIPInvalidRegistrationState
   181         *        if aContext.IsContextActive()==EFalse
   182         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
   183 		*	object has been deleted
   184         */
   185         IMPORT_C static CSIPSubscribeDialogAssoc*
   186             NewL(CSIPConnection& aConnection,                                    
   187                  CUri8* aRemoteUri,
   188                  const MSIPRegistrationContext& aContext,
   189                  CSIPEventHeader* aEvent,
   190                  CSIPFromHeader* aFrom = 0,
   191 	             CSIPToHeader* aTo = 0,
   192 	             CSIPContactHeader* aContact = 0);
   193 
   194        /**
   195         * Two-phased constructor        
   196 		* @pre aRemoteUri != 0
   197 		* @pre aEvent != 0
   198 		* The user of the class must not define tags in From-header
   199 		* and To-header.
   200         * @pre aContext.IsContextActive()==ETrue
   201         * @param aConnection a SIP connection to be used with
   202         *        dialog association 
   203         * @param aRemoteUri a remote target URI that identifies a resource that
   204         *		 the request is targeted to.
   205         * @param aContext used for selecting outbound 
   206         *        proxy and originator's address (AOR) and contact
   207         * @param aEvent an event to subscribe to; the ownership is transferred
   208         * @param aFrom originator's address. If not defined it will be
   209         *        constructed using registration context (User's AOR);
   210         *        the ownership is transfered
   211         * @param aTo logical recipient's address; if not defined
   212         *        the remote target uri will be used for To-header
   213         *        construction; the ownership is transfered
   214         * @param aContact a contact to be used in dialog creation. Must be
   215         *        given only if user intends to re-direct future requests; 
   216         *        the ownership is transfered
   217         * @return New object; the ownership is transferred.
   218         * @leave KErrArgument if aRemoteUri == 0 or aEvent == 0
   219         * @leave KErrSIPInvalidRegistrationState
   220         *        if aContext.IsContextActive()==EFalse
   221         * @leave KErrSIPResourceNotAvailable if a required SIP Client API
   222 		*	object has been deleted
   223         */
   224         IMPORT_C static CSIPSubscribeDialogAssoc*
   225             NewLC(CSIPConnection& aConnection,                                    
   226                   CUri8* aRemoteUri,
   227                   const MSIPRegistrationContext& aContext,
   228                   CSIPEventHeader* aEvent,
   229                   CSIPFromHeader* aFrom = 0,
   230 	              CSIPToHeader* aTo = 0,
   231 	              CSIPContactHeader* aContact = 0);
   232 
   233 		/**
   234 		* Destructor
   235 		*/
   236 		IMPORT_C ~CSIPSubscribeDialogAssoc();
   237 
   238 	public: //New functions
   239 		/**
   240 		* Creates SUBSCRIBE and sends it to the remote target.		
   241 		* 101-199 or 2xx response to SUBSCRIBE will create a dialog association
   242 		* in case of the first SUBSCRIBE request within this dialog.
   243 		* Client must not provide Event-header in the optional message headers.
   244         *
   245 		* @pre Dialog().Connection().State()==EActive
   246 		* @pre Dialog().State()==CSIPDialog::EInit ||
   247 		*      Dialog().State()==CSIPDialog::EConfirmed
   248 		* @param aElements optional SIP message headers and body. Ownership is
   249         *   transferred.
   250 		* @param aRefresh if set the transaction will be refreshed at given
   251 		*                 interval. Interval must be defined by including
   252 		*                 Expires-header. Ownership is transferred.
   253 		* @return SUBSCRIBE SIP transaction. Ownership is transferred.
   254 		* @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
   255 		* @capability NetworkServices
   256 		*/
   257 		IMPORT_C CSIPClientTransaction*
   258             SendSubscribeL(CSIPMessageElements* aElements=0,
   259 						   CSIPRefresh* aRefresh=0);
   260 
   261 		/**
   262         * Updates the subscription. Note that update can be done when 2xx
   263         * response is received to the initial SUBSCRIBE or to update.
   264         * Client must not provide Event-header in the optional message headers.
   265         * @pre aElements != 0
   266  		* @pre Dialog().Connection().State()==EActive
   267 		*      Dialog().State()==CSIPDialog::EConfirmed       
   268         * @param aElements contains user SIP headers and content; the ownership
   269         *		 is transferred
   270         * @return SUBSCRIBE SIP client transaction; the ownership is transferred
   271         * @leave KErrArgument if aElements == 0 or aElements contain
   272         *	Event-header
   273         * @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
   274         * @capability NetworkServices
   275         */            			   
   276         IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements);
   277         
   278 		/**
   279 		* Creates (un)SUBSCRIBE and sends it to the remote target.
   280 		* Possible associated refresh will be terminated as well.
   281 		* Client must not provide Event-header in the optional message headers.
   282 		* @pre Dialog().Connection().State()==EActive
   283 		* @pre Dialog().State()==CSIPDialog::EConfirmed
   284 		* @param aElements optional SIP message headers and body. Ownership is
   285         *   transferred.
   286 		* @return SUBSCRIBE SIP transaction. Ownership is transferred.
   287 		* @leave KErrSIPInvalidDialogState if Dialog().State() is incorrect
   288 		* @capability NetworkServices
   289 		*/
   290 		IMPORT_C CSIPClientTransaction*
   291             SendUnsubscribeL(CSIPMessageElements* aElements=0);
   292 
   293 		/**
   294 		* Gets associated refresh in case the user has requested
   295 		* the refresh of the SIP subscription.
   296 		* Note that refreshed SUBSCRIBE dialog association cannot be
   297 		* terminated nor updated using the returned object.
   298 		* @return Associated refresh or 0 pointer if the user has not requested
   299         *   a refresh. Ownership is not transferred.
   300 		*/
   301 		IMPORT_C const CSIPRefresh* SIPRefresh() const;
   302 
   303 		/**
   304 		* Gets an event to which the subscription is done
   305 		* @return an event
   306 		*/
   307 		IMPORT_C const CSIPEventHeader& Event() const;    
   308 
   309 	public: // New functions, for internal use
   310         
   311         /**
   312         * @internalComponent
   313         */        
   314         CSIPRefresh* FindRefresh(TUint32 aRefreshId);
   315         
   316         static CSIPSubscribeDialogAssoc* NewLC(CSIPConnection& aConnection,
   317 								CUri8* aRemoteUri,
   318 								CSIPEventHeader* aEvent,
   319                                 CSIPFromHeader* aFrom,
   320                                 CSIPToHeader* aTo,
   321 			                    CSIPContactHeader* aContact,
   322 			                    const MSIPRegistrationContext* aContext);
   323 
   324         void ConnectionLost();
   325 
   326         CSIPClientTransaction*
   327             DoSendSubscribeL(CSIPMessageElements* aElements,
   328                              CSIPRefresh* aRefresh,
   329                              TBool aWithinDialog);        
   330 
   331         CSIPClientTransaction* 
   332             DoSendUnsubscribeL(CSIPMessageElements* aElements);
   333 
   334         /**
   335         * @internalComponent
   336         */            
   337         void DeletingRefresh(CSIPRefresh& aRefresh, TUint32 aRefreshId);
   338 
   339  	private: // Constructors
   340         CSIPSubscribeDialogAssoc();
   341 
   342     private: // Data
   343         //If the subscription is refreshed, this is the used CSIPRefresh
   344         //instance, otherwise this is NULL. CSIPSubscribeDialogAssoc owns this.
   345         CSIPRefresh* iRefresh;
   346 
   347         CSIPEventHeader* iEvent;
   348 
   349 	private: // For testing purposes
   350 #ifdef CPPUNIT_TEST
   351         friend class CSIP_Test;
   352         friend class CSIPSubscribeDialogAssoc_Test;
   353 #endif
   354 	};
   355 
   356 #endif