|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Utilities to get and set profile used with SWIS. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // USER |
|
20 #include "mussipprofilehandler.h" |
|
21 #include "musuid.hrh" |
|
22 #include "muslogger.h" |
|
23 #include "mussipprofileuser.h" |
|
24 |
|
25 // SYSTEM |
|
26 #include <sip.h> |
|
27 #include <sipservertransaction.h> |
|
28 #include <sipinvitedialogassoc.h> |
|
29 #include <sipprofile.h> |
|
30 #include <sipprofileregistry.h> |
|
31 #include <sipprofilealrcontroller.h> |
|
32 #include <uri8.h> |
|
33 |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMusSipProfileHandler* CMusSipProfileHandler::NewL( MMusSipProfileUser& aUser ) |
|
41 { |
|
42 CMusSipProfileHandler* self = |
|
43 new (ELeave) CMusSipProfileHandler( aUser ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMusSipProfileHandler::CMusSipProfileHandler( MMusSipProfileUser& aUser ) |
|
56 : iUser( aUser ) |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CMusSipProfileHandler::ConstructL() |
|
65 { |
|
66 MUS_LOG( "mus: [ENGINE] -> CMusSipProfileHandler::ConstructL()" ) |
|
67 |
|
68 // Use NULL Uid since we do not want to receive any requests. |
|
69 // All requests should be handled by MCE. |
|
70 iSip = CSIP::NewL( TUid::Null(), *this ); |
|
71 iProfileRegistry = CSIPProfileRegistry::NewL( *iSip, *this ); |
|
72 iProfileAlrController = |
|
73 CSipProfileAlrController::NewL( *iProfileRegistry , *this ); |
|
74 |
|
75 MUS_LOG( "mus: [ENGINE] <- CMusSipProfileHandler::ConstructL()" ) |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CMusSipProfileHandler::~CMusSipProfileHandler() |
|
84 { |
|
85 delete iProfileAlrController; |
|
86 delete iSipProfile; |
|
87 delete iProfileRegistry; |
|
88 delete iSip; |
|
89 MUS_LOG( "mus: [ENGINE] CMusSipProfileHandler::~CMusSipProfileHandler()" ) |
|
90 } |
|
91 |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CMusSipProfileHandler::CreateProfileL( TUint32 aSipProfileId ) |
|
98 { |
|
99 CSIPProfile* profile( NULL ); |
|
100 if ( aSipProfileId != 0 ) |
|
101 { |
|
102 profile = iProfileRegistry->ProfileL( aSipProfileId ); |
|
103 } |
|
104 else |
|
105 { |
|
106 profile = iProfileRegistry->DefaultProfileL(); |
|
107 } |
|
108 CleanupStack::PushL( profile ); |
|
109 TBool profileRegistered = EFalse; |
|
110 User::LeaveIfError( profile->GetParameter( KSIPProfileRegistered, |
|
111 profileRegistered ) ); |
|
112 CleanupStack::Pop( profile ); |
|
113 delete iSipProfile; |
|
114 iSipProfile = profile; |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CSIPProfile* CMusSipProfileHandler::Profile() |
|
123 { |
|
124 return iSipProfile; |
|
125 } |
|
126 |
|
127 #if 0 //TODO: should this be removed? |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 CSIPProfile& CMusSipProfileHandler::SipProfileL( TInt aSipProfileId ) |
|
133 { |
|
134 MUS_LOG1( "mus: [ENGINE] -> CMusSipProfileHandler::SipProfileL(),\ |
|
135 od #%d", aSipProfileId ) |
|
136 |
|
137 if ( !iSipProfile ) |
|
138 { |
|
139 if ( aSipProfileId != 0 ) |
|
140 { |
|
141 iSipProfile = iProfileRegistry->ProfileL( aSipProfileId ); |
|
142 } |
|
143 else |
|
144 { |
|
145 iSipProfile = iProfileRegistry->DefaultProfileL(); |
|
146 } |
|
147 } |
|
148 |
|
149 // The parameter val indicates if the profile can be immediately |
|
150 // used for creating a session, or if the client must wait for |
|
151 // the profile to be registered. |
|
152 TBool profileRegistered = EFalse; |
|
153 |
|
154 User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered, |
|
155 profileRegistered ) ); |
|
156 |
|
157 if ( !profileRegistered ) |
|
158 { |
|
159 |
|
160 #if (defined (__WINS__) || defined(__WINSCW__)) |
|
161 |
|
162 iProfileRegistry->EnableL( *iSipProfile, *this ); |
|
163 |
|
164 User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered, |
|
165 profileRegistered ) ); |
|
166 |
|
167 if( !profileRegistered ) |
|
168 { |
|
169 CActiveScheduler::Start(); |
|
170 |
|
171 User::LeaveIfError( iSipProfile->GetParameter( |
|
172 KSIPProfileRegistered, |
|
173 profileRegistered ) ); |
|
174 |
|
175 if ( !profileRegistered ) |
|
176 { |
|
177 User::Leave( KErrNotReady ); |
|
178 } |
|
179 } |
|
180 |
|
181 #else |
|
182 |
|
183 User::Leave( KErrNotReady ); |
|
184 |
|
185 #endif |
|
186 |
|
187 } |
|
188 |
|
189 |
|
190 MUS_LOG( "mus: [ENGINE] <- CMusSipProfileHandler::SipProfileL()" ) |
|
191 |
|
192 return *iSipProfile; |
|
193 } |
|
194 #endif |
|
195 |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 CUri8* CMusSipProfileHandler::UserFromProfileLC() |
|
202 { |
|
203 MUS_LOG( "mus: [ENGINE] -> CMusSipProfileHandler::UserFromProfileLC()" ); |
|
204 |
|
205 __ASSERT_ALWAYS( iSipProfile != NULL, User::Leave( KErrNotReady ) ); |
|
206 |
|
207 const MDesC8Array* aors = NULL; |
|
208 User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) ); |
|
209 if( !aors || aors->MdcaCount() <= 0 ) |
|
210 { |
|
211 User::Leave( KErrArgument ); |
|
212 } |
|
213 TUriParser8 parser; |
|
214 User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) ); |
|
215 MUS_LOG( "mus: [ENGINE] <- CMusSipProfileHandler::UserFromProfileLC()" ) |
|
216 |
|
217 return CUri8::NewLC( parser ); |
|
218 } |
|
219 |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CMusSipProfileHandler::RefreshIapAvailabilities() |
|
226 { |
|
227 TRAP_IGNORE( iProfileAlrController->RefreshIapAvailabilityL( ProfileId() ) ) |
|
228 } |
|
229 |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 void CMusSipProfileHandler::ProfileRegistryEventOccurred( |
|
236 TUint32 /*aProfileId*/, |
|
237 MSIPProfileRegistryObserver::TEvent /*aEvent*/ ) |
|
238 { |
|
239 } |
|
240 |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CMusSipProfileHandler::ProfileRegistryErrorOccurred( |
|
247 TUint32 /*aProfileId*/, |
|
248 TInt /*aError*/) |
|
249 { |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CMusSipProfileHandler::IncomingRequest( |
|
257 TUint32 /*aIapId*/, |
|
258 CSIPServerTransaction* aTransaction ) |
|
259 { |
|
260 // Ownership transferred, should not ever be called by SIP though |
|
261 delete aTransaction; |
|
262 } |
|
263 |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CMusSipProfileHandler::TimedOut( |
|
270 CSIPServerTransaction& /*aTransaction*/ ) |
|
271 { |
|
272 } |
|
273 |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 void CMusSipProfileHandler::IncomingRequest( |
|
280 CSIPServerTransaction* aTransaction ) |
|
281 { |
|
282 // Ownership transferred, should not ever be called by SIP though |
|
283 delete aTransaction; |
|
284 } |
|
285 |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void CMusSipProfileHandler::IncomingRequest( |
|
292 CSIPServerTransaction* aTransaction, |
|
293 CSIPDialog& /*aDialog*/) |
|
294 { |
|
295 // Ownership transferred, should not ever be called by SIP though |
|
296 delete aTransaction; |
|
297 } |
|
298 |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CMusSipProfileHandler::IncomingResponse( |
|
305 CSIPClientTransaction& /*aTransaction*/) |
|
306 { |
|
307 } |
|
308 |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CMusSipProfileHandler::IncomingResponse( |
|
315 CSIPClientTransaction& /*aTransaction*/, |
|
316 CSIPDialogAssocBase& /*aDialogAssoc*/) |
|
317 { |
|
318 } |
|
319 |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void CMusSipProfileHandler::IncomingResponse( |
|
326 CSIPClientTransaction& /*aTransaction*/, |
|
327 CSIPInviteDialogAssoc* aDialogAssoc) |
|
328 { |
|
329 // Ownership transferred, should not ever be called by SIP though |
|
330 delete aDialogAssoc; |
|
331 } |
|
332 |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CMusSipProfileHandler::IncomingResponse( |
|
339 CSIPClientTransaction& /*aTransaction*/, |
|
340 CSIPRegistrationBinding& /*aRegistration*/ ) |
|
341 { |
|
342 } |
|
343 |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CMusSipProfileHandler::ErrorOccured( |
|
350 TInt /*aError*/, |
|
351 CSIPTransactionBase& /*aTransaction*/ ) |
|
352 { |
|
353 } |
|
354 |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CMusSipProfileHandler::ErrorOccured( |
|
361 TInt /*aError*/, |
|
362 CSIPClientTransaction& /*aTransaction*/, |
|
363 CSIPRegistrationBinding& /*aRegistration*/ ) |
|
364 { |
|
365 } |
|
366 |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CMusSipProfileHandler::ErrorOccured( |
|
373 TInt /*aError*/, |
|
374 CSIPTransactionBase& /*aTransaction*/, |
|
375 CSIPDialogAssocBase& /*aDialogAssoc*/ ) |
|
376 { |
|
377 } |
|
378 |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 void CMusSipProfileHandler::ErrorOccured( |
|
385 TInt /*aError*/, |
|
386 CSIPRefresh& /*aSIPRefresh*/ ) |
|
387 { |
|
388 } |
|
389 |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void CMusSipProfileHandler::ErrorOccured( |
|
396 TInt /*aError*/, |
|
397 CSIPRegistrationBinding& /*aRegistration*/ ) |
|
398 { |
|
399 } |
|
400 |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 void CMusSipProfileHandler::ErrorOccured( |
|
407 TInt /*aError*/, |
|
408 CSIPDialogAssocBase& /*aDialogAssoc*/ ) |
|
409 { |
|
410 } |
|
411 |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CMusSipProfileHandler::InviteCompleted( |
|
418 CSIPClientTransaction& /*aTransaction*/ ) |
|
419 { |
|
420 } |
|
421 |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CMusSipProfileHandler::InviteCanceled( |
|
428 CSIPServerTransaction& /*aTransaction*/ ) |
|
429 { |
|
430 MUS_LOG( "mus: [ENGINE] CMusSipProfileHandler::CSIPServerTransaction") |
|
431 } |
|
432 |
|
433 |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 // ----------------------------------------------------------------------------- |
|
437 // |
|
438 void CMusSipProfileHandler::ConnectionStateChanged( |
|
439 CSIPConnection::TState /*aState*/ ) |
|
440 { |
|
441 } |
|
442 |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CMusSipProfileHandler::AlrEvent |
|
446 // From MSipProfileAlrObserver |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 void CMusSipProfileHandler::AlrEvent( |
|
450 MSipProfileAlrObserver::TEvent aEvent, |
|
451 TUint32 aProfileId, |
|
452 TUint32 /*aSnapId*/, |
|
453 TUint32 aIapId ) |
|
454 { |
|
455 if ( aEvent == MSipProfileAlrObserver::EIapAvailable ) |
|
456 { |
|
457 if ( iSipProfile && |
|
458 aProfileId == ProfileId() && |
|
459 !iUser.IsRoamingBetweenAPsAllowed() ) |
|
460 { |
|
461 // Disallow roaming only if the profile is used by MuS and |
|
462 // the MuS has an ongoing session |
|
463 TRAP_IGNORE( |
|
464 iProfileAlrController->DisallowMigrationL( aProfileId, aIapId ) ) |
|
465 } |
|
466 else |
|
467 { |
|
468 // In all other cases allow roaming |
|
469 TRAP_IGNORE( |
|
470 iProfileAlrController->AllowMigrationL( aProfileId, aIapId ) ) |
|
471 } |
|
472 } |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CMusSipProfileHandler::AlrError |
|
477 // From MSipProfileAlrObserver |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 void CMusSipProfileHandler::AlrError( |
|
481 TInt /*aError*/, |
|
482 TUint32 /*aProfileId*/, |
|
483 TUint32 /*aSnapId*/, |
|
484 TUint32 /*aIapId*/ ) |
|
485 { |
|
486 // Ignore ALR related errors as they should not happen |
|
487 // as migration is not allowed when |
|
488 // the instance of CMusSipProfileHandler exists |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 TUint32 CMusSipProfileHandler::ProfileId() const |
|
496 { |
|
497 TUint32 sipProfileId( 0 ); |
|
498 if ( iSipProfile ) |
|
499 { |
|
500 iSipProfile->GetParameter( KSIPProfileId, sipProfileId ); |
|
501 } |
|
502 return sipProfileId; |
|
503 } |