2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
16 * Part of : SIP Client
17 * Interface : SDK API, SIP Client API
30 #include <stringpool.h>
32 // FORWARD DECLARATIONS
33 class CSIPClientTransaction;
34 class CSIPMessageElements;
35 class MSIPRefreshAssociation;
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.
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.
54 class CSIPRefresh: public CBase
58 /** SIP refresh states */
61 /** SIP refresh is inactive */
63 /** SIP refresh active */
65 /** SIP refresh is terminated */
67 /** Object is being constructed and is not yet ready for use */
71 public: // Constructors and destructor
74 * Two-phased constructor
75 * @return New object. Ownership is transferred.
77 IMPORT_C static CSIPRefresh* NewL();
80 * Two-phased constructor
81 * @return New object. Ownership is transferred.
83 IMPORT_C static CSIPRefresh* NewLC();
88 IMPORT_C ~CSIPRefresh();
90 public: // New functions
93 * Gets the state of the refresh
94 * @return refresh state
96 IMPORT_C CSIPRefresh::TState State() const;
99 * Tests if the refresh is a stand-alone refresh
100 * @return ETrue if refresh is a stand-alone; EFalse otherwise
102 IMPORT_C TBool IsStandAlone() const;
105 * Gets the associated SIP transaction with this refresh.
107 * @return Associated SIP transaction or 0-pointer. Ownership is not
110 IMPORT_C const CSIPClientTransaction* SIPTransaction() const;
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
124 * KSIPErrInvalidRegistrationState if trying to terminate a
126 * KErrSIPInvalidDialogState if trying to terminate a dialog
127 * association being refreshed.
128 * @capability NetworkServices
130 IMPORT_C CSIPClientTransaction*
131 TerminateL(CSIPMessageElements* aElements=0);
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
145 * KErrSIPInvalidRegistrationState if trying to update a
147 * KSIPErrInvalidDialogState if trying to update a
148 * dialog association being refreshed.
149 * @capability NetworkServices
151 IMPORT_C CSIPClientTransaction*
152 UpdateL(CSIPMessageElements* aElements=0);
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
159 IMPORT_C TBool operator==(const CSIPRefresh& aRefresh) const;
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.
168 IMPORT_C TUint IntervalL() const;
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
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.
183 IMPORT_C void SetIntervalL(TUint aInterval);
185 public: // New functions, for internal use
187 TBool DoesMatch(TUint32 aRefreshId) const;
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
194 void SetRefreshOwner(MSIPRefreshAssociation& aAssoc);
196 void RemoveRefreshOwner(const MSIPRefreshAssociation& aAssoc);
198 void ChangeState(CSIPRefresh::TState aNextState);
200 void UpdateRefreshState(TUint aStatusCode);
202 TUint32 RefreshId() const;
204 void SetRefreshIdIfEmpty(TUint32 aRefreshId);
206 RStringF RequestType() const;
208 void SetRequestType(RStringF aType);
210 void AddTransaction(CSIPClientTransaction& aTransaction);
212 void RemoveTransaction();
214 CSIPClientTransaction* Transaction();
216 private: // Constructors
224 void CheckStateL() const;
228 MSIPRefreshAssociation* iOwner;
230 //Client transaction which is refreshed, not owned by CSIPRefresh.
231 CSIPClientTransaction* iClientTransaction;
233 //Current state of the refresh
236 //RefreshId received from SIP client
239 //Identifies the request method which is being refreshed
240 RStringF iRequestType;
242 private: // For testing purposes
244 friend class CSIP_Test;
245 friend class CSIPConnection_Test;