|
1 /* |
|
2 * Copyright (c) 2002-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 "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 #include <crcseprofileregistry.h> |
|
20 #include <spsettings.h> |
|
21 #include <spentry.h> |
|
22 #include <spproperty.h> |
|
23 #include <spsettingsvoiputils.h> |
|
24 #include <pressettingsapi.h> |
|
25 #include <XdmSettingsApi.h> |
|
26 #include <XdmSettingsCollection.h> |
|
27 |
|
28 #include "scpsettinghandler.h" |
|
29 #include "scpservice.h" |
|
30 #include "scpsubservice.h" |
|
31 #include "scplogger.h" |
|
32 #include "scputility.h" |
|
33 #include "scpservicehandlerbase.h" |
|
34 #include "sipconnectionprovideruids.hrh" |
|
35 #include "scpprofilehandler.h" |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CScpSettingHandler::CScpSettingHandler |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CScpSettingHandler::CScpSettingHandler( CScpProfileHandler& aProfileHandler ) : |
|
42 iProfileHandler( aProfileHandler ) |
|
43 { |
|
44 SCPLOGSTRING( "CScpSettingHandler::CScpSettingHandler" ); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CScpSettingHandler::NewL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CScpSettingHandler* CScpSettingHandler::NewL( CScpProfileHandler& aProfileHandler ) |
|
52 { |
|
53 SCPLOGSTRING( "CScpSettingHandler::NewL()" ); |
|
54 |
|
55 CScpSettingHandler* self = new( ELeave ) CScpSettingHandler( aProfileHandler ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CScpSettingHandler::~CScpSettingHandler |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CScpSettingHandler::~CScpSettingHandler() |
|
67 { |
|
68 SCPLOGSTRING( "CScpSettingHandler::~CScpSettingHandler" ); |
|
69 |
|
70 delete iSpsVoIPUtils; |
|
71 delete iSpSettings; |
|
72 delete iRcseProfileEntry; |
|
73 delete iRcseProfileRegistry; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CScpSettingHandler::ConstructL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CScpSettingHandler::ConstructL() |
|
81 { |
|
82 SCPLOGSTRING("CScpSettingHandler::ConstructL" ); |
|
83 |
|
84 iRcseProfileRegistry = CRCSEProfileRegistry::NewL(); |
|
85 iRcseProfileEntry = CRCSEProfileEntry::NewL(); |
|
86 |
|
87 iSpSettings = CSPSettings::NewL(); |
|
88 iSpsVoIPUtils = CSPSettingsVoIPUtils::NewL(); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CScpSettingHandler::GetSipProfileIdByTypeL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CScpSettingHandler::GetSipProfileIdByTypeL( TUint32 aServiceId, |
|
96 TCCHSubserviceType aSubServiceType, |
|
97 TUint32& aSipId ) const |
|
98 { |
|
99 SCPLOGSTRING3( "CScpSettingHandler::GetSipProfileIdByTypeL service id :%i type %d", |
|
100 aServiceId, aSubServiceType ); |
|
101 |
|
102 switch ( aSubServiceType ) |
|
103 { |
|
104 case ECCHVoIPSub: |
|
105 case ECCHIMSub: |
|
106 { |
|
107 GetVoipSipProfileIdL( aServiceId, aSipId ); |
|
108 } |
|
109 break; |
|
110 |
|
111 case ECCHVMBxSub: |
|
112 { |
|
113 GetVmbxSipProfileIdL( aServiceId, aSipId ); |
|
114 } |
|
115 break; |
|
116 |
|
117 case ECCHPresenceSub: |
|
118 { |
|
119 GetPresenceSipProfileIdL( aServiceId, aSipId ); |
|
120 } |
|
121 break; |
|
122 |
|
123 case ECCHUnknown: |
|
124 { |
|
125 GetUnknownSipProfileIdL( aServiceId, aSipId ); |
|
126 } |
|
127 break; |
|
128 |
|
129 default: |
|
130 __ASSERT_DEBUG( EFalse, User::Panic( KNullDesC, KErrGeneral ) ); |
|
131 break; |
|
132 } |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CScpSettingHandler::GetSPSettingsIntPropertyL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CScpSettingHandler::GetSPSettingsIntPropertyL( TUint32 aServiceId, |
|
140 TServicePropertyName aPropertyName, |
|
141 TInt& aProperty ) const |
|
142 { |
|
143 SCPLOGSTRING( "CScpSettingHandler::GetSPSettingsIntPropertyL" ); |
|
144 |
|
145 CSPEntry* entry = CSPEntry::NewLC(); |
|
146 TInt result = iSpSettings->FindEntryL( aServiceId, *entry ); |
|
147 |
|
148 if ( result == KErrNone ) |
|
149 { |
|
150 // Get asked property |
|
151 const CSPProperty* property = NULL; |
|
152 result = entry->GetProperty( property, aPropertyName ); |
|
153 |
|
154 if ( result == KErrNone && property ) |
|
155 { |
|
156 TInt value( 0 ); |
|
157 property->GetValue( value ); |
|
158 aProperty = value; |
|
159 } |
|
160 else |
|
161 { |
|
162 User::Leave( KErrNotFound ); |
|
163 } |
|
164 } |
|
165 else |
|
166 { |
|
167 User::Leave( KErrNotFound ); |
|
168 } |
|
169 |
|
170 CleanupStack::PopAndDestroy( entry ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CScpSettingHandler::GetVoipSipProfileIdL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CScpSettingHandler::GetVoipSipProfileIdL( TUint32 aServiceId, |
|
178 TUint32& aSipId ) const |
|
179 { |
|
180 SCPLOGSTRING( "CScpSettingHandler::GetVoipSipProfileIdL" ); |
|
181 |
|
182 RPointerArray<CRCSEProfileEntry> entries; |
|
183 |
|
184 // Push entries to cleanup stack |
|
185 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
186 &entries ) ); |
|
187 |
|
188 iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries ); |
|
189 |
|
190 if ( entries.Count() ) |
|
191 { |
|
192 CRCSEProfileEntry* entry = entries[0]; |
|
193 if ( entry->iIds.Count() > 0 ) |
|
194 { |
|
195 aSipId = entry->iIds[0].iProfileId; |
|
196 } |
|
197 else |
|
198 { |
|
199 User::Leave( KErrNotFound ); |
|
200 } |
|
201 } |
|
202 else |
|
203 { |
|
204 User::Leave( KErrNotFound ); |
|
205 } |
|
206 |
|
207 CleanupStack::PopAndDestroy( &entries ); |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CScpSettingHandler::GetVmbxSipProfileIdL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CScpSettingHandler::GetVmbxSipProfileIdL( TUint32 aServiceId, |
|
215 TUint32& aSipId ) const |
|
216 { |
|
217 SCPLOGSTRING( "CScpSettingHandler::GetVmbxSipProfileIdL" ); |
|
218 |
|
219 TInt sipId; |
|
220 GetSPSettingsIntPropertyL( aServiceId, ESubPropertyVMBXSettingsId, sipId ); |
|
221 aSipId = sipId; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CScpSettingHandler::GetPresenceSipProfileIdL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CScpSettingHandler::GetPresenceSipProfileIdL( TUint32 aServiceId, |
|
229 TUint32& aSipId ) const |
|
230 { |
|
231 SCPLOGSTRING( "CScpSettingHandler::GetPresenceSipProfileIdL" ); |
|
232 |
|
233 CSPEntry* entry = CSPEntry::NewLC(); |
|
234 TInt result = iSpSettings->FindEntryL( aServiceId, *entry ); |
|
235 if ( result == KErrNone ) |
|
236 { |
|
237 // Get presence setting id for presence service |
|
238 const CSPProperty* property = NULL; |
|
239 result = entry->GetProperty( property, ESubPropertyPresenceSettingsId ); |
|
240 |
|
241 if ( result == KErrNone && property ) |
|
242 { |
|
243 TInt presId; |
|
244 property->GetValue( presId ); |
|
245 |
|
246 //Found out what is sip id in presencesettings |
|
247 TPresSettingsSet mySet; |
|
248 User::LeaveIfError( PresSettingsApi::SettingsSetL( presId, mySet )); |
|
249 |
|
250 TInt sipId( 0 ); |
|
251 sipId = mySet.iSipProfile; |
|
252 aSipId = (TUint32)(sipId); |
|
253 } |
|
254 else |
|
255 { |
|
256 User::Leave( KErrNotFound ); |
|
257 } |
|
258 } |
|
259 else |
|
260 { |
|
261 User::Leave( KErrNotFound ); |
|
262 } |
|
263 |
|
264 CleanupStack::PopAndDestroy( entry ); |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CScpSettingHandler::GetUnknownSipProfileIdL |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CScpSettingHandler::GetUnknownSipProfileIdL( TUint32 aServiceId, |
|
272 TUint32& aSipId ) const |
|
273 { |
|
274 SCPLOGSTRING( "CScpSettingHandler::GetVoipSipProfileIdL" ); |
|
275 |
|
276 TInt result( KErrNone ); |
|
277 TUint32 genericSipId( KErrNone ); |
|
278 RArray< TInt > sipIds; |
|
279 CleanupClosePushL( sipIds ); |
|
280 |
|
281 TRAP( result, GetSipProfileIdByTypeL( aServiceId, ECCHVoIPSub, genericSipId ) ); |
|
282 |
|
283 if ( result == KErrNone ) |
|
284 { |
|
285 sipIds.AppendL( genericSipId ); |
|
286 } |
|
287 else if ( KErrNoMemory == result ) |
|
288 { |
|
289 User::Leave( KErrNoMemory ); |
|
290 } |
|
291 |
|
292 TRAP( result, GetSipProfileIdByTypeL( aServiceId, ECCHVMBxSub, genericSipId ) ); |
|
293 |
|
294 if ( result == KErrNone ) |
|
295 { |
|
296 sipIds.AppendL( genericSipId ); |
|
297 } |
|
298 else if ( KErrNoMemory == result ) |
|
299 { |
|
300 User::Leave( KErrNoMemory ); |
|
301 } |
|
302 |
|
303 TRAP( result, GetSipProfileIdByTypeL( aServiceId, ECCHPresenceSub, genericSipId ) ); |
|
304 |
|
305 if ( result == KErrNone ) |
|
306 { |
|
307 sipIds.AppendL( genericSipId ); |
|
308 } |
|
309 else if ( KErrNoMemory == result ) |
|
310 { |
|
311 User::Leave( KErrNoMemory ); |
|
312 } |
|
313 |
|
314 // Check if all the sip profiles ids for different subservice types |
|
315 // are the same |
|
316 if ( sipIds.Count() > 0 ) |
|
317 { |
|
318 result = KErrNone; |
|
319 aSipId = sipIds[0]; |
|
320 |
|
321 for( TInt i=0; i<sipIds.Count(); i++ ) |
|
322 { |
|
323 if( sipIds[i] != aSipId ) |
|
324 { |
|
325 result = KErrArgument; |
|
326 break; |
|
327 } |
|
328 } |
|
329 } |
|
330 else |
|
331 { |
|
332 // There wasn't any sip profile ids |
|
333 result = KErrNotFound; |
|
334 } |
|
335 |
|
336 CleanupStack::PopAndDestroy( &sipIds ); |
|
337 |
|
338 User::LeaveIfError( result ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CScpSettingHandler::UpdateSettingsL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CScpSettingHandler::UpdateSettingsL( CScpService& aService, |
|
346 TCCHSubserviceType aSubServiceType ) const |
|
347 { |
|
348 SCPLOGSTRING4( "CScpSettingHandler::UpdateSettingsL: 0x%x id: %i type: %d", |
|
349 &aService, aService.ServiceId(), aSubServiceType ); |
|
350 __ASSERT_DEBUG( aService.ServiceId() > KErrNotFound, |
|
351 User::Panic( KNullDesC, KErrNotFound ) ); |
|
352 |
|
353 if ( !aService.ContainsSubServiceType( ECCHVoIPSub ) && |
|
354 ( aSubServiceType == ECCHVoIPSub || aSubServiceType == ECCHUnknown ) ) |
|
355 { |
|
356 SCPLOGSTRING( "CScpSettingHandler::UpdateSettingsL voip " ); |
|
357 UpdateVoIPSettingsL( aService ); |
|
358 } |
|
359 |
|
360 if ( !aService.ContainsSubServiceType( ECCHIMSub ) && |
|
361 ( ECCHIMSub == aSubServiceType || ECCHUnknown == aSubServiceType ) ) |
|
362 { |
|
363 SCPLOGSTRING( "CScpSettingHandler::UpdateSettingsL IM" ); |
|
364 UpdateImSettingsL( aService ); |
|
365 } |
|
366 |
|
367 if ( !aService.ContainsSubServiceType( ECCHVMBxSub ) && |
|
368 ( aSubServiceType == ECCHVMBxSub || aSubServiceType == ECCHUnknown ) ) |
|
369 { |
|
370 SCPLOGSTRING( "CScpSettingHandler::UpdateSettingsL vmbx " ); |
|
371 UpdateVmbxSettingsL( aService ); |
|
372 } |
|
373 |
|
374 if ( !aService.ContainsSubServiceType( ECCHPresenceSub ) && |
|
375 (aSubServiceType == ECCHPresenceSub || aSubServiceType == ECCHUnknown ) ) |
|
376 { |
|
377 SCPLOGSTRING( "CScpSettingHandler::UpdateSettingsL presence x " ); |
|
378 UpdatePresenceSettingsL( aService ); |
|
379 } |
|
380 |
|
381 if ( aService.SubServiceCount() == 0 ) |
|
382 { |
|
383 User::Leave( KErrNotFound ); |
|
384 } |
|
385 } |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // CScpSettingHandler::UpdateXdmUsernameL |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CScpSettingHandler::UpdateXdmUsernameL( CScpService& aService, |
|
392 TCCHSubserviceType aSubServiceType, const TDesC8& aUsername ) |
|
393 { |
|
394 SCPLOGSTRING2( "CScpSettingHandler::UpdateXdmUsernameL, service id: %d", |
|
395 aService.ServiceId() ); |
|
396 |
|
397 if ( aService.ContainsSubServiceType( ECCHPresenceSub ) && |
|
398 ( aSubServiceType == ECCHPresenceSub || |
|
399 aSubServiceType == ECCHUnknown ) ) |
|
400 { |
|
401 CSPEntry* entry = CSPEntry::NewLC(); |
|
402 User::LeaveIfError( iSpSettings->FindEntryL( |
|
403 aService.ServiceId(), *entry ) ); |
|
404 |
|
405 if ( ArePresenceSettingsValid( *entry ) ) |
|
406 { |
|
407 TInt presenceSettingsId = GetPresenceSettingsId( *entry ); |
|
408 |
|
409 if ( presenceSettingsId != KErrNotFound ) |
|
410 { |
|
411 // Find out the sip profile that the presence is using |
|
412 TPresSettingsSet mySet; |
|
413 TRAPD( result, |
|
414 PresSettingsApi::SettingsSetL( |
|
415 presenceSettingsId, mySet ) ); |
|
416 |
|
417 if ( KErrNone == result && mySet.iSipProfile > 0 ) |
|
418 { |
|
419 // check XDM settings are valid |
|
420 CXdmSettingsCollection* xdmCollection = NULL; |
|
421 TRAPD( xdmResult, xdmCollection = |
|
422 TXdmSettingsApi::SettingsCollectionL( |
|
423 mySet.iXDMSetting ) ); |
|
424 |
|
425 if ( KErrNone == xdmResult && xdmCollection ) |
|
426 { |
|
427 CleanupStack::PushL( xdmCollection ); |
|
428 |
|
429 if ( iProfileHandler.ProfileExists( |
|
430 mySet.iSipProfile ) ) |
|
431 { |
|
432 RBuf8 formattedUsername; |
|
433 CleanupClosePushL( formattedUsername ); |
|
434 |
|
435 if( !TScpUtility::CheckSipUsername( aUsername ) ) |
|
436 { |
|
437 // Since username is returned with prefix and |
|
438 // domain, it needs to be possible to also set |
|
439 // it with prefix and domain. Strip prefix |
|
440 // and domain from user aor if found. Prefix |
|
441 // might be sip or sips so search by colon. |
|
442 User::LeaveIfError( |
|
443 TScpUtility::RemovePrefixAndDomain( |
|
444 aUsername, formattedUsername ) ); |
|
445 } |
|
446 else |
|
447 { |
|
448 formattedUsername.CreateL( |
|
449 aUsername.Length() ); |
|
450 formattedUsername.Copy( aUsername ); |
|
451 } |
|
452 |
|
453 RBuf userName; |
|
454 CleanupClosePushL( userName ); |
|
455 userName.CreateL( formattedUsername.Length() ); |
|
456 userName.Copy( formattedUsername ); |
|
457 |
|
458 // Update username to XDM-setting. |
|
459 TXdmSettingsApi::UpdatePropertyL( |
|
460 mySet.iXDMSetting, |
|
461 userName, |
|
462 EXdmPropAuthName ); |
|
463 |
|
464 CleanupStack::PopAndDestroy( &userName ); |
|
465 CleanupStack::PopAndDestroy( &formattedUsername ); |
|
466 |
|
467 SCPLOGSTRING( |
|
468 "CScpSettingHandler::UpdateXdmUsernameL - DONE" ); |
|
469 } |
|
470 else |
|
471 { |
|
472 User::Leave( KErrNotFound ); |
|
473 } |
|
474 |
|
475 CleanupStack::PopAndDestroy( xdmCollection ); |
|
476 } |
|
477 } |
|
478 } |
|
479 } |
|
480 CleanupStack::PopAndDestroy( entry ); |
|
481 } |
|
482 |
|
483 if ( aService.SubServiceCount() == 0 ) |
|
484 { |
|
485 User::Leave( KErrNotFound ); |
|
486 } |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CScpSettingHandler::UpdateXdmPasswordL |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 void CScpSettingHandler::UpdateXdmPasswordL( CScpService& aService, |
|
494 TCCHSubserviceType aSubServiceType, const TDesC8& aPassword ) |
|
495 { |
|
496 SCPLOGSTRING2( "CScpSettingHandler::UpdateXdmPasswordL, service id: %d", |
|
497 aService.ServiceId() ); |
|
498 |
|
499 if ( aService.ContainsSubServiceType( ECCHPresenceSub ) && |
|
500 ( aSubServiceType == ECCHPresenceSub || |
|
501 aSubServiceType == ECCHUnknown ) ) |
|
502 { |
|
503 SCPLOGSTRING( "CScpSettingHandler::UpdateXdmPasswordL, presence" ); |
|
504 |
|
505 CSPEntry* entry = CSPEntry::NewLC(); |
|
506 User::LeaveIfError( iSpSettings->FindEntryL( |
|
507 aService.ServiceId(), *entry ) ); |
|
508 |
|
509 if ( ArePresenceSettingsValid( *entry ) ) |
|
510 { |
|
511 TInt presenceSettingsId = GetPresenceSettingsId( *entry ); |
|
512 |
|
513 if ( presenceSettingsId != KErrNotFound ) |
|
514 { |
|
515 // Find out the sip profile that the presence is using |
|
516 TPresSettingsSet mySet; |
|
517 |
|
518 TRAPD( result, |
|
519 PresSettingsApi::SettingsSetL( |
|
520 presenceSettingsId, mySet ) ); |
|
521 |
|
522 if ( KErrNone == result && mySet.iSipProfile > 0 ) |
|
523 { |
|
524 // check XDM settings are valid |
|
525 CXdmSettingsCollection* xdmCollection = NULL; |
|
526 TRAPD( xdmResult, xdmCollection = |
|
527 TXdmSettingsApi::SettingsCollectionL( |
|
528 mySet.iXDMSetting ) ); |
|
529 |
|
530 if ( KErrNone == xdmResult && xdmCollection ) |
|
531 { |
|
532 CleanupStack::PushL( xdmCollection ); |
|
533 |
|
534 if ( iProfileHandler.ProfileExists( |
|
535 mySet.iSipProfile ) ) |
|
536 { |
|
537 RBuf passwordBuf; |
|
538 CleanupClosePushL( passwordBuf ); |
|
539 passwordBuf.CreateL( aPassword.Length() ); |
|
540 passwordBuf.Copy( aPassword ); |
|
541 |
|
542 // Update password to XDM-setting |
|
543 TXdmSettingsApi::UpdatePropertyL( |
|
544 mySet.iXDMSetting, |
|
545 passwordBuf, |
|
546 EXdmPropAuthSecret ); |
|
547 |
|
548 CleanupStack::PopAndDestroy( &passwordBuf ); |
|
549 |
|
550 SCPLOGSTRING( |
|
551 "CScpSettingHandler::UpdateXdmPasswordL - DONE" ); |
|
552 } |
|
553 else |
|
554 { |
|
555 User::Leave( KErrNotFound ); |
|
556 } |
|
557 |
|
558 CleanupStack::PopAndDestroy( xdmCollection ); |
|
559 } |
|
560 } |
|
561 } |
|
562 } |
|
563 CleanupStack::PopAndDestroy( entry ); |
|
564 } |
|
565 |
|
566 if ( aService.SubServiceCount() == 0 ) |
|
567 { |
|
568 User::Leave( KErrNotFound ); |
|
569 } |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CScpSettingHandler::UpdatePresenceSettingsL |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void CScpSettingHandler::UpdatePresenceSettingsL( CScpService& aService ) const |
|
577 { |
|
578 SCPLOGSTRING( "CScpSettingHandler::UpdatePresenceSettingsL" ); |
|
579 |
|
580 CSPEntry* entry = CSPEntry::NewLC(); |
|
581 |
|
582 if ( iSpSettings->FindEntryL( aService.ServiceId(), *entry ) == KErrNone ) |
|
583 { |
|
584 if ( ArePresenceSettingsValid( *entry ) ) |
|
585 { |
|
586 TInt presenceSettingsId = GetPresenceSettingsId( *entry ); |
|
587 |
|
588 if ( presenceSettingsId != KErrNotFound ) |
|
589 { |
|
590 // Find out the sip profile that the presence is using |
|
591 TPresSettingsSet mySet; |
|
592 |
|
593 TRAPD( result, |
|
594 PresSettingsApi::SettingsSetL( presenceSettingsId, mySet ) ); |
|
595 |
|
596 if ( KErrNone == result && mySet.iSipProfile > 0 ) |
|
597 { |
|
598 // check XDM settings are valid |
|
599 CXdmSettingsCollection* xdmCollection = NULL; |
|
600 TRAPD( xdmResult, xdmCollection = |
|
601 TXdmSettingsApi::SettingsCollectionL( mySet.iXDMSetting ) ); |
|
602 |
|
603 if ( KErrNone == xdmResult && xdmCollection ) |
|
604 { |
|
605 CleanupStack::PushL( xdmCollection ); |
|
606 |
|
607 if ( iProfileHandler.ProfileExists( mySet.iSipProfile ) ) |
|
608 { |
|
609 CScpSubService& presenceService = aService.AddSubServiceL( ECCHPresenceSub ); |
|
610 |
|
611 presenceService.SetSipProfileId( mySet.iSipProfile ); |
|
612 } |
|
613 else |
|
614 { |
|
615 User::Leave( KErrNotFound ); |
|
616 } |
|
617 |
|
618 CleanupStack::PopAndDestroy( xdmCollection ); |
|
619 } |
|
620 } |
|
621 } |
|
622 } |
|
623 } |
|
624 CleanupStack::PopAndDestroy( entry ); |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CScpSettingHandler::ArePresenceSettingsValid |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TBool CScpSettingHandler::ArePresenceSettingsValid( const CSPEntry& aEntry ) const |
|
632 { |
|
633 SCPLOGSTRING( "CScpSettingHandler::ArePresenceSettingsValid" ); |
|
634 |
|
635 const CSPProperty* property = NULL; |
|
636 |
|
637 // Make sure that the this is the correct plugin |
|
638 TInt result = aEntry.GetProperty( property, EPropertyPresenceSubServicePluginId ); |
|
639 |
|
640 if ( result == KErrNone && property ) |
|
641 { |
|
642 TInt pluginId = 0; |
|
643 property->GetValue( pluginId ); |
|
644 |
|
645 SCPLOGSTRING2( "Presence sub service plugin UID: 0x%x", pluginId ); |
|
646 |
|
647 if ( pluginId == KSIPConnectivityPluginImplUid ) |
|
648 { |
|
649 return ETrue; |
|
650 } |
|
651 } |
|
652 |
|
653 return EFalse; |
|
654 } |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CScpSettingHandler::GetPresenceSettingsId |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 TInt CScpSettingHandler::GetPresenceSettingsId( const CSPEntry& aEntry ) const |
|
661 { |
|
662 SCPLOGSTRING( "CScpSettingHandler::GetPresenceSettingsId" ); |
|
663 |
|
664 const CSPProperty* property = NULL; |
|
665 TInt result = aEntry.GetProperty( property, ESubPropertyPresenceSettingsId ); |
|
666 |
|
667 if ( property && result == KErrNone ) |
|
668 { |
|
669 TInt presenceSettingsId = 0; |
|
670 result = property->GetValue( presenceSettingsId ); |
|
671 |
|
672 if ( result == KErrNone ) |
|
673 { |
|
674 return presenceSettingsId; |
|
675 } |
|
676 } |
|
677 |
|
678 return KErrNotFound; |
|
679 } |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CScpSettingHandler::UpdateVoIPSettingsL |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 void CScpSettingHandler::UpdateVoIPSettingsL( CScpService& aService ) const |
|
686 { |
|
687 SCPLOGSTRING( "CScpSettingHandler::UpdateVoIPSettingsL" ); |
|
688 |
|
689 CSPEntry* entry = CSPEntry::NewLC(); |
|
690 |
|
691 if ( iSpSettings->FindEntryL( aService.ServiceId(), *entry ) == KErrNone ) |
|
692 { |
|
693 if ( AreVoipSettingsValid( *entry ) ) |
|
694 { |
|
695 RPointerArray<CRCSEProfileEntry> entries; |
|
696 // Push entries to cleanup stack |
|
697 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
698 &entries ) ); |
|
699 |
|
700 iRcseProfileRegistry->FindByServiceIdL( aService.ServiceId(), entries ); |
|
701 |
|
702 TInt idsCount = entries.Count(); |
|
703 |
|
704 if ( idsCount > 0 ) |
|
705 { |
|
706 CRCSEProfileEntry* profileEntry = entries[ 0 ]; |
|
707 |
|
708 if ( profileEntry && profileEntry->iIds.Count() ) |
|
709 { |
|
710 TSettingIds& settingId = profileEntry->iIds[ 0 ]; |
|
711 |
|
712 __ASSERT_DEBUG( settingId.iProfileId > 0, |
|
713 User::Panic( KNullDesC, KErrGeneral ) ); |
|
714 |
|
715 if ( iProfileHandler.ProfileExists( settingId.iProfileId ) ) |
|
716 { |
|
717 CScpSubService& voipService = aService.AddSubServiceL( ECCHVoIPSub ); |
|
718 |
|
719 voipService.SetSipProfileId( settingId.iProfileId ); |
|
720 } |
|
721 else |
|
722 { |
|
723 User::Leave( KErrNotFound ); |
|
724 } |
|
725 } |
|
726 } |
|
727 |
|
728 CleanupStack::PopAndDestroy( &entries ); |
|
729 } |
|
730 } |
|
731 |
|
732 CleanupStack::PopAndDestroy( entry ); |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CScpSettingHandler::AreVoipSettingsValid |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 TBool CScpSettingHandler::AreVoipSettingsValid( const CSPEntry& aEntry ) const |
|
740 { |
|
741 SCPLOGSTRING( "CScpSettingHandler::AreVoipSettingsValid" ); |
|
742 |
|
743 const CSPProperty* property = NULL; |
|
744 |
|
745 // Make sure that the this is the correct plugin |
|
746 TInt result = aEntry.GetProperty( property, EPropertyVoIPSubServicePluginId ); |
|
747 |
|
748 if ( result == KErrNone && property ) |
|
749 { |
|
750 TInt pluginId = 0; |
|
751 property->GetValue( pluginId ); |
|
752 |
|
753 SCPLOGSTRING3( "VoIP sub service plugin UID: 0x%x this 0x%x", pluginId, KSIPConnectivityPluginImplUid ); |
|
754 |
|
755 if ( pluginId == KSIPConnectivityPluginImplUid ) |
|
756 { |
|
757 return ETrue; |
|
758 } |
|
759 } |
|
760 |
|
761 return EFalse; |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CScpSettingHandler::UpdateVmbxSettingsL |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 void CScpSettingHandler::UpdateVmbxSettingsL( CScpService& aService ) const |
|
769 { |
|
770 SCPLOGSTRING( "CScpSettingHandler::UpdateVmbxSettingsL" ); |
|
771 |
|
772 CSPEntry* entry = CSPEntry::NewLC(); |
|
773 |
|
774 if ( iSpSettings->FindEntryL( aService.ServiceId(), *entry ) == KErrNone ) |
|
775 { |
|
776 if( AreVmbxSettingsValid( *entry ) ) |
|
777 { |
|
778 const CSPProperty* property = NULL; |
|
779 |
|
780 // Get sip profile id for the vmbx service |
|
781 TInt result = entry->GetProperty( property, ESubPropertyVMBXSettingsId ); |
|
782 |
|
783 if ( result == KErrNone && property ) |
|
784 { |
|
785 TInt sipProfileId( 0 ); |
|
786 property->GetValue( sipProfileId ); |
|
787 |
|
788 __ASSERT_DEBUG( sipProfileId > 0, User::Panic( KNullDesC, KErrGeneral ) ); |
|
789 |
|
790 if ( iProfileHandler.ProfileExists( sipProfileId ) ) |
|
791 { |
|
792 CScpSubService& vmbxService = aService.AddSubServiceL( ECCHVMBxSub ); |
|
793 |
|
794 vmbxService.SetSipProfileId( sipProfileId ); |
|
795 } |
|
796 else |
|
797 { |
|
798 User::Leave( KErrNotFound ); |
|
799 } |
|
800 } |
|
801 } |
|
802 } |
|
803 |
|
804 CleanupStack::PopAndDestroy( entry ); |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CScpSettingHandler::AreVmbxSettingsValid |
|
809 // ----------------------------------------------------------------------------- |
|
810 // |
|
811 TBool CScpSettingHandler::AreVmbxSettingsValid( const CSPEntry& aEntry ) const |
|
812 { |
|
813 SCPLOGSTRING( "CScpSettingHandler::AreVmbxSettingsValid" ); |
|
814 |
|
815 const CSPProperty* property = NULL; |
|
816 |
|
817 // Make sure that the this is the correct plugin |
|
818 TInt result = aEntry.GetProperty( property, EPropertyVMBXSubServicePluginId ); |
|
819 |
|
820 if ( result == KErrNone && property ) |
|
821 { |
|
822 TInt pluginId = 0; |
|
823 property->GetValue( pluginId ); |
|
824 |
|
825 SCPLOGSTRING2( "VMBx sub service plugin UID: 0x%x", pluginId ); |
|
826 |
|
827 if ( pluginId == KSIPConnectivityPluginImplUid ) |
|
828 { |
|
829 // Make sure that the MWI address is found |
|
830 result = aEntry.GetProperty( property, ESubPropertyVMBXMWIAddress ); |
|
831 |
|
832 if ( result == KErrNone && property ) |
|
833 { |
|
834 return ETrue; |
|
835 } |
|
836 } |
|
837 } |
|
838 |
|
839 return EFalse; |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CScpSettingHandler::ServiceExistsL |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 TBool CScpSettingHandler::ServiceExistsL( TUint32 aServiceId ) const |
|
847 { |
|
848 SCPLOGSTRING2( "CScpSettingHandler::ServiceExistsL id: %d", aServiceId ); |
|
849 |
|
850 TBool serviceExists( EFalse ); |
|
851 |
|
852 RIdArray serviceIds; |
|
853 iSpSettings->FindServiceIdsL( serviceIds ); |
|
854 |
|
855 for ( TInt i=0; i<serviceIds.Count(); i++ ) |
|
856 { |
|
857 if ( aServiceId == serviceIds[ i ] ) |
|
858 { |
|
859 serviceExists = ETrue; |
|
860 break; |
|
861 } |
|
862 } |
|
863 |
|
864 serviceIds.Close(); |
|
865 return serviceExists; |
|
866 } |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // CScpSettingHandler::GetServiceId |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 TInt CScpSettingHandler::GetServiceIds( TUint32 aSipId, |
|
873 RArray< TUint32 >& aServiceIds ) const |
|
874 { |
|
875 SCPLOGSTRING2( "CScpSettingHandler::GetServiceIds sip id: %d", aSipId ); |
|
876 |
|
877 TRAPD( result, GetServiceIdsL( aSipId, aServiceIds ) ); |
|
878 |
|
879 return result; |
|
880 } |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CScpSettingHandler::GetServiceIdsL |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 void CScpSettingHandler::GetServiceIdsL( TUint32 aSipId, |
|
887 RArray< TUint32 >& aServiceIds ) const |
|
888 { |
|
889 SCPLOGSTRING2( "CScpSettingHandler::GetServiceIdsL sip id: %d", aSipId ); |
|
890 |
|
891 RArray<TUint32> profileIdArray; |
|
892 CleanupClosePushL( profileIdArray ); |
|
893 |
|
894 iRcseProfileRegistry->GetAllIdsL( profileIdArray ); |
|
895 |
|
896 TBool found( EFalse ); |
|
897 |
|
898 //VoIP profile count |
|
899 for ( TInt i=0; i < profileIdArray.Count() && !found; i++ ) |
|
900 { |
|
901 // profileEntry is reseted by rcse before the search |
|
902 iRcseProfileRegistry->FindL( profileIdArray[i], |
|
903 *iRcseProfileEntry ); |
|
904 |
|
905 for ( TInt j=0; j < iRcseProfileEntry->iIds.Count(); j++ ) |
|
906 { |
|
907 if ( aSipId == iRcseProfileEntry->iIds[j].iProfileId ) |
|
908 { |
|
909 aServiceIds.Append( profileIdArray[i] ); |
|
910 } |
|
911 } |
|
912 } |
|
913 |
|
914 if ( !aServiceIds.Count() ) |
|
915 { |
|
916 User::Leave( KErrNotFound ); |
|
917 } |
|
918 |
|
919 CleanupStack::PopAndDestroy( &profileIdArray ); |
|
920 } |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // CScpSettingHandler::IsVoIPSupported |
|
924 // ----------------------------------------------------------------------------- |
|
925 // |
|
926 TBool CScpSettingHandler::IsVoIPSupported() const |
|
927 { |
|
928 return iSpsVoIPUtils->IsVoIPSupported(); |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CScpSettingHandler::IsUahTerminalTypeDefinedL |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 TBool CScpSettingHandler::IsUahTerminalTypeDefinedL( |
|
936 TUint32 aServiceId ) const |
|
937 { |
|
938 TBool defined( EFalse ); |
|
939 RPointerArray<CRCSEProfileEntry> entries; |
|
940 |
|
941 // Push entries to cleanup stack |
|
942 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
943 &entries ) ); |
|
944 |
|
945 iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries ); |
|
946 |
|
947 if ( entries.Count() ) |
|
948 { |
|
949 // SIP VoIP User Agent header: terminal type display |
|
950 defined = entries[0]->iSIPVoIPUAHTerminalType; |
|
951 } |
|
952 |
|
953 CleanupStack::PopAndDestroy( &entries ); |
|
954 return defined; |
|
955 } |
|
956 |
|
957 // ----------------------------------------------------------------------------- |
|
958 // CScpSettingHandler::IsUahWLANMacDefinedL |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 TBool CScpSettingHandler::IsUahWLANMacDefinedL( |
|
962 TUint32 aServiceId ) const |
|
963 { |
|
964 TBool defined( EFalse ); |
|
965 RPointerArray<CRCSEProfileEntry> entries; |
|
966 |
|
967 // Push entries to cleanup stack |
|
968 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
969 &entries ) ); |
|
970 |
|
971 iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries ); |
|
972 |
|
973 if ( entries.Count() ) |
|
974 { |
|
975 // SIP VoIP User Agent header WLAN MAC address display |
|
976 defined = entries[0]->iSIPVoIPUAHeaderWLANMAC; |
|
977 } |
|
978 |
|
979 CleanupStack::PopAndDestroy( &entries ); |
|
980 return defined; |
|
981 } |
|
982 |
|
983 // ----------------------------------------------------------------------------- |
|
984 // CScpSettingHandler::UahStringLengthL |
|
985 // ----------------------------------------------------------------------------- |
|
986 // |
|
987 TInt CScpSettingHandler::UahStringLengthL( |
|
988 TUint32 aServiceId ) const |
|
989 { |
|
990 TBool length( KErrNone ); |
|
991 RPointerArray<CRCSEProfileEntry> entries; |
|
992 |
|
993 // Push entries to cleanup stack |
|
994 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
995 &entries ) ); |
|
996 |
|
997 iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries ); |
|
998 |
|
999 if ( entries.Count() ) |
|
1000 { |
|
1001 // SIP VoIP User Agent header string |
|
1002 length = entries[0]->iSIPVoIPUAHeaderString.Length(); |
|
1003 } |
|
1004 |
|
1005 CleanupStack::PopAndDestroy( &entries ); |
|
1006 return length; |
|
1007 } |
|
1008 |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // CScpSettingHandler::IsVoIPOverWcdmaAllowedL |
|
1011 // ----------------------------------------------------------------------------- |
|
1012 // |
|
1013 TBool CScpSettingHandler::IsVoIPOverWcdmaAllowedL( |
|
1014 TUint32 aServiceId ) const |
|
1015 { |
|
1016 SCPLOGSTRING( "CScpSettingHandler::IsVoIPOverWcdmaAllowedL IN" ); |
|
1017 |
|
1018 TBool response( EFalse ); |
|
1019 RPointerArray<CRCSEProfileEntry> entries; |
|
1020 |
|
1021 // Push entries to cleanup stack |
|
1022 CleanupStack::PushL( TCleanupItem( TScpUtility::ResetAndDestroyEntries, |
|
1023 &entries ) ); |
|
1024 |
|
1025 iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries ); |
|
1026 |
|
1027 if ( entries.Count() ) |
|
1028 { |
|
1029 response = CRCSEProfileEntry::EOn == entries[ 0 ]->iAllowVoIPoverWCDMA; |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 User::Leave( KErrNotFound ); |
|
1034 } |
|
1035 |
|
1036 CleanupStack::PopAndDestroy( &entries ); |
|
1037 |
|
1038 SCPLOGSTRING2( |
|
1039 "CScpSettingHandler::IsVoIPOverWcdmaAllowedL : allowed : %d OUT", |
|
1040 response ); |
|
1041 return response; |
|
1042 } |
|
1043 |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // CScpSettingHandler::UpdateImSettingsL |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // |
|
1048 void CScpSettingHandler::UpdateImSettingsL( CScpService& aService ) const |
|
1049 { |
|
1050 SCPLOGSTRING( "CScpSettingHandler::UpdateImSettingsL" ); |
|
1051 |
|
1052 CSPEntry* entry = CSPEntry::NewLC(); |
|
1053 |
|
1054 if ( KErrNone == iSpSettings->FindEntryL( aService.ServiceId(), *entry ) ) |
|
1055 { |
|
1056 if ( AreImSettingsValid( *entry ) ) |
|
1057 { |
|
1058 RPointerArray<CRCSEProfileEntry> entries; |
|
1059 // Push entries to cleanup stack |
|
1060 CleanupStack::PushL( TCleanupItem( |
|
1061 TScpUtility::ResetAndDestroyEntries, &entries ) ); |
|
1062 |
|
1063 iRcseProfileRegistry->FindByServiceIdL( aService.ServiceId(), |
|
1064 entries ); |
|
1065 TInt idsCount = entries.Count(); |
|
1066 |
|
1067 if ( idsCount > 0 ) |
|
1068 { |
|
1069 CRCSEProfileEntry* profileEntry = entries[ 0 ]; |
|
1070 |
|
1071 if ( profileEntry && profileEntry->iIds.Count() ) |
|
1072 { |
|
1073 TSettingIds& settingId = profileEntry->iIds[ 0 ]; |
|
1074 |
|
1075 __ASSERT_DEBUG( settingId.iProfileId > 0, |
|
1076 User::Panic( KNullDesC, KErrGeneral ) ); |
|
1077 |
|
1078 if ( iProfileHandler.ProfileExists( settingId.iProfileId ) ) |
|
1079 { |
|
1080 CScpSubService& imSubService = aService.AddSubServiceL( |
|
1081 ECCHIMSub ); |
|
1082 imSubService.SetSipProfileId( settingId.iProfileId ); |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 User::Leave( KErrNotFound ); |
|
1087 } |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 CleanupStack::PopAndDestroy( &entries ); |
|
1092 } |
|
1093 } |
|
1094 |
|
1095 CleanupStack::PopAndDestroy( entry ); |
|
1096 } |
|
1097 |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // CScpSettingHandler::AreImSettingsValid |
|
1100 // ----------------------------------------------------------------------------- |
|
1101 // |
|
1102 TBool CScpSettingHandler::AreImSettingsValid( const CSPEntry& aEntry ) const |
|
1103 { |
|
1104 SCPLOGSTRING( "CScpSettingHandler::AreImSettingsValid" ); |
|
1105 |
|
1106 const CSPProperty* property( NULL ); |
|
1107 TBool imFeatureEnabled = ( KErrNone == aEntry.GetProperty( |
|
1108 property, ESubPropertyIMLaunchUid ) ) && property; |
|
1109 if ( !imFeatureEnabled ) |
|
1110 { |
|
1111 return EFalse; |
|
1112 } |
|
1113 |
|
1114 // Make sure that this is the correct plugin |
|
1115 TInt result = aEntry.GetProperty( property, |
|
1116 EPropertyIMSubServicePluginId ); |
|
1117 |
|
1118 if ( KErrNone == result && property ) |
|
1119 { |
|
1120 TInt pluginId = 0; |
|
1121 property->GetValue( pluginId ); |
|
1122 |
|
1123 SCPLOGSTRING3( "IM Subservice plugin UID: 0x%x this 0x%x", |
|
1124 pluginId, KSIPConnectivityPluginImplUid ); |
|
1125 |
|
1126 if ( KSIPConnectivityPluginImplUid == pluginId ) |
|
1127 { |
|
1128 return ETrue; |
|
1129 } |
|
1130 } |
|
1131 |
|
1132 return EFalse; |
|
1133 } |
|
1134 |
|
1135 // End of File |