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