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