realtimenetprots/sipfw/SIP/sipapi/api/siprefresh.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     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        : siprefresh.h
       
    16 * Part of     : SIP Client
       
    17 * Interface   : SDK API, SIP Client API
       
    18 * Version     : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CSIPREFRESH_H
       
    26 #define CSIPREFRESH_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <e32base.h>
       
    30 #include <stringpool.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CSIPClientTransaction;
       
    34 class CSIPMessageElements;
       
    35 class MSIPRefreshAssociation;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  @publishedAll
       
    41 *  @released
       
    42 *
       
    43 *  Class for managing SIP refresh.
       
    44 *  It provides functions for getting associated sip transaction
       
    45 *  and state. Class also provides functions for updating and terminating 
       
    46 *  stand-alone refreshes.
       
    47 *
       
    48 *  Note that only stand-alone refreshes (i.e. refreshes that are not associated
       
    49 *  with registration binding or dialog associations) can be terminated or
       
    50 *  updated using functions defined in this class.
       
    51 *
       
    52 *  @lib sipclient.lib
       
    53 */
       
    54 class CSIPRefresh: public CBase
       
    55 	{
       
    56 	public:
       
    57 
       
    58 		/** SIP refresh states */
       
    59 		enum TState
       
    60 			{
       
    61 			/** SIP refresh is inactive */
       
    62 			EInactive,
       
    63 			/** SIP refresh active */
       
    64 			EActive,
       
    65 			/** SIP refresh is terminated */
       
    66 			ETerminated,
       
    67 			/** Object is being constructed and is not yet ready for use */
       
    68 			EConstructing
       
    69 			};
       
    70 
       
    71 	public: // Constructors and destructor
       
    72 
       
    73 		/**
       
    74 		* Two-phased constructor
       
    75         * @return New object. Ownership is transferred.
       
    76 		*/
       
    77 		IMPORT_C static CSIPRefresh* NewL();
       
    78 
       
    79 		/**
       
    80 		* Two-phased constructor
       
    81         * @return New object. Ownership is transferred.
       
    82 		*/
       
    83 		IMPORT_C static CSIPRefresh* NewLC();
       
    84 
       
    85 		/**
       
    86 		* Destructor
       
    87 		*/
       
    88 		IMPORT_C ~CSIPRefresh();
       
    89 
       
    90 	public: // New functions
       
    91 
       
    92 		/**
       
    93 		* Gets the state of the refresh
       
    94 		* @return refresh state
       
    95 		*/
       
    96         IMPORT_C CSIPRefresh::TState State() const;
       
    97 
       
    98 		/**
       
    99 		* Tests if the refresh is a stand-alone refresh
       
   100 		* @return ETrue if refresh is a stand-alone; EFalse otherwise
       
   101 		*/
       
   102 		IMPORT_C TBool IsStandAlone() const;
       
   103 		
       
   104 		/**
       
   105 		* Gets the associated SIP transaction with this refresh.
       
   106         *
       
   107 		* @return Associated SIP transaction or 0-pointer. Ownership is not
       
   108         *   transferred.
       
   109 		*/
       
   110 		IMPORT_C const CSIPClientTransaction* SIPTransaction() const;
       
   111 
       
   112 		/**
       
   113 		* Terminates the refresh by sending SIP request to the remote
       
   114         * destination. The new client transactation will be of the same type
       
   115         * as the first transaction associated with this request.
       
   116 		* @pre State()==EActive
       
   117 		* @pre IsStandAlone()==ETrue
       
   118 		* @param aElements contains optional SIP message headers and body.
       
   119         *   Ownership is transferred.
       
   120 		* @return SIP client transaction. Ownership is transferred.
       
   121 		* @leave KErrSIPInvalidTransactionState if State() is not EActive
       
   122 		*		 KErrNotFound if the CSIPRefresh is no longer associated to
       
   123         *        anything
       
   124         *        KSIPErrInvalidRegistrationState if trying to terminate a
       
   125         *        REGISTER refresh.
       
   126         *        KErrSIPInvalidDialogState if trying to terminate a dialog
       
   127         *		 association being refreshed. 
       
   128         * @capability NetworkServices
       
   129 		*/
       
   130 		IMPORT_C CSIPClientTransaction*
       
   131             TerminateL(CSIPMessageElements* aElements=0);
       
   132 
       
   133 		/**
       
   134 		* Updates the refresh by sending SIP request to the remote destination.
       
   135         * The new client transactation will be of the same type as the first
       
   136         * transaction associated with this request.
       
   137 		* @pre State()==EActive
       
   138 		* @pre IsStandAlone()==ETrue
       
   139 		* @param aElements contains optional SIP message headers and body.
       
   140         *   Ownership is transferred.
       
   141 		* @return SIP client transaction. Ownership is transferred.
       
   142         * @leave KErrSIPInvalidTransactionState if State() is not EActive
       
   143 		*		 KErrNotFound if the CSIPRefresh is no longer associated to
       
   144         *        anything
       
   145         *        KErrSIPInvalidRegistrationState if trying to update a
       
   146         *        REGISTER refresh. 
       
   147         *        KSIPErrInvalidDialogState if trying to update a
       
   148         *        dialog association being refreshed. 
       
   149         * @capability NetworkServices
       
   150 		*/
       
   151 		IMPORT_C CSIPClientTransaction*
       
   152             UpdateL(CSIPMessageElements* aElements=0);
       
   153 
       
   154 		/**
       
   155 		* Compares this object to another object 
       
   156 		* @param aRefresh a CSIPRefresh type object to compare
       
   157 		* @return ETrue if the objects are equal otherwise EFalse
       
   158 		*/
       
   159 	    IMPORT_C TBool operator==(const CSIPRefresh& aRefresh) const;
       
   160 
       
   161 		/**
       
   162 		* Gets current refresh interval
       
   163 		* @pre State()==CSIPRefresh::EActive
       
   164 		* @return current refresh interval in seconds
       
   165 		* @leave KErrSIPResourceNotAvailable if SIP server can't be contacted
       
   166 		*	because a required resource has been deleted.		
       
   167 		*/
       
   168 		IMPORT_C TUint IntervalL() const;
       
   169 
       
   170 		/**
       
   171 		* Sets refresh interval. 
       
   172 		* Note that SIP server choses the refresh interval. This function should
       
   173 		* be used only if SIP server has indicated new refresh interval using
       
   174 		* SIP messages that are not associated to the refresh needing the update.
       
   175 		* @pre State()==CSIPRefresh::EActive
       
   176 		* @pre aInterval > 0
       
   177 		* @param aInterval a new interval in seconds
       
   178 		* @leave KErrArgument if aInterval == 0
       
   179 		* @leave KErrSIPInvalidTransactionState if State() is not EActive
       
   180 		* @leave KErrSIPResourceNotAvailable if SIP server can't be contacted
       
   181 		*	because a required resource has been deleted.
       
   182 		*/
       
   183 		IMPORT_C void SetIntervalL(TUint aInterval);
       
   184 
       
   185 	public: // New functions, for internal use
       
   186 
       
   187 	    TBool DoesMatch(TUint32 aRefreshId) const;
       
   188 
       
   189         /**
       
   190 		* Associate the CSIPRefresh with another object.
       
   191 		* @param aAssoc Object associated with the CSIPRefresh
       
   192 		* @return ETrue if the objects are equal otherwise EFalse
       
   193 		*/
       
   194         void SetRefreshOwner(MSIPRefreshAssociation& aAssoc);
       
   195 
       
   196         void RemoveRefreshOwner(const MSIPRefreshAssociation& aAssoc);
       
   197 
       
   198         void ChangeState(CSIPRefresh::TState aNextState);
       
   199 
       
   200         void UpdateRefreshState(TUint aStatusCode);
       
   201 
       
   202         TUint32 RefreshId() const;
       
   203 
       
   204         void SetRefreshIdIfEmpty(TUint32 aRefreshId);        
       
   205 
       
   206         RStringF RequestType() const;
       
   207 
       
   208         void SetRequestType(RStringF aType);
       
   209 
       
   210         void AddTransaction(CSIPClientTransaction& aTransaction);
       
   211 
       
   212         void RemoveTransaction();
       
   213 
       
   214         CSIPClientTransaction* Transaction();
       
   215 
       
   216 	private: // Constructors
       
   217 
       
   218 		CSIPRefresh();
       
   219 
       
   220 		void ConstructL();
       
   221 
       
   222 	private:
       
   223 
       
   224 		void CheckStateL() const;
       
   225 		
       
   226 	private: // Data
       
   227 
       
   228         MSIPRefreshAssociation* iOwner;
       
   229 
       
   230         //Client transaction which is refreshed, not owned by CSIPRefresh.        
       
   231         CSIPClientTransaction* iClientTransaction;
       
   232 
       
   233 		//Current state of the refresh
       
   234         TState iState;
       
   235 
       
   236         //RefreshId received from SIP client        
       
   237         TUint32 iRefreshId;
       
   238 
       
   239         //Identifies the request method which is being refreshed
       
   240         RStringF iRequestType;
       
   241 
       
   242 	private: // For testing purposes
       
   243 #ifdef CPPUNIT_TEST
       
   244 	    friend class CSIP_Test;
       
   245         friend class CSIPConnection_Test;
       
   246 #endif
       
   247 	};
       
   248 
       
   249 #endif