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 : sipconnection.h
|
williamr@2
|
16 |
* Part of : SIP Client
|
williamr@2
|
17 |
* Interface : SDK API, SIP 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 |
#ifndef CSIPCONNECTION_H
|
williamr@2
|
25 |
#define CSIPCONNECTION_H
|
williamr@2
|
26 |
|
williamr@2
|
27 |
// INCLUDES
|
williamr@2
|
28 |
#include <e32base.h>
|
williamr@2
|
29 |
#include <in_sock.h>
|
williamr@2
|
30 |
|
williamr@2
|
31 |
// FORWARD DECLARATIONS
|
williamr@2
|
32 |
class CSIP;
|
williamr@2
|
33 |
class MSIPConnectionObserver;
|
williamr@2
|
34 |
class CSIPClientTransaction;
|
williamr@2
|
35 |
class MSIPRegistrationContext;
|
williamr@2
|
36 |
class CSIPRefresh;
|
williamr@2
|
37 |
class CSIPRequestElements;
|
williamr@2
|
38 |
class CSIPConnectionImplementation;
|
williamr@2
|
39 |
|
williamr@2
|
40 |
// CONSTANTS
|
williamr@2
|
41 |
|
williamr@2
|
42 |
// CLASS DECLARATION
|
williamr@2
|
43 |
|
williamr@2
|
44 |
/**
|
williamr@2
|
45 |
* @publishedAll
|
williamr@2
|
46 |
* @released
|
williamr@2
|
47 |
*
|
williamr@2
|
48 |
* Class for monitoring connection's state and sending SIP requests outside
|
williamr@2
|
49 |
* the dialog associations. Class must not be used
|
williamr@2
|
50 |
* - for sending requests to which received non-failure response creates a dialog
|
williamr@2
|
51 |
* - for sending requests that must be sent within SIP dialog
|
williamr@2
|
52 |
*
|
williamr@2
|
53 |
* Note that the user can have only one instance of the class per same IAP-id.
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
class CSIPConnection : public CBase
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
public:
|
williamr@2
|
58 |
/** Connection states */
|
williamr@2
|
59 |
enum TState
|
williamr@2
|
60 |
{
|
williamr@2
|
61 |
/** Connection initializing */
|
williamr@2
|
62 |
EInit=1,
|
williamr@2
|
63 |
/** Connection active */
|
williamr@2
|
64 |
EActive,
|
williamr@2
|
65 |
/** Connection suspended */
|
williamr@2
|
66 |
ESuspended,
|
williamr@2
|
67 |
/** Connection is inactive */
|
williamr@2
|
68 |
EInactive,
|
williamr@2
|
69 |
/** Connection is permanently unavailable */
|
williamr@2
|
70 |
EUnavailable
|
williamr@2
|
71 |
};
|
williamr@2
|
72 |
|
williamr@2
|
73 |
public: // Constructors and destructor
|
williamr@2
|
74 |
|
williamr@2
|
75 |
/**
|
williamr@2
|
76 |
* Two-phased constructor.
|
williamr@2
|
77 |
* @param aSip a handle to the SIP server
|
williamr@2
|
78 |
* @param aIapId IAP-id
|
williamr@2
|
79 |
* @param aObserver a observer for receiving asynchonous events on this
|
williamr@2
|
80 |
* connection
|
williamr@2
|
81 |
* @return New object, ownership is transferred
|
williamr@2
|
82 |
* @capability NetworkServices
|
williamr@2
|
83 |
*/
|
williamr@2
|
84 |
IMPORT_C static CSIPConnection*
|
williamr@2
|
85 |
NewL(CSIP& aSIP,
|
williamr@2
|
86 |
TUint32 aIapId,
|
williamr@2
|
87 |
MSIPConnectionObserver& aObserver);
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/**
|
williamr@2
|
90 |
* Two-phased constructor.
|
williamr@2
|
91 |
* Constructs an object and adds the pointer to the cleanup stack;
|
williamr@2
|
92 |
* @param aSip a handle to the SIP server
|
williamr@2
|
93 |
* @param aIapId IAP-id
|
williamr@2
|
94 |
* @param aObserver a observer for receiving asynchonous events on this
|
williamr@2
|
95 |
* connection
|
williamr@2
|
96 |
* @return New object, ownership is transferred
|
williamr@2
|
97 |
* @capability NetworkServices
|
williamr@2
|
98 |
*/
|
williamr@2
|
99 |
IMPORT_C static CSIPConnection*
|
williamr@2
|
100 |
NewLC(CSIP& aSIP,
|
williamr@2
|
101 |
TUint32 aIapId,
|
williamr@2
|
102 |
MSIPConnectionObserver& aObserver);
|
williamr@2
|
103 |
|
williamr@2
|
104 |
/**
|
williamr@2
|
105 |
* Destructor
|
williamr@2
|
106 |
* @capability NetworkServices
|
williamr@2
|
107 |
*/
|
williamr@2
|
108 |
IMPORT_C ~CSIPConnection();
|
williamr@2
|
109 |
|
williamr@2
|
110 |
public: // New functions
|
williamr@2
|
111 |
|
williamr@2
|
112 |
/**
|
williamr@2
|
113 |
* Gets current state of the connection
|
williamr@2
|
114 |
* @return current state of the connection
|
williamr@2
|
115 |
*/
|
williamr@2
|
116 |
IMPORT_C TState State() const;
|
williamr@2
|
117 |
|
williamr@2
|
118 |
/**
|
williamr@2
|
119 |
* Creates SIP request and sends it to the given destination.
|
williamr@2
|
120 |
* The function must not be used with SIP requests that creates
|
williamr@2
|
121 |
* SIP dialog associations or must be sent within SIP dialog
|
williamr@2
|
122 |
* association.
|
williamr@2
|
123 |
* This provokes the Non-invite state machine.
|
williamr@2
|
124 |
* This function must be used if the user has created the
|
williamr@2
|
125 |
* registration binding.
|
williamr@2
|
126 |
* @pre State() == EActive.
|
williamr@2
|
127 |
* @pre aContext.IsContextActive() == ETrue
|
williamr@2
|
128 |
* @param aElements contains local and remote addresses,
|
williamr@2
|
129 |
* optional SIP message headers and body.
|
williamr@2
|
130 |
* The ownership is transferred.
|
williamr@2
|
131 |
* @param aContext defines outbound proxy to be used. If the user
|
williamr@2
|
132 |
* does not provide from-address it will be constucted using
|
williamr@2
|
133 |
* user's AOR used during the registration.
|
williamr@2
|
134 |
* @return SIP client transaction, ownership is transferred
|
williamr@2
|
135 |
* @leave KErrArgument if aElements == 0
|
williamr@2
|
136 |
* @leave KErrSIPInvalidRegistrationState if aContext.IsContextActive()
|
williamr@2
|
137 |
* == EFalse
|
williamr@2
|
138 |
* @capability NetworkServices
|
williamr@2
|
139 |
*/
|
williamr@2
|
140 |
IMPORT_C CSIPClientTransaction*
|
williamr@2
|
141 |
SendRequestL(CSIPRequestElements* aElements,
|
williamr@2
|
142 |
const MSIPRegistrationContext& aContext);
|
williamr@2
|
143 |
|
williamr@2
|
144 |
/**
|
williamr@2
|
145 |
* Creates SIP request and sends it to the given destination.
|
williamr@2
|
146 |
* The function must not be used with SIP requests that creates
|
williamr@2
|
147 |
* SIP dialog associations or must be sent within SIP dialog
|
williamr@2
|
148 |
* association.
|
williamr@2
|
149 |
* This provokes the Non-invite state machine.
|
williamr@2
|
150 |
* This function must be used if the user has created the
|
williamr@2
|
151 |
* registration binding.
|
williamr@2
|
152 |
* @pre State() == EActive.
|
williamr@2
|
153 |
* @pre aContext.IsContextActive() == ETrue
|
williamr@2
|
154 |
* @param aElements contains local and remote addresses,
|
williamr@2
|
155 |
* optional SIP message headers and body.
|
williamr@2
|
156 |
* The ownership is transferred.
|
williamr@2
|
157 |
* @param aContext defines outbound proxy to be used. If the user
|
williamr@2
|
158 |
* does not provide from-address it will
|
williamr@2
|
159 |
* be constucted using user's AOR used during the registration.
|
williamr@2
|
160 |
* @param aRefresh defines the refresh interval for this transaction.
|
williamr@2
|
161 |
* @return SIP client transaction, ownership is transferred
|
williamr@2
|
162 |
* @leave KErrArgument if aElements == 0
|
williamr@2
|
163 |
* @leave KErrSIPInvalidRegistrationState if aContext.IsContextActive()
|
williamr@2
|
164 |
* == EFalse
|
williamr@2
|
165 |
* @capability NetworkServices
|
williamr@2
|
166 |
*/
|
williamr@2
|
167 |
IMPORT_C CSIPClientTransaction*
|
williamr@2
|
168 |
SendRequestL(CSIPRequestElements* aElements,
|
williamr@2
|
169 |
const MSIPRegistrationContext& aContext,
|
williamr@2
|
170 |
CSIPRefresh& aRefresh);
|
williamr@2
|
171 |
|
williamr@2
|
172 |
/**
|
williamr@2
|
173 |
* Creates SIP request and sends it to the given destination.
|
williamr@2
|
174 |
* The function must not be used with SIP requests that creates SIP
|
williamr@2
|
175 |
* dialog associations or must be sent within SIP dialog association.
|
williamr@2
|
176 |
* This invokes the Non-invite state machine.
|
williamr@2
|
177 |
* @pre State() == EActive.
|
williamr@2
|
178 |
* @pre aElements.FromHeader() != 0
|
williamr@2
|
179 |
* @param aElements contains local and remote addresses,
|
williamr@2
|
180 |
* optional SIP message headers and body.
|
williamr@2
|
181 |
* The ownership is transferred.
|
williamr@2
|
182 |
* @return SIP client transaction, ownership is transferred
|
williamr@2
|
183 |
* @leave KErrArgument if aElements == 0 or if From-header is not
|
williamr@2
|
184 |
* present in aElements
|
williamr@2
|
185 |
* @capability NetworkServices
|
williamr@2
|
186 |
*/
|
williamr@2
|
187 |
IMPORT_C CSIPClientTransaction*
|
williamr@2
|
188 |
SendRequestL(CSIPRequestElements* aElements);
|
williamr@2
|
189 |
|
williamr@2
|
190 |
/**
|
williamr@2
|
191 |
* Creates SIP request and sends it to the given destination.
|
williamr@2
|
192 |
* The function must not be used with SIP requests that creates SIP
|
williamr@2
|
193 |
* dialog associations or must be sent within SIP dialog association.
|
williamr@2
|
194 |
* This invokes the Non-invite state machine.
|
williamr@2
|
195 |
* @pre State() == EActive.
|
williamr@2
|
196 |
* @pre aElements.FromHeader() != 0
|
williamr@2
|
197 |
* @param aElements contains local and remote addresses,
|
williamr@2
|
198 |
* optional SIP message headers and body.
|
williamr@2
|
199 |
* The ownership is transferred.
|
williamr@2
|
200 |
* @param aRefresh indicates that transaction will be refreshed
|
williamr@2
|
201 |
* @return SIP client transaction, ownership is transferred
|
williamr@2
|
202 |
* @leave KErrArgument if aElements == 0 or if From-header is not
|
williamr@2
|
203 |
* present in aElements
|
williamr@2
|
204 |
* @capability NetworkServices
|
williamr@2
|
205 |
*/
|
williamr@2
|
206 |
IMPORT_C CSIPClientTransaction*
|
williamr@2
|
207 |
SendRequestL(CSIPRequestElements* aElements,
|
williamr@2
|
208 |
CSIPRefresh& aRefresh);
|
williamr@2
|
209 |
|
williamr@2
|
210 |
/**
|
williamr@2
|
211 |
* Creates SIP REGISTER request and sends it to the given destination.
|
williamr@2
|
212 |
* User must no define any Contact or Expires-headers
|
williamr@2
|
213 |
* in the provided elements.
|
williamr@2
|
214 |
* @pre State() == EActive
|
williamr@2
|
215 |
* @pre aElements != 0
|
williamr@2
|
216 |
* @pre aElements->Method().DesC().Length()==0
|
williamr@2
|
217 |
* @param aElements contains local and remote addresses, optional SIP
|
williamr@2
|
218 |
* message headers and body. User must not set any expires values
|
williamr@2
|
219 |
* to aElements. The ownership is transferred.
|
williamr@2
|
220 |
* @return SIP REGISTER client transaction, ownership is transferred
|
williamr@2
|
221 |
* @leave KErrArgument if aElements == 0 or if the request method has
|
williamr@2
|
222 |
* been defined in aElements
|
williamr@2
|
223 |
* @capability NetworkServices
|
williamr@2
|
224 |
*/
|
williamr@2
|
225 |
IMPORT_C CSIPClientTransaction*
|
williamr@2
|
226 |
FetchRegistrationsL(CSIPRequestElements* aElements);
|
williamr@2
|
227 |
|
williamr@2
|
228 |
/**
|
williamr@2
|
229 |
* Gets Iap-id used for this connection
|
williamr@2
|
230 |
* @return Iap-id
|
williamr@2
|
231 |
*/
|
williamr@2
|
232 |
IMPORT_C TUint32 IapId() const;
|
williamr@2
|
233 |
|
williamr@2
|
234 |
/**
|
williamr@2
|
235 |
* Gets SIP server handle
|
williamr@2
|
236 |
* @return handle to SIP server, or 0-pointer if SIP server does not
|
williamr@2
|
237 |
* exist any more
|
williamr@2
|
238 |
*/
|
williamr@2
|
239 |
IMPORT_C CSIP* SIP();
|
williamr@2
|
240 |
|
williamr@2
|
241 |
/**
|
williamr@2
|
242 |
* Gets SIP server handle
|
williamr@2
|
243 |
* @return handle to SIP server, or 0-pointer if SIP server does not
|
williamr@2
|
244 |
* exist any more
|
williamr@2
|
245 |
*/
|
williamr@2
|
246 |
IMPORT_C const CSIP* SIP() const;
|
williamr@2
|
247 |
|
williamr@2
|
248 |
/**
|
williamr@2
|
249 |
* Sets a RSocket option used for all the sockets used for sending
|
williamr@2
|
250 |
* SIP requests and responses in this CSIPConnection.
|
williamr@2
|
251 |
* @pre State() == EActive
|
williamr@2
|
252 |
* @param aOptionName An integer constant which identifies an option.
|
williamr@2
|
253 |
* @param aOptionLevel An integer constant which identifies
|
williamr@2
|
254 |
* level of an option.
|
williamr@2
|
255 |
* @param aOption Option value packaged in a descriptor.
|
williamr@2
|
256 |
* @leave A system-wide error code
|
williamr@2
|
257 |
* @capability NetworkControl
|
williamr@2
|
258 |
* @capability NetworkServices
|
williamr@2
|
259 |
* @capability Location
|
williamr@2
|
260 |
* @capability ReadDeviceData
|
williamr@2
|
261 |
* @capability WriteDeviceData
|
williamr@2
|
262 |
*/
|
williamr@2
|
263 |
IMPORT_C void SetOptL(TUint aOptionName,
|
williamr@2
|
264 |
TUint aOptionLevel,
|
williamr@2
|
265 |
const TDesC8& aOption=KNullDesC8);
|
williamr@2
|
266 |
|
williamr@2
|
267 |
/**
|
williamr@2
|
268 |
* Sets a RSocket option used for all the sockets used for sending
|
williamr@2
|
269 |
* SIP requests and responses in this CSIPConnection.
|
williamr@2
|
270 |
* @pre State() == EActive
|
williamr@2
|
271 |
* @param aOptionName An integer constant which identifies an option.
|
williamr@2
|
272 |
* @param aOptionLevel An integer constant which identifies
|
williamr@2
|
273 |
* level of an option.
|
williamr@2
|
274 |
* @param aOption Option value as an integer.
|
williamr@2
|
275 |
* @leave A system-wide error codes
|
williamr@2
|
276 |
* @capability NetworkControl
|
williamr@2
|
277 |
* @capability NetworkServices
|
williamr@2
|
278 |
* @capability Location
|
williamr@2
|
279 |
* @capability ReadDeviceData
|
williamr@2
|
280 |
* @capability WriteDeviceData
|
williamr@2
|
281 |
*/
|
williamr@2
|
282 |
IMPORT_C void SetOptL(TUint aOptionName,
|
williamr@2
|
283 |
TUint aOptionLevel,
|
williamr@2
|
284 |
TInt aOption);
|
williamr@2
|
285 |
|
williamr@2
|
286 |
/**
|
williamr@2
|
287 |
* Gets the local IP address of this CSIPConnection
|
williamr@2
|
288 |
* that is used by the SIP implementation.
|
williamr@2
|
289 |
* The user should re-new the call whenever the connection state changes
|
williamr@2
|
290 |
* to the CSIPConnection::EActive in order to verify the correctness of
|
williamr@2
|
291 |
* the previously retrieved local IP address. The local IP address might
|
williamr@2
|
292 |
* be different as a result of the connection state change.
|
williamr@2
|
293 |
* @pre State() == CSIPConnection::EActive
|
williamr@2
|
294 |
* @param aAddr on return filled with local IP address
|
williamr@2
|
295 |
* @leave a system-wide error code
|
williamr@2
|
296 |
*/
|
williamr@2
|
297 |
IMPORT_C void GetLocalAddrL(TInetAddr& aAddr) const;
|
williamr@2
|
298 |
|
williamr@4
|
299 |
/**
|
williamr@4
|
300 |
* Refreshes the connection.
|
williamr@4
|
301 |
* This will retrieve the Bearer Monitor Instance if any, is available for this CSIPConnection and issue a Connection Refresh Request to it.
|
williamr@4
|
302 |
* The state of the Connection can be retrieved from State() to check if there is any change after Refreshing the connection.
|
williamr@4
|
303 |
* @capability NetworkServices.
|
williamr@4
|
304 |
*/
|
williamr@2
|
305 |
|
williamr@4
|
306 |
IMPORT_C void RefreshConnection() const;
|
williamr@4
|
307 |
|
williamr@4
|
308 |
/**
|
williamr@4
|
309 |
* Gets the connection error code
|
williamr@4
|
310 |
* @param aError will be filled with the error code
|
williamr@4
|
311 |
* @leave a system-wide error code
|
williamr@4
|
312 |
* @capability NetworkServices.
|
williamr@4
|
313 |
*/
|
williamr@4
|
314 |
IMPORT_C void GetConnectionErrorL(TInt &aError) const;
|
williamr@2
|
315 |
|
williamr@2
|
316 |
public: // New functions, for internal use
|
williamr@2
|
317 |
|
williamr@2
|
318 |
/**
|
williamr@2
|
319 |
* Returns the implementation instance.
|
williamr@2
|
320 |
*
|
williamr@2
|
321 |
* @return CSIPConnectionImplementation
|
williamr@2
|
322 |
*/
|
williamr@2
|
323 |
CSIPConnectionImplementation& Implementation();
|
williamr@2
|
324 |
|
williamr@2
|
325 |
private: // Constructors
|
williamr@2
|
326 |
|
williamr@2
|
327 |
CSIPConnection();
|
williamr@2
|
328 |
|
williamr@2
|
329 |
void ConstructL(CSIP& aSIP,
|
williamr@2
|
330 |
TUint32 aIapId,
|
williamr@2
|
331 |
MSIPConnectionObserver& aObserver);
|
williamr@2
|
332 |
|
williamr@2
|
333 |
private: // Data
|
williamr@2
|
334 |
|
williamr@2
|
335 |
CSIPConnectionImplementation* iImplementation;
|
williamr@2
|
336 |
|
williamr@2
|
337 |
private: // For testing purposes
|
williamr@4
|
338 |
#ifdef CPPUNIT_TEST
|
williamr@4
|
339 |
friend class CSIP_Test;
|
williamr@4
|
340 |
friend class CSIPConnection_Test;
|
williamr@4
|
341 |
friend class CSIPSubscribeDialogAssoc_Test;
|
williamr@4
|
342 |
friend class CSIPInviteDialogAssoc_Test;
|
williamr@4
|
343 |
friend class CSIPReferDialogAssoc_Test;
|
williamr@4
|
344 |
friend class CSIPNotifyDialogAssoc_Test;
|
williamr@4
|
345 |
friend class CSIPDialogTrying_Test;
|
williamr@4
|
346 |
friend class CSIPRegistrationBinding_Test;
|
williamr@4
|
347 |
#endif
|
williamr@4
|
348 |
void __DbgTestInvariant() const;
|
williamr@4
|
349 |
|
williamr@2
|
350 |
};
|
williamr@2
|
351 |
|
williamr@2
|
352 |
#endif
|