|
1 /* |
|
2 * Copyright (c) 2005 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 "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CMCESIPCONNECTION_H |
|
22 #define CMCESIPCONNECTION_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <in_sock.h> |
|
26 #include <sipconnectionobserver.h> |
|
27 |
|
28 #include "mcesrv.h" |
|
29 |
|
30 // FORWARD DECLARATION |
|
31 |
|
32 // CLASS DECLARATION |
|
33 class CSIPProfile; |
|
34 class CSIPConnection; |
|
35 class CMceCsSubSession; |
|
36 class CMceSipManager; |
|
37 class CMceLocalAddrResolver; |
|
38 class CSIPProfileRegistry; |
|
39 |
|
40 /** |
|
41 * MCE SIP Connection. |
|
42 * |
|
43 * @lib |
|
44 * @since |
|
45 */ |
|
46 class CMceSipConnection : public CBase, |
|
47 public MSIPConnectionObserver |
|
48 { |
|
49 |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @param aSessionManager, reference to session manager |
|
55 * @param aProfile, reference to profile. |
|
56 */ |
|
57 static CMceSipConnection* NewLC ( CMceSipManager& aSessionManager, |
|
58 CSIPProfile& aProfile, |
|
59 CSIPProfileRegistry& aProfileRegistry ); |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * @param aSessionManager, reference to session manager |
|
64 * @param aIAPId, access point id to be used. |
|
65 */ |
|
66 static CMceSipConnection* NewLC ( CMceSipManager& aSessionManager, TUint32 aIAPId ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 ~CMceSipConnection(); |
|
72 |
|
73 |
|
74 public: //New |
|
75 |
|
76 /** |
|
77 * return access point id |
|
78 * |
|
79 * @return return access point id |
|
80 */ |
|
81 TUint32 AccessPointId() const; |
|
82 |
|
83 /** |
|
84 * State of connection |
|
85 * |
|
86 * @State of connection |
|
87 */ |
|
88 CSIPConnection::TState State() const; |
|
89 |
|
90 /** |
|
91 * return connection |
|
92 * |
|
93 * @return connection |
|
94 */ |
|
95 CSIPConnection& Connection() const; |
|
96 |
|
97 /** |
|
98 * Numbers of sessions |
|
99 * |
|
100 * @param |
|
101 * @return number of sessions attached to this connection |
|
102 */ |
|
103 TBool IsProfileUsedInSession( CSIPProfile& aProfile ); |
|
104 |
|
105 /** |
|
106 * Attach session to this connection |
|
107 * Leaves, if SIP connection is not active or |
|
108 * session is allready attached |
|
109 * @param aSession session |
|
110 */ |
|
111 void AttachL( CMceCsSubSession& aSession ); |
|
112 |
|
113 /** |
|
114 * De-Attach session to this connection |
|
115 * |
|
116 * @param aSession session |
|
117 * @return number of sessions attached to this connection |
|
118 */ |
|
119 TInt Detach( CMceCsSubSession& aSession ); |
|
120 |
|
121 /** |
|
122 * Gets local IP address of the connection |
|
123 * |
|
124 * @return local IP address |
|
125 */ |
|
126 TInetAddr LocalIPAddressL(TInetAddr* aNextHop); |
|
127 |
|
128 /** |
|
129 * Gets IP address of IAP |
|
130 * |
|
131 * @return IP address |
|
132 */ |
|
133 static TInetAddr IPAddressL( TUint32 aIapId ); |
|
134 |
|
135 /** |
|
136 * Sets signalling type of service for connection if profile is |
|
137 * not used. |
|
138 * @param aSignallingTypeOfService |
|
139 */ |
|
140 void UpdateConnectionL( TUint aSignallingTypeOfService ); |
|
141 |
|
142 public: // from MSIPConnectionObserver |
|
143 |
|
144 |
|
145 /** |
|
146 * A SIP request outside a dialog has been received from the network. |
|
147 * |
|
148 * @pre aTransaction != 0 |
|
149 * @param aTransaction SIP server transaction. The ownership is |
|
150 * transferred. |
|
151 */ |
|
152 void IncomingRequest (CSIPServerTransaction* |
|
153 aTransaction); |
|
154 |
|
155 /** |
|
156 * A SIP request within a dialog has been received from the network. |
|
157 * The client must resolve the actual dialog association to which |
|
158 * this request belongs. |
|
159 * |
|
160 * @pre aTransaction != 0 |
|
161 * @param aTransaction SIP server transaction. The ownership is |
|
162 * transferred. |
|
163 * @param aDialog the dialog that this transaction belongs to. |
|
164 */ |
|
165 void IncomingRequest (CSIPServerTransaction* aTransaction, |
|
166 CSIPDialog& aDialog); |
|
167 |
|
168 /** |
|
169 * A SIP response received from the network. |
|
170 * |
|
171 * @param aTransaction contains response elements. |
|
172 */ |
|
173 void IncomingResponse (CSIPClientTransaction& |
|
174 aTransaction); |
|
175 |
|
176 /** |
|
177 * A SIP response received from the network that is within a dialog |
|
178 * association or creates a dialog association. |
|
179 * |
|
180 * @param aTransaction contains response elements. |
|
181 * @param aDialogAssoc a dialog association. |
|
182 */ |
|
183 void IncomingResponse ( |
|
184 CSIPClientTransaction& aTransaction, |
|
185 CSIPDialogAssocBase& aDialogAssoc); |
|
186 |
|
187 /** |
|
188 * Multiple SIP responses have been received to the single INVITE due |
|
189 * to the forking proxy. Note that each response creates a separate |
|
190 * INVITE dialog association. |
|
191 * Multiple responses can arrive until SIP stack completes UAC core |
|
192 * INVITE transaction. |
|
193 * If clients deletes INVITE transaction after first SIP response |
|
194 * other possible responses will be consumed by the implementation. |
|
195 * |
|
196 * @param aTransaction contains response elements |
|
197 * @param aDialogAssoc INVITE dialog association; the ownership is |
|
198 * transferred |
|
199 */ |
|
200 void IncomingResponse ( |
|
201 CSIPClientTransaction& aTransaction, |
|
202 CSIPInviteDialogAssoc* aDialogAssoc); |
|
203 |
|
204 /** |
|
205 * A SIP response related a registration binding or an error response |
|
206 * that is related to registration binding has been received |
|
207 * from the network. |
|
208 * |
|
209 * @param aTransaction contains response elements |
|
210 * @param aRegistration registration binding this transaction belongs to |
|
211 */ |
|
212 void |
|
213 IncomingResponse (CSIPClientTransaction& aTransaction, |
|
214 CSIPRegistrationBinding& aRegistration); |
|
215 |
|
216 /** |
|
217 * An asynchronous error has occurred in the stack related to the |
|
218 * request indicated by the given transaction. |
|
219 * |
|
220 * @param aError system wide or SIP error code |
|
221 * @param aTransaction failed transaction |
|
222 * @param aSIPConnection a SIP connection |
|
223 */ |
|
224 void ErrorOccured (TInt aError, |
|
225 CSIPTransactionBase& aTransaction); |
|
226 |
|
227 /** |
|
228 * An asynchronous error has occurred in the stack related |
|
229 * to the request indicated by the given transaction. |
|
230 * |
|
231 * @param aError system wide or SIP error code |
|
232 * @param aTransaction the failed transaction |
|
233 * @param aRegistration the failed registration binding |
|
234 */ |
|
235 void ErrorOccured (TInt aError, |
|
236 CSIPClientTransaction& aTransaction, |
|
237 CSIPRegistrationBinding& aRegistration); |
|
238 |
|
239 /** |
|
240 * An asynchronous error has occured related to a request within |
|
241 * an existing dialog. |
|
242 * |
|
243 * @param aError system wide or SIP error code |
|
244 * @param aTransaction the failed transaction. |
|
245 * @param aDialogAssoc the failed dialog associoation. |
|
246 */ |
|
247 void ErrorOccured ( |
|
248 TInt aError, |
|
249 CSIPTransactionBase& aTransaction, |
|
250 CSIPDialogAssocBase& aDialogAssoc); |
|
251 |
|
252 /** |
|
253 * An asynchronous error has occured related to a refresh |
|
254 * |
|
255 * @param aError system wide or SIP error code |
|
256 * @param aSIPRefresh original refresh object. |
|
257 */ |
|
258 void ErrorOccured (TInt aError, CSIPRefresh& aSIPRefresh); |
|
259 |
|
260 /** |
|
261 * An asynchronous error has occured related to a periodical refresh |
|
262 * that relates to a registration. |
|
263 * |
|
264 * @param aError system wide or SIP error code; |
|
265 * KErrCouldNotConnect if the refresh has failed |
|
266 * due to the suspended connection. |
|
267 * @param aRegistration associated registration binding |
|
268 */ |
|
269 void ErrorOccured (TInt aError, |
|
270 CSIPRegistrationBinding& aRegistration); |
|
271 |
|
272 /** |
|
273 * An asynchronous error has occured related to a periodical refresh |
|
274 * that belongs to SIP dialog association. |
|
275 * |
|
276 * @param aError system wide or SIP error code; |
|
277 * KErrCouldNotConnect if the refresh has failed |
|
278 * due to the suspended connection. |
|
279 * @param aDialogAssoc SIP dialog association. |
|
280 */ |
|
281 void ErrorOccured (TInt aError, |
|
282 CSIPDialogAssocBase& aDialogAssoc); |
|
283 |
|
284 /** |
|
285 * SIP stack has completed UAC core INVITE transaction 64*T1 seconds |
|
286 * after the reception of the first 2xx response. No more 2xx responses |
|
287 * can be received to the issued single INVITE. |
|
288 * |
|
289 * If the INVITE transaction does not create a dialog, or the INVITE |
|
290 * transaction encounters an error, this event will not be sent. |
|
291 * |
|
292 * @param aTransaction a complete UAC core INVITE transaction |
|
293 */ |
|
294 void InviteCompleted (CSIPClientTransaction& aTransaction); |
|
295 |
|
296 /** |
|
297 * Invite was canceled with the CANCEL |
|
298 * @param aTransaction a canceled INVITE UAS transaction |
|
299 */ |
|
300 void InviteCanceled (CSIPServerTransaction& aTransaction); |
|
301 |
|
302 /** |
|
303 * Connection state has changed. |
|
304 * If connection state has changed to EInactive or EUnavailable, |
|
305 * SIP stack has removed all stand-alone SIP refreshes, registrations |
|
306 * and dialog associations that client requested to refresh. Client may |
|
307 * re-issue refresh requests (stand-alone, registration or dialog |
|
308 * association related) when connection becomes EActive again. |
|
309 * SIP stack also terminates all pending SIP client transactions and no |
|
310 * errors are reported back to the client about the terminated |
|
311 * transactions nor about removed refreshes in order to avoid event |
|
312 * flood. |
|
313 * |
|
314 * @param aState indicates the current connection state |
|
315 */ |
|
316 void ConnectionStateChanged (CSIPConnection::TState aState); |
|
317 |
|
318 private: |
|
319 |
|
320 CMceSipConnection ( CMceSipManager& aSessionManager, |
|
321 CSIPProfile& aProfile ); |
|
322 |
|
323 CMceSipConnection ( CMceSipManager& aSessionManager, |
|
324 TUint32 aIAPId ); |
|
325 void ConstructL ( CSIPProfile& aProfile, CSIPProfileRegistry& aProfileRegistry ); |
|
326 |
|
327 void ConstructL ( ); |
|
328 |
|
329 void Reject ( CSIPInviteDialogAssoc* aDialogAssoc ); |
|
330 |
|
331 void FillWithMatchingAddrFamily( TInetAddr& aAddr, |
|
332 const TInetAddr* aNextHop ); |
|
333 |
|
334 private: // Data |
|
335 |
|
336 TUint32 iIAPId; |
|
337 |
|
338 CSIPConnection* iClientConnection; |
|
339 |
|
340 CMceLocalAddrResolver* iLocalAddrResolver; |
|
341 |
|
342 TUint iCurrentSignallingTypeOfService; |
|
343 |
|
344 private: //NOT owned data |
|
345 |
|
346 |
|
347 RPointerArray<CMceCsSubSession> iSessions; |
|
348 |
|
349 CMceSipManager& iSessionManager; |
|
350 |
|
351 //definitions for unit testing |
|
352 MCESRV_UT_DEFINITIONS |
|
353 |
|
354 |
|
355 }; |
|
356 |
|
357 #endif |
|
358 |
|
359 // End of File |