|
1 /* |
|
2 * Copyright (c) 2009-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 * Keeps track of the general destination/connection method structure in |
|
16 * database. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include <metadatabase.h> |
|
22 #include <commsdattypesv1_1.h> |
|
23 #include <datamobilitycommsdattypes.h> |
|
24 #include <cmpluginembdestinationdef.h> |
|
25 #include <wlancontainer.h> |
|
26 |
|
27 #include "cmminstancemapping.h" |
|
28 #include "cmpluginbaseeng.h" |
|
29 |
|
30 #include "OstTraceDefinitions.h" |
|
31 #ifdef OST_TRACE_COMPILER_IN_USE |
|
32 #include "cmminstancemappingTraces.h" |
|
33 #endif |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Two phased construction. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CDestination* CDestination::NewL() |
|
41 { |
|
42 OstTraceFunctionEntry0( CDESTINATION_NEWL_ENTRY ); |
|
43 |
|
44 CDestination* self = CDestination::NewLC(); |
|
45 CleanupStack::Pop( self ); |
|
46 |
|
47 OstTraceFunctionExit0( CDESTINATION_NEWL_EXIT ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Two phased construction. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CDestination* CDestination::NewLC() |
|
56 { |
|
57 OstTraceFunctionEntry0( CDESTINATION_NEWLC_ENTRY ); |
|
58 |
|
59 CDestination* self = new( ELeave ) CDestination(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 |
|
63 OstTraceFunctionExit0( CDESTINATION_NEWLC_EXIT ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CDestination::~CDestination() |
|
72 { |
|
73 OstTraceFunctionEntry0( CDESTINATION_CDESTINATION_ENTRY ); |
|
74 |
|
75 iConnMethodItemArray.Close(); |
|
76 iUnsupportedConnMethods.Close(); |
|
77 |
|
78 OstTraceFunctionExit0( CDESTINATION_CDESTINATION_EXIT ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Constructor. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CDestination::CDestination() |
|
86 { |
|
87 OstTraceFunctionEntry0( DUP1_CDESTINATION_CDESTINATION_ENTRY ); |
|
88 |
|
89 iId = 0; |
|
90 iMetadata = 0; |
|
91 |
|
92 OstTraceFunctionExit0( DUP1_CDESTINATION_CDESTINATION_EXIT ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Second phase constructor. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CDestination::ConstructL() |
|
100 { |
|
101 OstTraceFunctionEntry0( CDESTINATION_CONSTRUCTL_ENTRY ); |
|
102 OstTraceFunctionExit0( CDESTINATION_CONSTRUCTL_EXIT ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Two phased construction. |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CCmmInstanceMapping* CCmmInstanceMapping::NewL( CCmmCache& aCache ) |
|
110 { |
|
111 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_NEWL_ENTRY ); |
|
112 |
|
113 CCmmInstanceMapping* self = CCmmInstanceMapping::NewLC( aCache ); |
|
114 CleanupStack::Pop( self ); |
|
115 |
|
116 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_NEWL_EXIT ); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Two phased construction. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CCmmInstanceMapping* CCmmInstanceMapping::NewLC( CCmmCache& aCache ) |
|
125 { |
|
126 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_NEWLC_ENTRY ); |
|
127 |
|
128 CCmmInstanceMapping* self = new( ELeave ) CCmmInstanceMapping( aCache ); |
|
129 CleanupStack::PushL( self ); |
|
130 self->ConstructL(); |
|
131 |
|
132 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_NEWLC_EXIT ); |
|
133 return self; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Destructor. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 CCmmInstanceMapping::~CCmmInstanceMapping() |
|
141 { |
|
142 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_ENTRY ); |
|
143 |
|
144 iConnMethodItemArray.Close(); |
|
145 iUnsupportedConnMethods.Close(); |
|
146 iDestinations.ResetAndDestroy(); |
|
147 iDeletedConnMethods.Close(); |
|
148 iDeletedDestinations.Close(); |
|
149 |
|
150 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_EXIT ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // Constructor. |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 CCmmInstanceMapping::CCmmInstanceMapping( CCmmCache& aCache ) : iCache( aCache ) |
|
158 { |
|
159 OstTraceFunctionEntry0( DUP1_CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_ENTRY ); |
|
160 iEasyWlanId = 0; |
|
161 OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_EXIT ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // Second phase constructor. |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CCmmInstanceMapping::ConstructL() |
|
169 { |
|
170 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONSTRUCTL_ENTRY ); |
|
171 |
|
172 // Read connection methods from database and find the supported ones. |
|
173 ReadAndValidateConnMethodsL(); |
|
174 // Read destinations from database. |
|
175 ReadAndValidateDestinationsL(); |
|
176 |
|
177 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONSTRUCTL_EXIT ); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // Resets arrays and reads CMs and Connection Methods |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CCmmInstanceMapping::RefreshL() |
|
185 { |
|
186 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REFRESHL_ENTRY ); |
|
187 |
|
188 ReadAndValidateConnMethodsL(); |
|
189 ReadAndValidateDestinationsL(); |
|
190 |
|
191 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REFRESHL_EXIT ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Check if the given ID is a valid existing destination ID. |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 TBool CCmmInstanceMapping::ValidDestinationId( const TUint32 aId ) const |
|
199 { |
|
200 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDDESTINATIONID_ENTRY ); |
|
201 |
|
202 TBool validity( EFalse ); |
|
203 |
|
204 if ( aId > 0 ) |
|
205 { |
|
206 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
207 { |
|
208 if ( iDestinations[i]->iId == aId ) |
|
209 { |
|
210 validity = ETrue; |
|
211 break; |
|
212 } |
|
213 } |
|
214 } |
|
215 |
|
216 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDDESTINATIONID_EXIT ); |
|
217 return validity; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // Check if the given ID is a valid existing connection method ID. |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 TBool CCmmInstanceMapping::ValidConnMethodId( const TUint32 aId ) const |
|
225 { |
|
226 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDCONNMETHODID_ENTRY ); |
|
227 |
|
228 TBool validity( EFalse ); |
|
229 |
|
230 if ( aId > 0 ) |
|
231 { |
|
232 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
233 { |
|
234 if ( iConnMethodItemArray[i].iId == aId ) |
|
235 { |
|
236 validity = ETrue; |
|
237 break; |
|
238 } |
|
239 } |
|
240 } |
|
241 |
|
242 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDCONNMETHODID_EXIT ); |
|
243 return validity; |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // Check if the given ID is a valid existing unsupported connection method ID. |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 TBool CCmmInstanceMapping::UnsupportedConnMethodId( const TUint32 aId ) const |
|
251 { |
|
252 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_UNSUPPORTEDCONNMETHODID_ENTRY ); |
|
253 |
|
254 TBool validity( EFalse ); |
|
255 |
|
256 if ( aId > 0 ) |
|
257 { |
|
258 for ( TInt i = 0; i < iUnsupportedConnMethods.Count(); i++ ) |
|
259 { |
|
260 if ( iUnsupportedConnMethods[i] == aId ) |
|
261 { |
|
262 validity = ETrue; |
|
263 break; |
|
264 } |
|
265 } |
|
266 } |
|
267 |
|
268 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_UNSUPPORTEDCONNMETHODID_EXIT ); |
|
269 return validity; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // Check from database if the given destination is an embedded destination in |
|
274 // any other destination. |
|
275 // --------------------------------------------------------------------------- |
|
276 // |
|
277 TBool CCmmInstanceMapping::DestinationIsEmbedded( const TUint32 aDestinationId ) const |
|
278 { |
|
279 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONISEMBEDDED_ENTRY ); |
|
280 |
|
281 TBool result( EFalse ); |
|
282 TInt index( 0 ); |
|
283 |
|
284 // Iterate through all destinations. |
|
285 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
286 { |
|
287 // An embedded destination is always at the very last position in |
|
288 // the connection method item array. |
|
289 index = iDestinations[i]->iConnMethodItemArray.Count() - 1; |
|
290 if ( index >= 0 ) |
|
291 { |
|
292 // We can skip bearer type check. If the last item isn't an |
|
293 // embedded destination, the ID will not match anyway. |
|
294 if ( iDestinations[i]->iConnMethodItemArray[index].iId == aDestinationId ) |
|
295 { |
|
296 result = ETrue; |
|
297 break; |
|
298 } |
|
299 } |
|
300 } |
|
301 |
|
302 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONISEMBEDDED_EXIT ); |
|
303 return result; |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // Check from database if the given destination has an embedded destination. |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 TBool CCmmInstanceMapping::DestinationHasEmbedded( const TUint32 aDestinationId ) const |
|
311 { |
|
312 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONHASEMBEDDED_ENTRY ); |
|
313 |
|
314 TBool result( EFalse ); |
|
315 |
|
316 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
317 { |
|
318 // Find the correct destination. |
|
319 if ( iDestinations[i]->iId == aDestinationId ) |
|
320 { |
|
321 // An embedded destination is always at the very last position in |
|
322 // the connection method item array. |
|
323 TInt index = iDestinations[i]->iConnMethodItemArray.Count() - 1; |
|
324 if ( index >= 0 ) |
|
325 { |
|
326 if ( iDestinations[i]->iConnMethodItemArray[index].IsEmbedded() ) |
|
327 { |
|
328 result = ETrue; |
|
329 } |
|
330 } |
|
331 break; |
|
332 } |
|
333 } |
|
334 |
|
335 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONHASEMBEDDED_EXIT ); |
|
336 return result; |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // Check from database if the given destination is pointed to by any virtual |
|
341 // IAP. |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 TBool CCmmInstanceMapping::DestinationPointedToByVirtualIap( |
|
345 const TUint32 aDestinationId ) const |
|
346 { |
|
347 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_ENTRY ); |
|
348 |
|
349 TBool result( EFalse ); |
|
350 if ( aDestinationId > 0 ) |
|
351 { |
|
352 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
353 { |
|
354 if ( iConnMethodItemArray[i].LinkedSnapId() == aDestinationId ) |
|
355 { |
|
356 result = ETrue; |
|
357 break; |
|
358 } |
|
359 } |
|
360 } |
|
361 |
|
362 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT ); |
|
363 return result; |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // Check from database if the given connection method is pointed to by any |
|
368 // virtual IAP. |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 TBool CCmmInstanceMapping::ConnMethodPointedToByVirtualIap( |
|
372 const TUint32 aConnMethodId ) const |
|
373 { |
|
374 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_ENTRY ); |
|
375 |
|
376 TBool result( EFalse ); |
|
377 if ( aConnMethodId > 0 ) |
|
378 { |
|
379 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
380 { |
|
381 if ( iConnMethodItemArray[i].LinkedIapId() == aConnMethodId ) |
|
382 { |
|
383 result = ETrue; |
|
384 break; |
|
385 } |
|
386 } |
|
387 } |
|
388 |
|
389 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT ); |
|
390 return result; |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // Check if the given connection method is the only connection method in the |
|
395 // given destination and if a virtual IAP points to that destination. |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 TBool CCmmInstanceMapping::ConnMethodInDestinationButLocked( |
|
399 const TUint32 aConnMethodId, |
|
400 const TUint32 aDestinationId ) const |
|
401 { |
|
402 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY ); |
|
403 |
|
404 TBool result( EFalse ); |
|
405 |
|
406 // Find destination. |
|
407 CDestination* destination( NULL ); |
|
408 destination = GetDestination( aDestinationId ); |
|
409 |
|
410 if ( destination ) |
|
411 { |
|
412 // Check if the destination has only 1 IAP. |
|
413 if ( destination->iConnMethodItemArray.Count() == 1 ) |
|
414 { |
|
415 // Check if the IAP has given ID. |
|
416 if ( destination->iConnMethodItemArray[0].iId == aConnMethodId ) |
|
417 { |
|
418 // Check if this destination is linked from a virtual IAP. |
|
419 result = DestinationPointedToByVirtualIap( aDestinationId ); |
|
420 } |
|
421 } |
|
422 } |
|
423 |
|
424 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_EXIT ); |
|
425 return result; |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // Get bearer type of connection method matching given ID. |
|
430 // Return KErrNone if ID is found, KErrNotFound if not. |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 TInt CCmmInstanceMapping::GetConnMethodBearerType( |
|
434 const TUint32 aConnMethodId, |
|
435 TUint32& bearerType ) const |
|
436 { |
|
437 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODBEARERTYPE_ENTRY ); |
|
438 |
|
439 TInt result( KErrNotFound ); |
|
440 |
|
441 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
442 { |
|
443 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
444 { |
|
445 bearerType = iConnMethodItemArray[i].iBearerType; |
|
446 result = KErrNone; |
|
447 break; |
|
448 } |
|
449 } |
|
450 if ( result == KErrNotFound ) |
|
451 { |
|
452 // Embedded destinations are not in connection method array. |
|
453 if ( aConnMethodId > KCmmDestIdIntervalMin && aConnMethodId < KCmmDestIdIntervalMax ) |
|
454 { |
|
455 if ( ValidDestinationId( aConnMethodId ) ) |
|
456 { |
|
457 bearerType = KUidEmbeddedDestination; |
|
458 result = KErrNone; |
|
459 } |
|
460 } |
|
461 } |
|
462 |
|
463 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODBEARERTYPE_EXIT ); |
|
464 return result; |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------------------------- |
|
468 // Returns the number of destinations the provided connection method belongs |
|
469 // to. Zero is returned if the connection method belongs to no destination |
|
470 // (legacy IAP) or does not exist. |
|
471 // --------------------------------------------------------------------------- |
|
472 // |
|
473 TInt CCmmInstanceMapping::DestinationsContainingConnMethod( |
|
474 const TUint32 aConnMethodId ) const |
|
475 { |
|
476 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODREFERENCECOUNT_ENTRY ); |
|
477 |
|
478 TInt referenceCount( 0 ); |
|
479 TInt count( 0 ); |
|
480 |
|
481 // Go through each destination. |
|
482 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
483 { |
|
484 TBool foundInThisDestination( EFalse ); |
|
485 |
|
486 // Loop through all connection methods in this destination. |
|
487 count = iDestinations[i]->iConnMethodItemArray.Count(); |
|
488 for ( TInt j = 0; j < count; j++ ) |
|
489 { |
|
490 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
491 { |
|
492 foundInThisDestination = ETrue; |
|
493 referenceCount++; |
|
494 break; |
|
495 } |
|
496 } |
|
497 |
|
498 // Check unsupported connection methods also. |
|
499 if ( !foundInThisDestination ) |
|
500 { |
|
501 count = iDestinations[i]->iUnsupportedConnMethods.Count(); |
|
502 for ( TInt j = 0; j < count; j++ ) |
|
503 { |
|
504 if ( iDestinations[i]->iUnsupportedConnMethods[j] == aConnMethodId ) |
|
505 { |
|
506 referenceCount++; |
|
507 break; |
|
508 } |
|
509 } |
|
510 } |
|
511 } |
|
512 |
|
513 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODREFERENCECOUNT_EXIT ); |
|
514 return referenceCount; |
|
515 } |
|
516 |
|
517 // --------------------------------------------------------------------------- |
|
518 // Returns the destination IDs containing the connection method given as |
|
519 // parameter. |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 void CCmmInstanceMapping::DestinationsContainingConnMethodL( |
|
523 const TUint32 aConnMethodId, |
|
524 RArray<TUint32>& aDestinationIds ) const |
|
525 { |
|
526 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONSCONTAININGCONNMETHODL_ENTRY ); |
|
527 |
|
528 aDestinationIds.Reset(); |
|
529 TInt count( 0 ); |
|
530 |
|
531 // Go through each destination. |
|
532 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
533 { |
|
534 TBool foundInThisDestination( EFalse ); |
|
535 |
|
536 // Loop through all connection methods in this destination. |
|
537 count = iDestinations[i]->iConnMethodItemArray.Count(); |
|
538 for ( TInt j = 0; j < count; j++ ) |
|
539 { |
|
540 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
541 { |
|
542 foundInThisDestination = ETrue; |
|
543 aDestinationIds.AppendL( iDestinations[i]->iId ); |
|
544 break; |
|
545 } |
|
546 } |
|
547 |
|
548 // Check unsupported connection methods also. |
|
549 if ( !foundInThisDestination ) |
|
550 { |
|
551 count = iDestinations[i]->iUnsupportedConnMethods.Count(); |
|
552 for ( TInt j = 0; j < count; j++ ) |
|
553 { |
|
554 if ( iDestinations[i]->iUnsupportedConnMethods[j] == aConnMethodId ) |
|
555 { |
|
556 aDestinationIds.AppendL( iDestinations[i]->iId ); |
|
557 break; |
|
558 } |
|
559 } |
|
560 } |
|
561 } |
|
562 |
|
563 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONSCONTAININGCONNMETHODL_EXIT ); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // Get database session. |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 CommsDat::CMDBSession& CCmmInstanceMapping::Session() const |
|
571 { |
|
572 // No traces. |
|
573 return iCache.Session(); |
|
574 } |
|
575 |
|
576 // --------------------------------------------------------------------------- |
|
577 // Discovers all connection methods from database. Unsupported connection |
|
578 // methods are kept separately. |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void CCmmInstanceMapping::ReadAndValidateConnMethodsL() |
|
582 { |
|
583 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_READANDVALIDATECONNMETHODSL_ENTRY ); |
|
584 |
|
585 CMDBRecordSet<CCDIAPRecord>* iapRecordSet = |
|
586 new( ELeave ) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
587 CleanupStack::PushL( iapRecordSet ); |
|
588 |
|
589 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>( |
|
590 CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
591 CleanupStack::PushL( iapRecord ); |
|
592 |
|
593 TRAP_IGNORE( iapRecordSet->LoadL( Session() ) ); |
|
594 |
|
595 // Clear the old info about IAPs. |
|
596 iConnMethodItemArray.Reset(); |
|
597 iUnsupportedConnMethods.Reset(); |
|
598 |
|
599 TInt iapRecordCount( iapRecordSet->iRecords.Count() ); |
|
600 TInt err( KErrNone ); |
|
601 TUint32 bearerType( 0 ); |
|
602 TUint bearerPriority( CMManager::KDataMobilitySelectionPolicyPriorityWildCard ); |
|
603 |
|
604 for ( TInt i = 0; i < iapRecordCount; i++ ) |
|
605 { |
|
606 TUint32 connMethodId( iapRecordSet->iRecords[i]->RecordId() ); |
|
607 |
|
608 // Check the connection method is not on the deleted list waiting to be |
|
609 // deleted from database. |
|
610 TInt indexInDeletedList = iDeletedConnMethods.FindInOrder( ( TUint )connMethodId ); |
|
611 if ( indexInDeletedList == KErrNotFound ) |
|
612 { |
|
613 // Check the bearer type of the iap. Leaves if iap is unsupported. |
|
614 iapRecord->SetRecordId( connMethodId ); |
|
615 TRAP( err, iCache.BearerInfoFromIapRecordL( iapRecord, bearerType, bearerPriority ) ); |
|
616 if ( !err ) |
|
617 { |
|
618 TBool isVirtual( EFalse ); |
|
619 TUint32 linkedIap( 0 ); |
|
620 TUint32 linkedSnap( 0 ); |
|
621 |
|
622 // BearerInfoFromIapRecordL() has called LoadL() for iapRecord. |
|
623 if( TPtrC( KCDTypeNameVPNService ) == iapRecord->iServiceType ) |
|
624 { |
|
625 isVirtual = ETrue; |
|
626 CCDVPNServiceRecord* serviceRecord = static_cast<CCDVPNServiceRecord*>( |
|
627 CCDRecordBase::RecordFactoryL( KCDTIdVPNServiceRecord ) ); |
|
628 CleanupStack::PushL( serviceRecord ); |
|
629 serviceRecord->SetRecordId( iapRecord->iService ); |
|
630 serviceRecord->LoadL( Session() ); |
|
631 |
|
632 // If neither link is set, or both are set, it is an error |
|
633 // but we ignore it. If both links are set, we use only the |
|
634 // SNAP link. |
|
635 if ( !serviceRecord->iServiceSNAP.IsNull() ) |
|
636 { |
|
637 TUint32 apRecordId = serviceRecord->iServiceSNAP; |
|
638 if ( apRecordId != 0 ) |
|
639 { |
|
640 CCDAccessPointRecord* apRecord = static_cast<CCDAccessPointRecord*>( |
|
641 CCDRecordBase::RecordFactoryL( KCDTIdAccessPointRecord ) ); |
|
642 apRecord->SetRecordId( apRecordId ); |
|
643 TRAP( err, apRecord->LoadL( Session() ) ); |
|
644 if ( !err ) |
|
645 { |
|
646 linkedSnap = apRecord->iRecordTag; |
|
647 } |
|
648 } |
|
649 } |
|
650 if ( !linkedSnap && !serviceRecord->iServiceIAP.IsNull() ) |
|
651 { |
|
652 linkedIap = serviceRecord->iServiceIAP; |
|
653 if ( linkedIap >= KCmmConnMethodIdIntervalMax ) |
|
654 { |
|
655 linkedIap = ( linkedIap & KCDMaskShowRecordId ) >> KBitsInOneByte; |
|
656 } |
|
657 } |
|
658 |
|
659 CleanupStack::PopAndDestroy( serviceRecord ); |
|
660 } |
|
661 TCmmConnMethodItem item( |
|
662 connMethodId, |
|
663 bearerType, |
|
664 bearerPriority, |
|
665 0, |
|
666 isVirtual, |
|
667 linkedIap, |
|
668 linkedSnap ); |
|
669 iConnMethodItemArray.Append( item ); // Ignore errors. |
|
670 } |
|
671 else if ( err == KErrNotSupported ) |
|
672 { |
|
673 iUnsupportedConnMethods.InsertInOrder( ( TUint )connMethodId ); // Ignore errors. |
|
674 } |
|
675 else if ( err == KErrNoMemory ) |
|
676 { |
|
677 User::Leave( err ); |
|
678 } |
|
679 } |
|
680 } |
|
681 |
|
682 CleanupStack::PopAndDestroy( iapRecord ); |
|
683 CleanupStack::PopAndDestroy( iapRecordSet ); |
|
684 |
|
685 // Check all virtual IAPs that link to an IAP. If the link is invalid |
|
686 // (linked IAP not found), the IAP is removed. |
|
687 ValidateVirtualIapsLinkingToIaps(); |
|
688 |
|
689 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_READANDVALIDATECONNMETHODSL_EXIT ); |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // Discovers all destinations and the connection methods inside them. |
|
694 // Unsupported connection methods are kept separately. |
|
695 // --------------------------------------------------------------------------- |
|
696 // |
|
697 void CCmmInstanceMapping::ReadAndValidateDestinationsL() |
|
698 { |
|
699 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_READANDVALIDATEDESTINATIONSL_ENTRY ); |
|
700 |
|
701 // Make 2 loops, first add destinations and then connection methods / embedded destinations. |
|
702 iDestinations.ResetAndDestroy(); |
|
703 |
|
704 // Explicitly build a TLinearOrder<class>. Used as parameter to RArray::InsertInOrder(). |
|
705 TLinearOrder<TCmmConnMethodItem> connMethodItemOrderingLogic( TCmmConnMethodItem::Compare ); |
|
706 |
|
707 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* snapRecordSet = |
|
708 new( ELeave ) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
709 iCache.TableId( ECmmDbSnapRecord ) ); |
|
710 CleanupStack::PushL( snapRecordSet ); |
|
711 |
|
712 CCDDataMobilitySelectionPolicyRecord* snapRecord = |
|
713 new( ELeave ) CCDDataMobilitySelectionPolicyRecord( |
|
714 iCache.TableId( ECmmDbSnapRecord ) ); |
|
715 CleanupStack::PushL( snapRecord ); |
|
716 |
|
717 TRAP_IGNORE( snapRecordSet->LoadL( Session() ) ); |
|
718 |
|
719 // Read snap ID, connection method ID and embedded destination ID. |
|
720 const TInt snapRecordCount( snapRecordSet->iRecords.Count() ); |
|
721 for ( TInt i = 0; i < snapRecordCount; i++ ) |
|
722 { |
|
723 snapRecord->SetElementId( snapRecordSet->iRecords[i]->ElementId() ); |
|
724 snapRecord->LoadL( Session() ); |
|
725 |
|
726 TUint32 destinationId = (TUint32)( snapRecord->iSNAP ); |
|
727 TInt indexInDeletedList = iDeletedDestinations.FindInOrder( ( TUint )destinationId ); |
|
728 if ( indexInDeletedList == KErrNotFound ) |
|
729 { |
|
730 TUint32 connMethodId = ( snapRecord->iIAP & KCDMaskShowRecordId ) >> 8; |
|
731 TUint32 embeddedDestinationId = (TUint32)( snapRecord->iEmbeddedSNAP ); |
|
732 |
|
733 // If connMethodId and embeddedDestinationId are 0 this is a destination. |
|
734 if ( connMethodId == 0 && embeddedDestinationId == 0 ) |
|
735 { |
|
736 TBool destAlreadyExists = ValidDestinationId( destinationId ); |
|
737 if ( !destAlreadyExists ) |
|
738 { |
|
739 CCDSNAPMetadataRecord* metadataRecord = new( ELeave ) CCDSNAPMetadataRecord( |
|
740 iCache.TableId( ECmmDestMetadataRecord ) ); |
|
741 CleanupStack::PushL( metadataRecord ); |
|
742 |
|
743 // Add destination metadata. |
|
744 metadataRecord->iSNAP.SetL( destinationId ); |
|
745 if ( metadataRecord->FindL( Session() ) ) |
|
746 { |
|
747 metadataRecord->LoadL( Session() ); |
|
748 |
|
749 CDestination* dest = CDestination::NewLC(); |
|
750 dest->iId = destinationId; |
|
751 dest->iMetadata = metadataRecord->iMetadata; |
|
752 iDestinations.AppendL( dest ); |
|
753 CleanupStack::Pop( dest ); |
|
754 } |
|
755 CleanupStack::PopAndDestroy( metadataRecord ); |
|
756 metadataRecord = NULL; |
|
757 } |
|
758 } |
|
759 } |
|
760 } |
|
761 |
|
762 // Check all virtual IAPs that link to a SNAP. If the link is invalid |
|
763 // (linked SNAP not found), the IAP is removed. |
|
764 ValidateVirtualIapsLinkingToSnaps(); |
|
765 |
|
766 // Read snap ID, connection method ID and embedded destination ID. |
|
767 for ( TInt i = 0; i < snapRecordCount; i++ ) |
|
768 { |
|
769 snapRecord->SetElementId( snapRecordSet->iRecords[i]->ElementId() ); |
|
770 snapRecord->LoadL( Session() ); |
|
771 |
|
772 TUint32 destinationId = (TUint32)( snapRecord->iSNAP ); |
|
773 TUint32 connMethodId = ( snapRecord->iIAP & KCDMaskShowRecordId ) >> 8; |
|
774 TUint32 embeddedDestinationId = (TUint32)( snapRecord->iEmbeddedSNAP ); |
|
775 |
|
776 // If connMethodId or embeddedDestinationId differs from 0 this is a connection method object. |
|
777 if ( connMethodId > 0 || embeddedDestinationId > 0 ) |
|
778 { |
|
779 // Find destination. |
|
780 CDestination* destination( NULL ); |
|
781 destination = GetDestination( destinationId ); |
|
782 |
|
783 if ( destination ) |
|
784 { |
|
785 if ( connMethodId ) |
|
786 { |
|
787 // Connection method, not embedded destination. |
|
788 TBool found( EFalse ); |
|
789 TCmmConnMethodItem item; |
|
790 |
|
791 // Find connection method. |
|
792 for ( TInt j = 0; j < iConnMethodItemArray.Count(); j++ ) |
|
793 { |
|
794 if ( iConnMethodItemArray[j].iId == connMethodId ) |
|
795 { |
|
796 item = iConnMethodItemArray[j]; |
|
797 found = ETrue; |
|
798 break; |
|
799 } |
|
800 } |
|
801 if ( found ) |
|
802 { |
|
803 // Make sure no duplicate entries are allowed. Any |
|
804 // duplicate would imply a corrupted CommsDat. |
|
805 TInt index = destination->iConnMethodItemArray.Find<TUint32>( |
|
806 connMethodId, |
|
807 TCmmConnMethodItem::FindCompare ); |
|
808 if ( index == KErrNotFound ) |
|
809 { |
|
810 item.iPriority = snapRecord->iPriority; |
|
811 destination->iConnMethodItemArray.InsertInOrderAllowRepeats( |
|
812 item, |
|
813 connMethodItemOrderingLogic ); // Ignore errors. |
|
814 } |
|
815 } |
|
816 else |
|
817 { |
|
818 // Check if the connection method is unsupported instead. |
|
819 TBool isUnsupported = UnsupportedConnMethodId( connMethodId ); |
|
820 if ( isUnsupported ) |
|
821 { |
|
822 destination->iUnsupportedConnMethods.InsertInOrder( |
|
823 ( TUint )connMethodId ); // Ignore errors. |
|
824 } |
|
825 } |
|
826 } |
|
827 |
|
828 else |
|
829 { |
|
830 // Embedded destination, not IAP. |
|
831 // Prevent destinations from embedding themselves. |
|
832 if ( embeddedDestinationId != destinationId ) |
|
833 { |
|
834 // Check embedded destination ID is valid. |
|
835 TBool valid = ValidDestinationId( embeddedDestinationId ); |
|
836 if ( valid ) |
|
837 { |
|
838 TCmmConnMethodItem item( |
|
839 embeddedDestinationId, |
|
840 KUidEmbeddedDestination, |
|
841 CMManager::KDataMobilitySelectionPolicyPriorityWildCard, |
|
842 CMManager::KDataMobilitySelectionPolicyPriorityWildCard ); |
|
843 destination->iConnMethodItemArray.InsertInOrderAllowRepeats( |
|
844 item, |
|
845 connMethodItemOrderingLogic ); |
|
846 } |
|
847 } |
|
848 } |
|
849 } |
|
850 } |
|
851 } |
|
852 CleanupStack::PopAndDestroy( snapRecord ); |
|
853 CleanupStack::PopAndDestroy( snapRecordSet ); |
|
854 |
|
855 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_READANDVALIDATEDESTINATIONSL_EXIT ); |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // Goes through the internal IAP table, checking all virtual IAPs that link to |
|
860 // an IAP. If the linked IAP is not found, the virtual IAP is removed. |
|
861 // --------------------------------------------------------------------------- |
|
862 // |
|
863 void CCmmInstanceMapping::ValidateVirtualIapsLinkingToIaps() |
|
864 { |
|
865 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOIAPS_ENTRY ); |
|
866 |
|
867 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
868 { |
|
869 if ( iConnMethodItemArray[i].LinkedIapId() != 0 ) |
|
870 { |
|
871 if ( !ValidConnMethodId( iConnMethodItemArray[i].LinkedIapId() ) ) |
|
872 { |
|
873 iConnMethodItemArray.Remove( i ); |
|
874 i--; // Adjust counter. |
|
875 } |
|
876 } |
|
877 } |
|
878 |
|
879 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOIAPS_EXIT ); |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
|
883 // Goes through the internal IAP table, checking all virtual IAPs that link to |
|
884 // a SNAP. If the linked SNAP is not found, the virtual IAP is removed. |
|
885 // --------------------------------------------------------------------------- |
|
886 // |
|
887 void CCmmInstanceMapping::ValidateVirtualIapsLinkingToSnaps() |
|
888 { |
|
889 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOSNAPS_ENTRY ); |
|
890 |
|
891 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
892 { |
|
893 if ( iConnMethodItemArray[i].LinkedSnapId() != 0 ) |
|
894 { |
|
895 if ( !ValidDestinationId( iConnMethodItemArray[i].LinkedSnapId() ) ) |
|
896 { |
|
897 iConnMethodItemArray.Remove( i ); |
|
898 i--; // Adjust counter. |
|
899 } |
|
900 } |
|
901 } |
|
902 |
|
903 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDATEVIRTUALIAPSLINKINGTOSNAPS_EXIT ); |
|
904 } |
|
905 |
|
906 // --------------------------------------------------------------------------- |
|
907 // Find the destination item matching the provided destination ID. |
|
908 // Returns a pointer to the internal destination item, NULL if not found. |
|
909 // --------------------------------------------------------------------------- |
|
910 // |
|
911 CDestination* CCmmInstanceMapping::GetDestination( const TUint32 aDestinationId ) const |
|
912 { |
|
913 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATION_ENTRY ); |
|
914 |
|
915 CDestination* destination( NULL ); |
|
916 if ( aDestinationId > 0 ) |
|
917 { |
|
918 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
919 { |
|
920 if ( iDestinations[i]->iId == aDestinationId ) |
|
921 { |
|
922 destination = iDestinations[i]; |
|
923 break; |
|
924 } |
|
925 } |
|
926 } |
|
927 |
|
928 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETDESTINATION_EXIT ); |
|
929 return destination; |
|
930 } |
|
931 |
|
932 // --------------------------------------------------------------------------- |
|
933 // Find and return a copy of a connection method item matching the given ID. |
|
934 // Returns KErrNotFound, if the connection method is not found. |
|
935 // --------------------------------------------------------------------------- |
|
936 // |
|
937 TInt CCmmInstanceMapping::GetConnMethodItem( |
|
938 const TUint32 aConnMethodId, |
|
939 TCmmConnMethodItem& aConnMethodItem ) const |
|
940 { |
|
941 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODITEM_ENTRY ); |
|
942 |
|
943 TInt result( KErrNotFound ); |
|
944 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
945 { |
|
946 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
947 { |
|
948 aConnMethodItem = iConnMethodItemArray[i]; |
|
949 result = KErrNone; |
|
950 break; |
|
951 } |
|
952 } |
|
953 |
|
954 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODITEM_EXIT ); |
|
955 return result; |
|
956 } |
|
957 |
|
958 // --------------------------------------------------------------------------- |
|
959 // Returns all conenction method IDs. Unsupported connection methods are |
|
960 // included if aCheckBearerType is set to EFalse. |
|
961 // --------------------------------------------------------------------------- |
|
962 // |
|
963 void CCmmInstanceMapping::GetAllConnMethodsL( |
|
964 RArray<TUint32>& aConnMethodArray, |
|
965 TBool aCheckBearerType ) const |
|
966 { |
|
967 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODSL_ENTRY ); |
|
968 |
|
969 TInt connMethodCount = iConnMethodItemArray.Count(); |
|
970 aConnMethodArray.Reset(); |
|
971 |
|
972 if ( aCheckBearerType ) |
|
973 { |
|
974 aConnMethodArray.ReserveL( connMethodCount ); |
|
975 } |
|
976 else |
|
977 { |
|
978 aConnMethodArray.ReserveL( connMethodCount + iUnsupportedConnMethods.Count() ); |
|
979 } |
|
980 |
|
981 for ( TInt i = 0; i < connMethodCount; i++ ) |
|
982 { |
|
983 aConnMethodArray.AppendL( iConnMethodItemArray[i].iId ); |
|
984 } |
|
985 if ( !aCheckBearerType ) |
|
986 { |
|
987 // Include unsupported connection methods also. |
|
988 for ( TInt i = 0; i < iUnsupportedConnMethods.Count(); i++ ) |
|
989 { |
|
990 aConnMethodArray.AppendL( ( TUint32 )iUnsupportedConnMethods[i] ); |
|
991 } |
|
992 } |
|
993 |
|
994 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODSL_EXIT ); |
|
995 } |
|
996 |
|
997 // --------------------------------------------------------------------------- |
|
998 // Return the number of destinations in database. |
|
999 // --------------------------------------------------------------------------- |
|
1000 // |
|
1001 TInt CCmmInstanceMapping::GetDestinationCount() const |
|
1002 { |
|
1003 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATIONCOUNT_ENTRY ); |
|
1004 |
|
1005 return iDestinations.Count(); |
|
1006 } |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // Return an array containing all destination IDs. |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CCmmInstanceMapping::GetDestinationsL( RArray<TUint32>& aDestinationArray ) const |
|
1013 { |
|
1014 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATIONSL_ENTRY ); |
|
1015 |
|
1016 aDestinationArray.Reset(); |
|
1017 aDestinationArray.ReserveL( iDestinations.Count() ); // Re-allocates only if more is needed. |
|
1018 |
|
1019 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1020 { |
|
1021 aDestinationArray.AppendL( iDestinations[i]->iId ); |
|
1022 } |
|
1023 |
|
1024 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETDESTINATIONSL_EXIT ); |
|
1025 } |
|
1026 |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // Inserts all the valid connection methods inside the given destination into |
|
1029 // the provided connection method item array. The array is reset first. |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // |
|
1032 void CCmmInstanceMapping::GetConnMethodsFromDestinationL( |
|
1033 const TUint32 aDestinationId, |
|
1034 RArray<TCmmConnMethodItem>& aConnMethodArray ) const |
|
1035 { |
|
1036 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODSFROMDESTINATIONL_ENTRY ); |
|
1037 |
|
1038 TBool destinationFound( EFalse ); |
|
1039 |
|
1040 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1041 { |
|
1042 if ( iDestinations[i]->iId == aDestinationId ) |
|
1043 { |
|
1044 destinationFound = ETrue; |
|
1045 aConnMethodArray.Reset(); |
|
1046 aConnMethodArray.ReserveL( iDestinations[i]->iConnMethodItemArray.Count() ); |
|
1047 |
|
1048 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1049 { |
|
1050 aConnMethodArray.AppendL( iDestinations[i]->iConnMethodItemArray[j] ); |
|
1051 } |
|
1052 break; |
|
1053 } |
|
1054 } |
|
1055 if ( !destinationFound ) |
|
1056 { |
|
1057 User::Leave( KErrNotFound ); |
|
1058 } |
|
1059 |
|
1060 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODSFROMDESTINATIONL_EXIT ); |
|
1061 } |
|
1062 |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // Check if the given connection method belongs to any other destination than |
|
1065 // the one provided. |
|
1066 // --------------------------------------------------------------------------- |
|
1067 // |
|
1068 TBool CCmmInstanceMapping::ConnMethodInOtherDestination( |
|
1069 const TUint32 aConnMethodId, |
|
1070 const TUint32 aDestinationId ) |
|
1071 { |
|
1072 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_ENTRY ); |
|
1073 |
|
1074 // Loop through all destinations. |
|
1075 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1076 { |
|
1077 // Skip the specified destination. |
|
1078 if ( iDestinations[i]->iId != aDestinationId ) |
|
1079 { |
|
1080 // Loop through all connection methods in the current destination. |
|
1081 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1082 { |
|
1083 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1084 { |
|
1085 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
1086 return ETrue; |
|
1087 } |
|
1088 } |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
1093 return EFalse; |
|
1094 } |
|
1095 |
|
1096 // --------------------------------------------------------------------------- |
|
1097 // Return the EasyWLAN IAP ID, zero if not found or WLAN not supported. |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // |
|
1100 TUint32 CCmmInstanceMapping::EasyWlanIdL() |
|
1101 { |
|
1102 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_EASYWLANIDL_ENTRY ); |
|
1103 |
|
1104 iEasyWlanId = 0; |
|
1105 |
|
1106 // Check WLAN support. |
|
1107 if ( iCache.WlanSupported() ) |
|
1108 { |
|
1109 CMDBRecordSet<CCDIAPRecord>* iapRecordSet = |
|
1110 new( ELeave ) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
1111 CleanupStack::PushL( iapRecordSet ); |
|
1112 TRAP_IGNORE( iapRecordSet->LoadL( Session() ) ); |
|
1113 |
|
1114 TInt iapRecordCount( iapRecordSet->iRecords.Count() ); |
|
1115 for ( TInt i = 0; i < iapRecordCount; i++ ) |
|
1116 { |
|
1117 CCDIAPRecord* iapRecord = ( CCDIAPRecord* )iapRecordSet->iRecords[i]; |
|
1118 |
|
1119 if ( TPtrC( iapRecord->iServiceType ) == TPtrC( KCDTypeNameLANService ) && |
|
1120 TPtrC( iapRecord->iBearerType ) == TPtrC( KCDTypeNameLANBearer ) ) |
|
1121 { |
|
1122 TUint32 serviceId = iapRecord->iService; |
|
1123 |
|
1124 CCDWlanServiceRecord* wlanServ = |
|
1125 new( ELeave ) CCDWlanServiceRecord( |
|
1126 CCDWlanServiceRecord::TableIdL( Session() ) ); |
|
1127 CleanupStack::PushL( wlanServ ); |
|
1128 |
|
1129 wlanServ->iWlanServiceId.SetL( serviceId ); |
|
1130 if ( wlanServ->FindL( Session() ) ) |
|
1131 { |
|
1132 wlanServ->LoadL( Session() ); |
|
1133 // Only EasyWLAN IAP has NULL in SSID field. |
|
1134 if ( wlanServ->iWLanSSID.IsNull() || |
|
1135 !( TPtrC( wlanServ->iWLanSSID ).Compare( KNullDesC ) ) ) |
|
1136 { |
|
1137 iEasyWlanId = iapRecord->RecordId(); |
|
1138 } |
|
1139 } |
|
1140 CleanupStack::PopAndDestroy( wlanServ ); |
|
1141 } |
|
1142 if ( iEasyWlanId != 0 ) |
|
1143 { |
|
1144 break; |
|
1145 } |
|
1146 } |
|
1147 CleanupStack::PopAndDestroy( iapRecordSet ); |
|
1148 } |
|
1149 |
|
1150 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_EASYWLANIDL_EXIT ); |
|
1151 return iEasyWlanId; |
|
1152 } |
|
1153 |
|
1154 // --------------------------------------------------------------------------- |
|
1155 // Find out the internet destination ID. ID is set to 0 if not found. |
|
1156 // --------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CCmmInstanceMapping::InternetDestinationIdL( TUint& aInternetDestinationId ) |
|
1159 { |
|
1160 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_INTERNETDESTINATIONIDL_ENTRY ); |
|
1161 |
|
1162 // Set to zero in case the destination is not found. |
|
1163 aInternetDestinationId = 0; |
|
1164 |
|
1165 CommsDat::CMDBRecordSet<CCDSNAPMetadataRecord>* metaSet = |
|
1166 new( ELeave )CommsDat::CMDBRecordSet<CCDSNAPMetadataRecord>( |
|
1167 iCache.TableId( ECmmDestMetadataRecord ) ); |
|
1168 CleanupStack::PushL( metaSet ); |
|
1169 |
|
1170 TRAP_IGNORE( metaSet->LoadL( Session() ) ); |
|
1171 |
|
1172 CCDSNAPMetadataRecord* metadataRecord = |
|
1173 new( ELeave ) CCDSNAPMetadataRecord( |
|
1174 iCache.TableId( ECmmDestMetadataRecord ) ); |
|
1175 CleanupStack::PushL( metadataRecord ); |
|
1176 |
|
1177 for ( TInt i = 0; i < metaSet->iRecords.Count(); i++ ) |
|
1178 { |
|
1179 metadataRecord->SetRecordId( metaSet->iRecords[i]->RecordId() ); |
|
1180 metadataRecord->LoadL( Session() ); |
|
1181 |
|
1182 TUint32 metadata = metadataRecord->iMetadata; |
|
1183 |
|
1184 TUint32 internet = metadata & |
|
1185 CMManager::ESnapMetadataInternet; |
|
1186 TUint32 localizationValue = ( metadata & |
|
1187 CMManager::ESnapMetadataDestinationIsLocalised ) >> 4; |
|
1188 TUint32 purposeValue = ( metadata & |
|
1189 CMManager::ESnapMetadataPurpose ) >> 8; |
|
1190 |
|
1191 // The first record that has a matching value in any of the 3 metadata |
|
1192 // fields will be taken as the internet snap. |
|
1193 if ( internet || |
|
1194 ( localizationValue == CMManager::ELocalisedDestInternet ) || |
|
1195 ( purposeValue == CMManager::ESnapPurposeInternet ) ) |
|
1196 { |
|
1197 TInt id = metadataRecord->iSNAP; |
|
1198 if ( ValidDestinationId( ( TUint32 )id ) ) |
|
1199 { |
|
1200 aInternetDestinationId = ( TUint )id; |
|
1201 break; |
|
1202 } |
|
1203 } |
|
1204 } |
|
1205 CleanupStack::PopAndDestroy( metadataRecord ); |
|
1206 CleanupStack::PopAndDestroy( metaSet ); |
|
1207 |
|
1208 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_INTERNETDESTINATIONIDL_EXIT ); |
|
1209 } |
|
1210 |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // Add a connection method ID to deleted list. Ignores any duplicates. Also |
|
1213 // removes the connection method from destination/connection method structures |
|
1214 // so Refresh()-call is not needed. Use this method if the connection method |
|
1215 // has not been removed from database yet. |
|
1216 // --------------------------------------------------------------------------- |
|
1217 // |
|
1218 void CCmmInstanceMapping::AddConnMethodToDeletedListL( const TUint aConnMethodId ) |
|
1219 { |
|
1220 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDCONNMETHODTODELETEDLISTL_ENTRY ); |
|
1221 |
|
1222 iDeletedConnMethods.InsertInOrderL( aConnMethodId ); |
|
1223 |
|
1224 // Remove the connection method from current destination/connection method structures. |
|
1225 RemoveConnMethod( aConnMethodId ); |
|
1226 |
|
1227 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_ADDCONNMETHODTODELETEDLISTL_EXIT ); |
|
1228 } |
|
1229 |
|
1230 // --------------------------------------------------------------------------- |
|
1231 // Remove a connection method ID from deleted list. Nothing happens if ID is |
|
1232 // not found from the list. |
|
1233 // --------------------------------------------------------------------------- |
|
1234 // |
|
1235 void CCmmInstanceMapping::RemoveConnMethodFromDeletedList( const TUint aConnMethodId ) |
|
1236 { |
|
1237 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDELETEDLIST_ENTRY ); |
|
1238 |
|
1239 TInt index = iDeletedConnMethods.FindInOrder( aConnMethodId ); |
|
1240 if ( index != KErrNotFound ) |
|
1241 { |
|
1242 iDeletedConnMethods.Remove( index ); |
|
1243 } |
|
1244 |
|
1245 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDELETEDLIST_EXIT ); |
|
1246 } |
|
1247 |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // Add a destination ID to deleted list. Ignores any duplicates. Also removes |
|
1250 // the destination from destination/connection method structures so |
|
1251 // Refresh()-call is not needed. Use this method if the connection method has |
|
1252 // not been removed from database yet. |
|
1253 // --------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CCmmInstanceMapping::AddDestinationToDeletedListL( const TUint aDestinationId ) |
|
1256 { |
|
1257 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDDESTINATIONTODELETEDLISTL_ENTRY ); |
|
1258 |
|
1259 iDeletedDestinations.InsertInOrderL( aDestinationId ); |
|
1260 |
|
1261 // Remove the destination from current destination/connection method structures. |
|
1262 RemoveDestination( aDestinationId ); |
|
1263 |
|
1264 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_ADDDESTINATIONTODELETEDLISTL_EXIT ); |
|
1265 } |
|
1266 |
|
1267 // --------------------------------------------------------------------------- |
|
1268 // Remove a destination ID from deleted list. Nothing happens if ID is not |
|
1269 // found from the list. |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // |
|
1272 void CCmmInstanceMapping::RemoveDestinationFromDeletedList( const TUint aDestinationId ) //TODO, check removal is called in all necessary places. |
|
1273 { |
|
1274 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATIONFROMDELETEDLIST_ENTRY ); |
|
1275 |
|
1276 TInt index = iDeletedDestinations.FindInOrder( aDestinationId ); |
|
1277 if ( index != KErrNotFound ) |
|
1278 { |
|
1279 iDeletedDestinations.Remove( index ); |
|
1280 } |
|
1281 |
|
1282 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVEDESTINATIONFROMDELETEDLIST_EXIT ); |
|
1283 } |
|
1284 |
|
1285 // --------------------------------------------------------------------------- |
|
1286 // Remove the connection method from current destination/connection method |
|
1287 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1288 // the connection method has been removed from database. |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 void CCmmInstanceMapping::RemoveConnMethod( const TUint32 aConnMethodId ) |
|
1292 { |
|
1293 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHOD_ENTRY ); |
|
1294 |
|
1295 // Remove from list of connection methods. |
|
1296 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1297 { |
|
1298 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
1299 { |
|
1300 iConnMethodItemArray.Remove( i ); |
|
1301 break; |
|
1302 } |
|
1303 } |
|
1304 |
|
1305 // Remove connection method from all destinations. |
|
1306 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1307 { |
|
1308 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1309 { |
|
1310 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1311 { |
|
1312 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1313 break; |
|
1314 } |
|
1315 } |
|
1316 } |
|
1317 |
|
1318 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHOD_EXIT ); |
|
1319 } |
|
1320 |
|
1321 // --------------------------------------------------------------------------- |
|
1322 // Remove the connection method from current destination/connection method |
|
1323 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1324 // the connection method has been removed from database. |
|
1325 // Also adds the ID of any changed destinations to the provided array. |
|
1326 // --------------------------------------------------------------------------- |
|
1327 // |
|
1328 void CCmmInstanceMapping::RemoveConnMethod( |
|
1329 const TUint32 aConnMethodId, |
|
1330 RArray<TUint32>& aChangedDestinations ) |
|
1331 { |
|
1332 OstTraceFunctionEntry0( DUP1_CCMMINSTANCEMAPPING_REMOVECONNMETHOD_ENTRY ); |
|
1333 |
|
1334 // Remove from list of connection methods. |
|
1335 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1336 { |
|
1337 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
1338 { |
|
1339 iConnMethodItemArray.Remove( i ); |
|
1340 break; |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 // Remove connection method from all destinations. |
|
1345 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1346 { |
|
1347 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1348 { |
|
1349 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1350 { |
|
1351 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1352 // Add ID of changed destination into array. Ignore any error. |
|
1353 aChangedDestinations.Append( iDestinations[i]->iId ); |
|
1354 break; |
|
1355 } |
|
1356 } |
|
1357 } |
|
1358 |
|
1359 OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_REMOVECONNMETHOD_EXIT ); |
|
1360 } |
|
1361 |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // Remove the destination from current destination/connection method |
|
1364 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1365 // the connection method has been removed from database. |
|
1366 // --------------------------------------------------------------------------- |
|
1367 // |
|
1368 void CCmmInstanceMapping::RemoveDestination( const TUint32 aDestinationId ) |
|
1369 { |
|
1370 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATION_ENTRY ); |
|
1371 |
|
1372 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1373 { |
|
1374 if ( iDestinations[i]->iId == aDestinationId ) |
|
1375 { |
|
1376 delete iDestinations[i]; |
|
1377 iDestinations.Remove( i ); |
|
1378 i--; |
|
1379 } |
|
1380 else |
|
1381 { |
|
1382 // Check also if the destination is an embedded destination |
|
1383 // anywhere, and remove that reference too. |
|
1384 TInt cmCount( iDestinations[i]->iConnMethodItemArray.Count() ); |
|
1385 if ( cmCount ) |
|
1386 { |
|
1387 if ( iDestinations[i]->iConnMethodItemArray[cmCount - 1].iId == aDestinationId ) |
|
1388 { |
|
1389 iDestinations[i]->iConnMethodItemArray.Remove( cmCount - 1 ); |
|
1390 } |
|
1391 } |
|
1392 } |
|
1393 } |
|
1394 |
|
1395 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVEDESTINATION_EXIT ); |
|
1396 } |
|
1397 |
|
1398 // --------------------------------------------------------------------------- |
|
1399 // Remove the connection method from all destinations in the current |
|
1400 // destination/connection method structures. This is a lot faster than calling |
|
1401 // Refresh(). The ID of any changed destination is added to the |
|
1402 // aChangedDestinations-array. |
|
1403 // --------------------------------------------------------------------------- |
|
1404 // |
|
1405 void CCmmInstanceMapping::RemoveConnMethodFromDestinations( |
|
1406 const TUint32 aConnMethodId, |
|
1407 RArray<TUint32>& aChangedDestinations ) |
|
1408 { |
|
1409 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_ENTRY ); |
|
1410 |
|
1411 // Remove given connection method from all destinations. |
|
1412 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1413 { |
|
1414 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1415 { |
|
1416 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1417 { |
|
1418 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1419 // Add ID of changed destination into array. Ignore any error. |
|
1420 aChangedDestinations.Append( iDestinations[i]->iId ); |
|
1421 break; |
|
1422 } |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_EXIT ); |
|
1427 } |
|
1428 |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // Iterate through destinations to find the one identified with provided ID |
|
1431 // and return its metadata. |
|
1432 // --------------------------------------------------------------------------- |
|
1433 // |
|
1434 TUint32 CCmmInstanceMapping::DestinationMetadata( |
|
1435 const TUint32 aDestinationId ) const |
|
1436 { |
|
1437 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONMETADATA_ENTRY ); |
|
1438 |
|
1439 TUint32 metadata( 0 ); |
|
1440 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1441 { |
|
1442 if ( iDestinations[i]->iId == aDestinationId ) |
|
1443 { |
|
1444 metadata = iDestinations[i]->iMetadata; |
|
1445 break; |
|
1446 } |
|
1447 } |
|
1448 |
|
1449 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONMETADATA_EXIT ); |
|
1450 return metadata; |
|
1451 } |
|
1452 |
|
1453 // End of file |