28
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2010 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 |
#ifndef C_SCPSIPCONNECTION_H
|
|
19 |
#define C_SCPSIPCONNECTION_H
|
|
20 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <rconnmon.h>
|
|
23 |
#include <sipconnectionobserver.h>
|
|
24 |
#include <sipprofileregistryobserver.h>
|
|
25 |
|
|
26 |
#include "scpdefs.h"
|
|
27 |
|
|
28 |
class CSIPProfileRegistry;
|
|
29 |
class CSIPProfile;
|
|
30 |
class CSIPManagedProfileRegistry;
|
|
31 |
class MScpSipConnectionObserver;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Register/unregister protocol profiles.
|
|
35 |
*
|
|
36 |
* @lib sipconnectionprovider.dll
|
|
37 |
* @since Series 60 3.2
|
|
38 |
*/
|
|
39 |
class CScpSipConnection : public CBase,
|
|
40 |
public MSIPConnectionObserver
|
|
41 |
{
|
|
42 |
public:
|
|
43 |
|
|
44 |
enum TConnectionState
|
|
45 |
{
|
|
46 |
EUnknown = 0,
|
|
47 |
ERegistering,
|
|
48 |
ERegistered,
|
|
49 |
EDeregistering,
|
|
50 |
EDeregistered,
|
|
51 |
};
|
|
52 |
|
|
53 |
enum TRegistrationRequestState
|
|
54 |
{
|
|
55 |
ENoRequest = 0,
|
|
56 |
ERegistrationRequested,
|
|
57 |
EDeregistrationRequested
|
|
58 |
};
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Two-phased constructor.
|
|
62 |
*/
|
|
63 |
static CScpSipConnection* NewL( TInt aProfileId,
|
|
64 |
CSIPProfileRegistry& aProfileRegistry,
|
|
65 |
CSIPManagedProfileRegistry& aManagedProfileRegistry,
|
|
66 |
CSIP& aSip );
|
|
67 |
/**
|
|
68 |
* Destructor.
|
|
69 |
*/
|
|
70 |
virtual ~CScpSipConnection();
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Return sip profile id of this connection
|
|
74 |
* @return Profile id
|
|
75 |
*/
|
|
76 |
TInt ProfileId() const;
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Enables the connection
|
|
80 |
*/
|
|
81 |
void EnableL();
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Disables the connection.
|
|
85 |
* @return Symbian error codes
|
|
86 |
*/
|
|
87 |
TInt Disable();
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Disables the connection ungracefully.
|
|
91 |
* @return Symbian error codes
|
|
92 |
*/
|
|
93 |
TInt ForceDisable();
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Returns state of deregistration request
|
|
97 |
* @return Registration state
|
|
98 |
*/
|
|
99 |
TRegistrationRequestState RegistrationRequestState() const;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Get sip connection state
|
|
103 |
* @return State
|
|
104 |
*/
|
|
105 |
void GetState( TConnectionState& aState, TInt& aError ) const;
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Adds observer for the connection
|
|
109 |
* @param aObserver Observer
|
|
110 |
*/
|
|
111 |
void AddObserver( MScpSipConnectionObserver& aObserver );
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Removes observer from this connection
|
|
115 |
* @param aObserver Observer
|
|
116 |
* @return Symbian error codes
|
|
117 |
*/
|
|
118 |
TInt RemoveObserver( MScpSipConnectionObserver& aObserver );
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Gets Protocol Profile's IAP Id.
|
|
122 |
* @return Iap id
|
|
123 |
*/
|
|
124 |
TInt GetIap( TUint32& aIapId ) const;
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Gets Protocol Profile's SNAP Id.
|
|
128 |
* @return Snap id.
|
|
129 |
*/
|
|
130 |
TInt GetSnap( TUint32& aSnapId ) const;
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Gets Protocol Profile's Username..
|
|
134 |
* @param aUsername Username of profile.
|
|
135 |
* @return KErrNone if succeed.
|
|
136 |
*/
|
|
137 |
TInt GetUsername( TDes8& aUsername ) const;
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Gets Protocol Profile's domain.
|
|
141 |
* @param aDomain Domain of profile.
|
|
142 |
* @return KErrNone if succeed.
|
|
143 |
*/
|
|
144 |
TInt GetDomain( TDes8& aDomain ) const;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Gets Protocol Profile's User name from Contact header
|
|
148 |
* @param aDomain Domain of profile.
|
|
149 |
* @return KErrNone if succeed.
|
|
150 |
*/
|
|
151 |
TInt GetContactHeaderUser( RBuf8& aContactHeaderUser ) const;
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Get CSIPProfile
|
|
155 |
* @return CSIPProfile
|
|
156 |
*/
|
|
157 |
CSIPProfile& SipProfile() const;
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Set Protocol Profile use this IAP.
|
|
161 |
* @since Series 60 3.2
|
|
162 |
* @param aIapId Iap Id.
|
|
163 |
* @return KErrNone if succeed.
|
|
164 |
*/
|
|
165 |
TInt SetIap( TUint32 aIapId );
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Set Protocol Profile use this SNAP.
|
|
169 |
* @param aSnapId Profile new SNAP Id.
|
|
170 |
* @return KErrNone if succeed.
|
|
171 |
*/
|
|
172 |
TInt SetSnap( TUint32 aSnapId );
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Returns the type of the iap this connection's profile is using
|
|
176 |
* @return Iap type
|
|
177 |
*/
|
|
178 |
TScpIapType GetIapTypeL() const;
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Profile registry error occurred
|
|
182 |
* @param aProfileId Profile id
|
|
183 |
* @param aError error code
|
|
184 |
*/
|
|
185 |
void ProfileRegistryErrorOccurred( TInt aError );
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Updates the sip connection for the used sip profile
|
|
189 |
* @param aProfileId Profile id
|
|
190 |
* @param aEvent Event
|
|
191 |
*/
|
|
192 |
void ProfileRegistryEventOccurred( MSIPProfileRegistryObserver::TEvent aEvent );
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Reserve/Free the used connection for a service's use.
|
|
196 |
* For example a VoIP service might reserve the profile for a
|
|
197 |
* duration of a VoIP call
|
|
198 |
* @param aReserved Reserved
|
|
199 |
*/
|
|
200 |
void SetReserved( TBool aReserved );
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Returns information about if a connection is reserved or not
|
|
204 |
* @return ETrue if reserved
|
|
205 |
*/
|
|
206 |
TBool Reserved() const;
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Raises the flag fot iap availability offered. Iap availability
|
|
210 |
* offers may come from SIP during ALR. If the connection is reserved,
|
|
211 |
* the ARL is not allowed and iap available offered is raised.
|
|
212 |
* When the connection is freed the ALR can occur.
|
|
213 |
*/
|
|
214 |
void SetIapAvailableOffered( TBool aIapAvailableOffered );
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Returns the iap available offered flag
|
|
218 |
* @return ETrue if iap available was offered
|
|
219 |
*/
|
|
220 |
TBool IapAvailableOffered() const;
|
|
221 |
|
|
222 |
/**
|
|
223 |
* Sets flag that currenlty the profile is romaing
|
|
224 |
*/
|
|
225 |
void SetProfileCurrentlyRoaming();
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Handle ongoing alr
|
|
229 |
*/
|
|
230 |
void HandleMigrationStarted();
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Handle alr error
|
|
234 |
* @param aError the error that occurred
|
|
235 |
* @param aProfileId identifies the SIP profile related to the error
|
|
236 |
* @param aSnapId the SNAP related to the event
|
|
237 |
* @param aIapId the IAP related to the error
|
|
238 |
*/
|
|
239 |
void HandleMigrationError( TInt aError,
|
|
240 |
TUint32 aProfileId, TUint32 aSnapId, TUint32 aIapId );
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Password check.
|
|
244 |
* @return returns always ETrue because information cannot
|
|
245 |
* be checked from sip
|
|
246 |
*/
|
|
247 |
TBool IsPasswordSet() const;
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Username check.
|
|
251 |
* Checks if digest username is set and username is in aor.
|
|
252 |
* @return ETrue when username exists
|
|
253 |
*/
|
|
254 |
TBool IsUsernameSetL() const;
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Checks if SNAP connection method used by the SIP profile is
|
|
258 |
* available
|
|
259 |
* @return ETrue if available
|
|
260 |
*/
|
|
261 |
TBool IsSnapConnectionAvailable( TInt aSnapId ) const;
|
|
262 |
|
|
263 |
/**
|
|
264 |
* Checks if IAP connection method used by sip profile is
|
|
265 |
* available
|
|
266 |
* @return ETrue if available
|
|
267 |
*/
|
|
268 |
TBool IsIapConnectionAvailable( TInt aIapId ) const;
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Gets bearer filttering setting used by sip profile.
|
|
272 |
* 0 --> Not Specified.
|
|
273 |
* 1 --> WLAN Bearer Only.
|
|
274 |
* 2 --> Cellular Data Bearer Only.
|
|
275 |
* @param aBearerFilttering bearer filttering setting
|
|
276 |
*
|
|
277 |
* @return KErrNone if succeed.
|
|
278 |
*/
|
|
279 |
TInt BearerFiltteringSetting( TUint32& aBearerFilttering ) const;
|
|
280 |
|
|
281 |
#ifdef _DEBUG
|
|
282 |
void GetInfo( TDes& aInfo ) const;
|
|
283 |
#endif
|
|
284 |
|
|
285 |
private:
|
|
286 |
|
|
287 |
// From MSIPConnectionObserver
|
|
288 |
void IncomingRequest( CSIPServerTransaction* /*aTransaction*/ ) {};
|
|
289 |
|
|
290 |
void IncomingRequest( CSIPServerTransaction* /*aTransaction*/,
|
|
291 |
CSIPDialog& /*aDialog*/ ) {};
|
|
292 |
|
|
293 |
void IncomingResponse( CSIPClientTransaction& /*aTransaction*/ ) {};
|
|
294 |
|
|
295 |
void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
|
|
296 |
CSIPDialogAssocBase& /*aDialogAssoc*/ ) {};
|
|
297 |
|
|
298 |
void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
|
|
299 |
CSIPInviteDialogAssoc* /*aDialogAssoc*/ ) {};
|
|
300 |
|
|
301 |
void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
|
|
302 |
CSIPRegistrationBinding& /*aRegistration*/ ) {};
|
|
303 |
|
|
304 |
void ErrorOccured( TInt /*aError*/, CSIPTransactionBase& /*aTransaction*/ ) {};
|
|
305 |
|
|
306 |
void ErrorOccured( TInt /*aError*/,
|
|
307 |
CSIPClientTransaction& /*aTransaction*/,
|
|
308 |
CSIPRegistrationBinding& /*aRegistration*/ ) {};
|
|
309 |
|
|
310 |
void ErrorOccured( TInt /*aError*/,
|
|
311 |
CSIPTransactionBase& /*aTransaction*/,
|
|
312 |
CSIPDialogAssocBase& /*aDialogAssoc*/ ) {};
|
|
313 |
|
|
314 |
void ErrorOccured( TInt /*aError*/, CSIPRefresh& /*aSIPRefresh*/ ) {};
|
|
315 |
|
|
316 |
|
|
317 |
void ErrorOccured( TInt /*aError*/,
|
|
318 |
CSIPRegistrationBinding& /*aRegistration*/ ) {};
|
|
319 |
|
|
320 |
void ErrorOccured( TInt /*aError*/,
|
|
321 |
CSIPDialogAssocBase& /*aDialogAssoc*/) {};
|
|
322 |
|
|
323 |
void InviteCompleted( CSIPClientTransaction& /*aTransaction*/ ) {};
|
|
324 |
|
|
325 |
void InviteCanceled( CSIPServerTransaction& /*aTransaction*/ ) {};
|
|
326 |
|
|
327 |
void ConnectionStateChanged( CSIPConnection::TState aState );
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Checks if connection method used by the sip profile is
|
|
331 |
* available
|
|
332 |
* @return ETrue if available
|
|
333 |
*/
|
|
334 |
TBool IsNetworkConnectionAvailable() const;
|
|
335 |
|
|
336 |
private:
|
|
337 |
|
|
338 |
/**
|
|
339 |
* C++ default constructor.
|
|
340 |
*/
|
|
341 |
CScpSipConnection( TInt aProfileId,
|
|
342 |
CSIPProfileRegistry& aProfileRegistry,
|
|
343 |
CSIPManagedProfileRegistry& aManagedProfileRegistry,
|
|
344 |
CSIP& aSip );
|
|
345 |
|
|
346 |
/**
|
|
347 |
* By default Symbian 2nd phase constructor is private.
|
|
348 |
*/
|
|
349 |
void ConstructL();
|
|
350 |
|
|
351 |
/**
|
|
352 |
* Starts timeout timer
|
|
353 |
* @param aFunction The function to call after the time out
|
|
354 |
*/
|
|
355 |
void StartEnableTimeoutTimer( TInt (*aFunction)(TAny* aPtr) );
|
|
356 |
|
|
357 |
/**
|
|
358 |
* Cancels the disable timer
|
|
359 |
*/
|
|
360 |
void CancelEnableTimeoutTimer();
|
|
361 |
|
|
362 |
/**
|
|
363 |
* Profile register timeout callback
|
|
364 |
* @param aSelf this object
|
|
365 |
*/
|
|
366 |
static TInt EnableTimeout( TAny* aSelf );
|
|
367 |
|
|
368 |
/**
|
|
369 |
* Handles sip profile register timeout
|
|
370 |
*/
|
|
371 |
void HandleEnableTimeout();
|
|
372 |
|
|
373 |
/**
|
|
374 |
* Changes SIP profile from "Always on" to "When needed" if
|
|
375 |
* the profile was originally set to "Always on"
|
|
376 |
*/
|
|
377 |
void DisableAlwaysOnModeL();
|
|
378 |
|
|
379 |
/**
|
|
380 |
* Checks if Sip profile type is IMS
|
|
381 |
*/
|
|
382 |
TBool SipProfileIMS() const;
|
|
383 |
|
|
384 |
private:
|
|
385 |
|
|
386 |
/**
|
|
387 |
* Sip profile id
|
|
388 |
*/
|
|
389 |
TInt iProfileId;
|
|
390 |
|
|
391 |
/**
|
|
392 |
* Sip profile registry
|
|
393 |
*/
|
|
394 |
CSIPProfileRegistry& iProfileRegistry;
|
|
395 |
|
|
396 |
/**
|
|
397 |
* Managed sip profile registry
|
|
398 |
*/
|
|
399 |
CSIPManagedProfileRegistry& iManagedProfileRegistry;
|
|
400 |
|
|
401 |
/**
|
|
402 |
* SIP instance
|
|
403 |
*/
|
|
404 |
CSIP& iSip;
|
|
405 |
|
|
406 |
/**
|
|
407 |
* Sip profile. May change. Own
|
|
408 |
*/
|
|
409 |
CSIPProfile* iSipProfile;
|
|
410 |
|
|
411 |
/**
|
|
412 |
* Observer
|
|
413 |
*/
|
|
414 |
MScpSipConnectionObserver* iObserver;
|
|
415 |
|
|
416 |
/**
|
|
417 |
* Registration request state
|
|
418 |
*/
|
|
419 |
TRegistrationRequestState iRegistrationRequestState;
|
|
420 |
|
|
421 |
/**
|
|
422 |
* Registration faile flag
|
|
423 |
*/
|
|
424 |
TInt iConnectionStateError;
|
|
425 |
|
|
426 |
/**
|
|
427 |
* Timeout timer. Owned.
|
|
428 |
*/
|
|
429 |
CPeriodic* iEnableTimeoutTimer;
|
|
430 |
|
|
431 |
/**
|
|
432 |
* Connection reserved for services' usage
|
|
433 |
*/
|
|
434 |
TBool iReserved;
|
|
435 |
|
|
436 |
/**
|
|
437 |
* Iap available offered
|
|
438 |
*/
|
|
439 |
TBool iIapAvailableOffered;
|
|
440 |
|
|
441 |
/**
|
|
442 |
* Profile is currently roaming
|
|
443 |
*/
|
|
444 |
TBool iProfileCurrentlyRoaming;
|
|
445 |
|
|
446 |
/**
|
|
447 |
* Connection monitor
|
|
448 |
*/
|
|
449 |
RConnectionMonitor iConnectionMonitor;
|
|
450 |
|
|
451 |
/**
|
|
452 |
* SIP connection
|
|
453 |
* Own.
|
|
454 |
*/
|
|
455 |
CSIPConnection* iSipConnection;
|
|
456 |
|
|
457 |
// This need to be cleaned to separate macro/header
|
|
458 |
#ifdef _DEBUG
|
|
459 |
friend class T_CScpSipConnection;
|
|
460 |
friend class T_CScpProfileHandler;
|
|
461 |
friend class T_CScpServiceManager;
|
|
462 |
friend class T_CScpVmbxHandler;
|
|
463 |
friend class T_CScpVoipHandler;
|
|
464 |
#endif
|
|
465 |
};
|
|
466 |
|
|
467 |
#endif // C_SCPSIPCONNECTION_H
|
|
468 |
|
|
469 |
// End of File
|