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