williamr@2: /* williamr@2: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Name : siprefresh.h williamr@2: * Part of : SIP Client williamr@2: * Interface : SDK API, SIP Client API williamr@2: * Version : 1.0 williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef CSIPREFRESH_H williamr@2: #define CSIPREFRESH_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CSIPClientTransaction; williamr@2: class CSIPMessageElements; williamr@2: class MSIPRefreshAssociation; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * williamr@2: * Class for managing SIP refresh. williamr@2: * It provides functions for getting associated sip transaction williamr@2: * and state. Class also provides functions for updating and terminating williamr@2: * stand-alone refreshes. williamr@2: * williamr@2: * Note that only stand-alone refreshes (i.e. refreshes that are not associated williamr@2: * with registration binding or dialog associations) can be terminated or williamr@2: * updated using functions defined in this class. williamr@2: * williamr@2: * @lib sipclient.lib williamr@2: */ williamr@2: class CSIPRefresh: public CBase williamr@2: { williamr@2: public: williamr@2: williamr@2: /** SIP refresh states */ williamr@2: enum TState williamr@2: { williamr@2: /** SIP refresh is inactive */ williamr@2: EInactive, williamr@2: /** SIP refresh active */ williamr@2: EActive, williamr@2: /** SIP refresh is terminated */ williamr@2: ETerminated, williamr@2: /** Object is being constructed and is not yet ready for use */ williamr@2: EConstructing williamr@2: }; williamr@2: williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Two-phased constructor williamr@2: * @return New object. Ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPRefresh* NewL(); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor williamr@2: * @return New object. Ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPRefresh* NewLC(); williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C ~CSIPRefresh(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Gets the state of the refresh williamr@2: * @return refresh state williamr@2: */ williamr@2: IMPORT_C CSIPRefresh::TState State() const; williamr@2: williamr@2: /** williamr@2: * Tests if the refresh is a stand-alone refresh williamr@2: * @return ETrue if refresh is a stand-alone; EFalse otherwise williamr@2: */ williamr@2: IMPORT_C TBool IsStandAlone() const; williamr@2: williamr@2: /** williamr@2: * Gets the associated SIP transaction with this refresh. williamr@2: * williamr@2: * @return Associated SIP transaction or 0-pointer. Ownership is not williamr@2: * transferred. williamr@2: */ williamr@2: IMPORT_C const CSIPClientTransaction* SIPTransaction() const; williamr@2: williamr@2: /** williamr@2: * Terminates the refresh by sending SIP request to the remote williamr@2: * destination. The new client transactation will be of the same type williamr@2: * as the first transaction associated with this request. williamr@2: * @pre State()==EActive williamr@2: * @pre IsStandAlone()==ETrue williamr@2: * @param aElements contains optional SIP message headers and body. williamr@2: * Ownership is transferred. williamr@2: * @return SIP client transaction. Ownership is transferred. williamr@2: * @leave KErrSIPInvalidTransactionState if State() is not EActive williamr@2: * KErrNotFound if the CSIPRefresh is no longer associated to williamr@2: * anything williamr@2: * KSIPErrInvalidRegistrationState if trying to terminate a williamr@2: * REGISTER refresh. williamr@2: * KErrSIPInvalidDialogState if trying to terminate a dialog williamr@2: * association being refreshed. williamr@2: * @capability NetworkServices williamr@2: */ williamr@2: IMPORT_C CSIPClientTransaction* williamr@2: TerminateL(CSIPMessageElements* aElements=0); williamr@2: williamr@2: /** williamr@2: * Updates the refresh by sending SIP request to the remote destination. williamr@2: * The new client transactation will be of the same type as the first williamr@2: * transaction associated with this request. williamr@2: * @pre State()==EActive williamr@2: * @pre IsStandAlone()==ETrue williamr@2: * @param aElements contains optional SIP message headers and body. williamr@2: * Ownership is transferred. williamr@2: * @return SIP client transaction. Ownership is transferred. williamr@2: * @leave KErrSIPInvalidTransactionState if State() is not EActive williamr@2: * KErrNotFound if the CSIPRefresh is no longer associated to williamr@2: * anything williamr@2: * KErrSIPInvalidRegistrationState if trying to update a williamr@2: * REGISTER refresh. williamr@2: * KSIPErrInvalidDialogState if trying to update a williamr@2: * dialog association being refreshed. williamr@2: * @capability NetworkServices williamr@2: */ williamr@2: IMPORT_C CSIPClientTransaction* williamr@2: UpdateL(CSIPMessageElements* aElements=0); williamr@2: williamr@2: /** williamr@2: * Compares this object to another object williamr@2: * @param aRefresh a CSIPRefresh type object to compare williamr@2: * @return ETrue if the objects are equal otherwise EFalse williamr@2: */ williamr@2: IMPORT_C TBool operator==(const CSIPRefresh& aRefresh) const; williamr@2: williamr@2: /** williamr@2: * Gets current refresh interval williamr@2: * @pre State()==CSIPRefresh::EActive williamr@2: * @return current refresh interval in seconds williamr@2: * @leave KErrSIPResourceNotAvailable if SIP server can't be contacted williamr@2: * because a required resource has been deleted. williamr@2: */ williamr@2: IMPORT_C TUint IntervalL() const; williamr@2: williamr@2: /** williamr@2: * Sets refresh interval. williamr@2: * Note that SIP server choses the refresh interval. This function should williamr@2: * be used only if SIP server has indicated new refresh interval using williamr@2: * SIP messages that are not associated to the refresh needing the update. williamr@2: * @pre State()==CSIPRefresh::EActive williamr@2: * @pre aInterval > 0 williamr@2: * @param aInterval a new interval in seconds williamr@2: * @leave KErrArgument if aInterval == 0 williamr@2: * @leave KErrSIPInvalidTransactionState if State() is not EActive williamr@2: * @leave KErrSIPResourceNotAvailable if SIP server can't be contacted williamr@2: * because a required resource has been deleted. williamr@2: */ williamr@2: IMPORT_C void SetIntervalL(TUint aInterval); williamr@2: williamr@2: public: // New functions, for internal use williamr@2: williamr@2: TBool DoesMatch(TUint32 aRefreshId) const; williamr@2: williamr@2: /** williamr@2: * Associate the CSIPRefresh with another object. williamr@2: * @param aAssoc Object associated with the CSIPRefresh williamr@2: * @return ETrue if the objects are equal otherwise EFalse williamr@2: */ williamr@2: void SetRefreshOwner(MSIPRefreshAssociation& aAssoc); williamr@2: williamr@2: void RemoveRefreshOwner(const MSIPRefreshAssociation& aAssoc); williamr@2: williamr@2: void ChangeState(CSIPRefresh::TState aNextState); williamr@2: williamr@2: void UpdateRefreshState(TUint aStatusCode); williamr@2: williamr@2: TUint32 RefreshId() const; williamr@2: williamr@2: void SetRefreshIdIfEmpty(TUint32 aRefreshId); williamr@2: williamr@2: RStringF RequestType() const; williamr@2: williamr@2: void SetRequestType(RStringF aType); williamr@2: williamr@2: void AddTransaction(CSIPClientTransaction& aTransaction); williamr@2: williamr@2: void RemoveTransaction(); williamr@2: williamr@2: CSIPClientTransaction* Transaction(); williamr@2: williamr@2: private: // Constructors williamr@2: williamr@2: CSIPRefresh(); williamr@2: williamr@2: void ConstructL(); williamr@2: williamr@2: private: williamr@2: williamr@2: void CheckStateL() const; williamr@2: williamr@2: private: // Data williamr@2: williamr@2: MSIPRefreshAssociation* iOwner; williamr@2: williamr@2: //Client transaction which is refreshed, not owned by CSIPRefresh. williamr@2: CSIPClientTransaction* iClientTransaction; williamr@2: williamr@2: //Current state of the refresh williamr@2: TState iState; williamr@2: williamr@2: //RefreshId received from SIP client williamr@2: TUint32 iRefreshId; williamr@2: williamr@2: //Identifies the request method which is being refreshed williamr@2: RStringF iRequestType; williamr@2: williamr@2: private: // For testing purposes williamr@4: #ifdef CPPUNIT_TEST williamr@4: friend class CSIP_Test; williamr@4: friend class CSIPConnection_Test; williamr@4: #endif williamr@2: }; williamr@2: williamr@2: #endif