epoc32/include/mw/siprefresh.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/siprefresh.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,250 @@
     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        : siprefresh.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 +
    1.28 +#ifndef CSIPREFRESH_H
    1.29 +#define CSIPREFRESH_H
    1.30 +
    1.31 +// INCLUDES
    1.32 +#include <e32base.h>
    1.33 +#include <stringpool.h>
    1.34 +#include "_sipcodecdefs.h"
    1.35 +
    1.36 +// FORWARD DECLARATIONS
    1.37 +class CSIPClientTransaction;
    1.38 +class CSIPMessageElements;
    1.39 +class MSIPRefreshAssociation;
    1.40 +
    1.41 +// CLASS DECLARATION
    1.42 +
    1.43 +/**
    1.44 +*  @publishedAll
    1.45 +*  @released
    1.46 +*
    1.47 +*  Class for managing SIP refresh.
    1.48 +*  It provides functions for getting associated sip transaction
    1.49 +*  and state. Class also provides functions for updating and terminating 
    1.50 +*  stand-alone refreshes.
    1.51 +*
    1.52 +*  Note that only stand-alone refreshes (i.e. refreshes that are not associated
    1.53 +*  with registration binding or dialog associations) can be terminated or
    1.54 +*  updated using functions defined in this class.
    1.55 +*
    1.56 +*  @lib sipclient.lib
    1.57 +*/
    1.58 +class CSIPRefresh: public CBase
    1.59 +	{
    1.60 +	public:
    1.61 +
    1.62 +		/** SIP refresh states */
    1.63 +		enum TState
    1.64 +			{
    1.65 +			/** SIP refresh is inactive */
    1.66 +			EInactive,
    1.67 +			/** SIP refresh active */
    1.68 +			EActive,
    1.69 +			/** SIP refresh is terminated */
    1.70 +			ETerminated,
    1.71 +			/** Object is being constructed and is not yet ready for use */
    1.72 +			EConstructing
    1.73 +			};
    1.74 +
    1.75 +	public: // Constructors and destructor
    1.76 +
    1.77 +		/**
    1.78 +		* Two-phased constructor
    1.79 +        * @return New object. Ownership is transferred.
    1.80 +		*/
    1.81 +		IMPORT_C static CSIPRefresh* NewL();
    1.82 +
    1.83 +		/**
    1.84 +		* Two-phased constructor
    1.85 +        * @return New object. Ownership is transferred.
    1.86 +		*/
    1.87 +		IMPORT_C static CSIPRefresh* NewLC();
    1.88 +
    1.89 +		/**
    1.90 +		* Destructor
    1.91 +		*/
    1.92 +		IMPORT_C ~CSIPRefresh();
    1.93 +
    1.94 +	public: // New functions
    1.95 +
    1.96 +		/**
    1.97 +		* Gets the state of the refresh
    1.98 +		* @return refresh state
    1.99 +		*/
   1.100 +        IMPORT_C CSIPRefresh::TState State() const;
   1.101 +
   1.102 +		/**
   1.103 +		* Tests if the refresh is a stand-alone refresh
   1.104 +		* @return ETrue if refresh is a stand-alone; EFalse otherwise
   1.105 +		*/
   1.106 +		IMPORT_C TBool IsStandAlone() const;
   1.107 +		
   1.108 +		/**
   1.109 +		* Gets the associated SIP transaction with this refresh.
   1.110 +        *
   1.111 +		* @return Associated SIP transaction or 0-pointer. Ownership is not
   1.112 +        *   transferred.
   1.113 +		*/
   1.114 +		IMPORT_C const CSIPClientTransaction* SIPTransaction() const;
   1.115 +
   1.116 +		/**
   1.117 +		* Terminates the refresh by sending SIP request to the remote
   1.118 +        * destination. The new client transactation will be of the same type
   1.119 +        * as the first transaction associated with this request.
   1.120 +		* @pre State()==EActive
   1.121 +		* @pre IsStandAlone()==ETrue
   1.122 +		* @param aElements contains optional SIP message headers and body.
   1.123 +        *   Ownership is transferred.
   1.124 +		* @return SIP client transaction. Ownership is transferred.
   1.125 +		* @leave KErrSIPInvalidTransactionState if State() is not EActive
   1.126 +		*		 KErrNotFound if the CSIPRefresh is no longer associated to
   1.127 +        *        anything
   1.128 +        *        KSIPErrInvalidRegistrationState if trying to terminate a
   1.129 +        *        REGISTER refresh.
   1.130 +        *        KErrSIPInvalidDialogState if trying to terminate a dialog
   1.131 +        *		 association being refreshed. 
   1.132 +        * @capability NetworkServices
   1.133 +		*/
   1.134 +		IMPORT_C CSIPClientTransaction*
   1.135 +            TerminateL(CSIPMessageElements* aElements=0);
   1.136 +
   1.137 +		/**
   1.138 +		* Updates the refresh by sending SIP request to the remote destination.
   1.139 +        * The new client transactation will be of the same type as the first
   1.140 +        * transaction associated with this request.
   1.141 +		* @pre State()==EActive
   1.142 +		* @pre IsStandAlone()==ETrue
   1.143 +		* @param aElements contains optional SIP message headers and body.
   1.144 +        *   Ownership is transferred.
   1.145 +		* @return SIP client transaction. Ownership is transferred.
   1.146 +        * @leave KErrSIPInvalidTransactionState if State() is not EActive
   1.147 +		*		 KErrNotFound if the CSIPRefresh is no longer associated to
   1.148 +        *        anything
   1.149 +        *        KErrSIPInvalidRegistrationState if trying to update a
   1.150 +        *        REGISTER refresh. 
   1.151 +        *        KSIPErrInvalidDialogState if trying to update a
   1.152 +        *        dialog association being refreshed. 
   1.153 +        * @capability NetworkServices
   1.154 +		*/
   1.155 +		IMPORT_C CSIPClientTransaction*
   1.156 +            UpdateL(CSIPMessageElements* aElements=0);
   1.157 +
   1.158 +		/**
   1.159 +		* Compares this object to another object 
   1.160 +		* @param aRefresh a CSIPRefresh type object to compare
   1.161 +		* @return ETrue if the objects are equal otherwise EFalse
   1.162 +		*/
   1.163 +	    IMPORT_C TBool operator==(const CSIPRefresh& aRefresh) const;
   1.164 +
   1.165 +		/**
   1.166 +		* Gets current refresh interval
   1.167 +		* @pre State()==CSIPRefresh::EActive
   1.168 +		* @return current refresh interval in seconds
   1.169 +		* @leave KErrSIPInvalidTransactionState if State() is not EActive
   1.170 +		* @leave KErrSIPResourceNotAvailable if SIP server can't be contacted
   1.171 +		*	because a required resource has been deleted.		
   1.172 +		*/
   1.173 +		IMPORT_C TUint IntervalL() const;
   1.174 +
   1.175 +		/**
   1.176 +		* Sets refresh interval. 
   1.177 +		* Note that SIP server choses the refresh interval. This function should
   1.178 +		* be used only if SIP server has indicated new refresh interval using
   1.179 +		* SIP messages that are not associated to the refresh needing the update.
   1.180 +		* @pre State()==CSIPRefresh::EActive
   1.181 +		* @pre aInterval > 0
   1.182 +		* @param aInterval a new interval in seconds
   1.183 +		* @leave KErrArgument if aInterval == 0
   1.184 +		* @leave KErrSIPInvalidTransactionState if State() is not EActive
   1.185 +		* @leave KErrSIPResourceNotAvailable if SIP server can't be contacted
   1.186 +		*	because a required resource has been deleted.
   1.187 +		*/
   1.188 +		IMPORT_C void SetIntervalL(TUint aInterval);
   1.189 +
   1.190 +	public: // New functions, for internal use
   1.191 +
   1.192 +	    TBool DoesMatch(TUint32 aRefreshId) const;
   1.193 +
   1.194 +        /**
   1.195 +		* Associate the CSIPRefresh with another object.
   1.196 +		* @param aAssoc Object associated with the CSIPRefresh
   1.197 +		* @return ETrue if the objects are equal otherwise EFalse
   1.198 +		*/
   1.199 +        void SetRefreshOwner(MSIPRefreshAssociation& aAssoc);
   1.200 +
   1.201 +        void RemoveRefreshOwner(const MSIPRefreshAssociation& aAssoc);
   1.202 +
   1.203 +        void ChangeState(CSIPRefresh::TState aNextState);
   1.204 +
   1.205 +        void UpdateRefreshState(TUint aStatusCode);
   1.206 +
   1.207 +        TUint32 RefreshId() const;
   1.208 +
   1.209 +        void SetRefreshIdIfEmpty(TUint32 aRefreshId);        
   1.210 +
   1.211 +        RStringF RequestType() const;
   1.212 +
   1.213 +        void SetRequestType(RStringF aType);
   1.214 +
   1.215 +        void AddTransaction(CSIPClientTransaction& aTransaction);
   1.216 +
   1.217 +        void RemoveTransaction();
   1.218 +
   1.219 +        CSIPClientTransaction* Transaction();
   1.220 +
   1.221 +	private: // Constructors
   1.222 +
   1.223 +		CSIPRefresh();
   1.224 +
   1.225 +		void ConstructL();
   1.226 +
   1.227 +	private:
   1.228 +
   1.229 +		void CheckStateL() const;
   1.230 +		
   1.231 +	private: // Data
   1.232 +
   1.233 +        MSIPRefreshAssociation* iOwner;
   1.234 +
   1.235 +        //Client transaction which is refreshed, not owned by CSIPRefresh.        
   1.236 +        CSIPClientTransaction* iClientTransaction;
   1.237 +
   1.238 +		//Current state of the refresh
   1.239 +        TState iState;
   1.240 +
   1.241 +        //RefreshId received from SIP client        
   1.242 +        TUint32 iRefreshId;
   1.243 +
   1.244 +        //Identifies the request method which is being refreshed
   1.245 +        RStringF iRequestType;
   1.246 +
   1.247 +	private: // For testing purposes
   1.248 +
   1.249 +	    UNIT_TEST(CSIP_Test)
   1.250 +        UNIT_TEST(CSIPConnection_Test)
   1.251 +	};
   1.252 +
   1.253 +#endif