|
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 |
|
91 OstTraceFunctionExit0( DUP1_CDESTINATION_CDESTINATION_EXIT ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Second phase constructor. |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CDestination::ConstructL() |
|
99 { |
|
100 OstTraceFunctionEntry0( CDESTINATION_CONSTRUCTL_ENTRY ); |
|
101 OstTraceFunctionExit0( CDESTINATION_CONSTRUCTL_EXIT ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Two phased construction. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CCmmInstanceMapping* CCmmInstanceMapping::NewL( CCmmCache& aCache ) |
|
109 { |
|
110 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_NEWL_ENTRY ); |
|
111 |
|
112 CCmmInstanceMapping* self = CCmmInstanceMapping::NewLC( aCache ); |
|
113 CleanupStack::Pop( self ); |
|
114 |
|
115 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_NEWL_EXIT ); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // Two phased construction. |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CCmmInstanceMapping* CCmmInstanceMapping::NewLC( CCmmCache& aCache ) |
|
124 { |
|
125 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_NEWLC_ENTRY ); |
|
126 |
|
127 CCmmInstanceMapping* self = new( ELeave ) CCmmInstanceMapping( aCache ); |
|
128 CleanupStack::PushL( self ); |
|
129 self->ConstructL(); |
|
130 |
|
131 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_NEWLC_EXIT ); |
|
132 return self; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Destructor. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 CCmmInstanceMapping::~CCmmInstanceMapping() |
|
140 { |
|
141 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_ENTRY ); |
|
142 |
|
143 iConnMethodItemArray.Close(); |
|
144 iUnsupportedConnMethods.Close(); |
|
145 iDestinations.ResetAndDestroy(); |
|
146 iDeletedConnMethods.Close(); |
|
147 iDeletedDestinations.Close(); |
|
148 |
|
149 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_EXIT ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Constructor. |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 CCmmInstanceMapping::CCmmInstanceMapping( CCmmCache& aCache ) : iCache( aCache ) |
|
157 { |
|
158 OstTraceFunctionEntry0( DUP1_CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_ENTRY ); |
|
159 iEasyWlanId = 0; |
|
160 OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_CCMMINSTANCEMAPPING_EXIT ); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Second phase constructor. |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CCmmInstanceMapping::ConstructL() |
|
168 { |
|
169 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONSTRUCTL_ENTRY ); |
|
170 |
|
171 // Read connection methods from database and find the supported ones. |
|
172 ReadAndValidateConnMethodsL(); |
|
173 // Read destinations from database. |
|
174 ReadAndValidateDestinationsL(); |
|
175 |
|
176 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONSTRUCTL_EXIT ); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // Resets arrays and reads CMs and Connection Methods |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CCmmInstanceMapping::RefreshL() |
|
184 { |
|
185 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REFRESHL_ENTRY ); |
|
186 |
|
187 ReadAndValidateConnMethodsL(); |
|
188 ReadAndValidateDestinationsL(); |
|
189 |
|
190 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REFRESHL_EXIT ); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // Check if the given ID is a valid existing destination ID. |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CCmmInstanceMapping::ValidDestinationId( const TUint32& aId ) const |
|
198 { |
|
199 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDDESTINATIONID_ENTRY ); |
|
200 |
|
201 TBool validity( EFalse ); |
|
202 |
|
203 if ( aId > 0 ) |
|
204 { |
|
205 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
206 { |
|
207 if ( iDestinations[i]->iId == aId ) |
|
208 { |
|
209 validity = ETrue; |
|
210 break; |
|
211 } |
|
212 } |
|
213 } |
|
214 |
|
215 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDDESTINATIONID_EXIT ); |
|
216 return validity; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // Check if the given ID is a valid existing connection method ID. |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 TBool CCmmInstanceMapping::ValidConnMethodId( const TUint32& aId ) const |
|
224 { |
|
225 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_VALIDCONNMETHODID_ENTRY ); |
|
226 |
|
227 TBool validity( EFalse ); |
|
228 |
|
229 if ( aId > 0 ) |
|
230 { |
|
231 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
232 { |
|
233 if ( iConnMethodItemArray[i].iId == aId ) |
|
234 { |
|
235 validity = ETrue; |
|
236 break; |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_VALIDCONNMETHODID_EXIT ); |
|
242 return validity; |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // Check from database if the given destination is an embedded destination in |
|
247 // any other destination. |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 TBool CCmmInstanceMapping::DestinationIsEmbedded( const TUint32& aDestinationId ) const |
|
251 { |
|
252 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONISEMBEDDED_ENTRY ); |
|
253 |
|
254 TBool result( EFalse ); |
|
255 TInt index( 0 ); |
|
256 |
|
257 // Iterate through all destinations. |
|
258 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
259 { |
|
260 // An embedded destination is always at the very last position in |
|
261 // the connection method item array. |
|
262 index = iDestinations[i]->iConnMethodItemArray.Count() - 1; |
|
263 if ( index >= 0 ) |
|
264 { |
|
265 // We can skip bearer type check. If the last item isn't an |
|
266 // embedded destination, the ID will not match anyway. |
|
267 if ( iDestinations[i]->iConnMethodItemArray[index].iId == aDestinationId ) |
|
268 { |
|
269 result = ETrue; |
|
270 break; |
|
271 } |
|
272 } |
|
273 } |
|
274 |
|
275 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONISEMBEDDED_EXIT ); |
|
276 return result; |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // Check from database if the given destination has an embedded destination. |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 TBool CCmmInstanceMapping::DestinationHasEmbedded( const TUint32& aDestinationId ) const |
|
284 { |
|
285 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONHASEMBEDDED_ENTRY ); |
|
286 |
|
287 TBool result( EFalse ); |
|
288 |
|
289 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
290 { |
|
291 // Find the correct destination. |
|
292 if ( iDestinations[i]->iId == aDestinationId ) |
|
293 { |
|
294 // An embedded destination is always at the very last position in |
|
295 // the connection method item array. |
|
296 TInt index = iDestinations[i]->iConnMethodItemArray.Count() - 1; |
|
297 if ( index >= 0 ) |
|
298 { |
|
299 if ( iDestinations[i]->iConnMethodItemArray[index].iBearerType == KUidEmbeddedDestination ) |
|
300 { |
|
301 result = ETrue; |
|
302 } |
|
303 } |
|
304 break; |
|
305 } |
|
306 } |
|
307 |
|
308 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONHASEMBEDDED_EXIT ); |
|
309 return result; |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // Check from database if the given destination is pointed to by any virtual |
|
314 // IAP. |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 TBool CCmmInstanceMapping::DestinationPointedToByVirtualIap( |
|
318 const TUint32& /*aDestinationId*/ ) const |
|
319 { |
|
320 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_ENTRY ); |
|
321 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT ); |
|
322 |
|
323 return EFalse; //TODO, virtual IAPs are not yet supported. |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // Check from database if the given connection method is pointed to by any |
|
328 // virtual IAP. |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 TBool CCmmInstanceMapping::ConnMethodPointedToByVirtualIap( |
|
332 const TUint32& /*aConnMethodId*/ ) const |
|
333 { |
|
334 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_ENTRY ); |
|
335 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODPOINTEDTOBYVIRTUALIAP_EXIT ); |
|
336 |
|
337 return EFalse; //TODO, virtual IAPs are not yet supported. |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // Check if the given connection method is the only connection method in the |
|
342 // given destination and if a virtual IAP points to that destination. |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 TBool CCmmInstanceMapping::ConnMethodInDestinationButLocked( |
|
346 const TUint32& /*aConnMethodId*/, |
|
347 const TUint32& /*aDestinationId*/ ) const |
|
348 { |
|
349 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY ); |
|
350 |
|
351 // - Find correct destination. |
|
352 // - Check if it only has 1 CM. |
|
353 // - Check if the CM is the one given. |
|
354 // - Call DestinationPointedToByVirtualIap( aDestinationId ). |
|
355 // |
|
356 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODINDESTINATIONBUTLOCKED_EXIT ); |
|
357 |
|
358 return EFalse; //TODO, virtual IAPs are not yet supported. |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // Get bearer type of connection method matching given ID. |
|
363 // Return KErrNone if ID is found, KErrNotFound if not. |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CCmmInstanceMapping::GetConnMethodBearerType( |
|
367 const TUint32& aConnMethodId, |
|
368 TUint32& bearerType ) const |
|
369 { |
|
370 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODBEARERTYPE_ENTRY ); |
|
371 |
|
372 TInt result( KErrNotFound ); |
|
373 |
|
374 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
375 { |
|
376 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
377 { |
|
378 bearerType = iConnMethodItemArray[i].iBearerType; |
|
379 result = KErrNone; |
|
380 break; |
|
381 } |
|
382 } |
|
383 if ( result == KErrNotFound ) |
|
384 { |
|
385 // Embedded destinations are not in connection method array, need check from ID range. |
|
386 if ( aConnMethodId > KCmmDestIdIntervalMin && aConnMethodId < KCmmDestIdIntervalMax ) |
|
387 { |
|
388 bearerType = KUidEmbeddedDestination; |
|
389 result = KErrNone; |
|
390 } |
|
391 } |
|
392 |
|
393 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODBEARERTYPE_EXIT ); |
|
394 return result; |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // Returns the number of destinations the provided connection method belongs |
|
399 // to. Zero is returned if the connection method belongs to no destination |
|
400 // (legacy IAP) or does not exist. |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 TInt CCmmInstanceMapping::DestinationsContainingConnMethod( |
|
404 const TUint32& aConnMethodId ) const |
|
405 { |
|
406 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODREFERENCECOUNT_ENTRY ); |
|
407 |
|
408 TInt referenceCount( 0 ); |
|
409 TInt count( 0 ); |
|
410 |
|
411 // Go through each destination. |
|
412 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
413 { |
|
414 TBool foundInThisDestination( EFalse ); |
|
415 |
|
416 // Loop through all connection methods in this destination. |
|
417 count = iDestinations[i]->iConnMethodItemArray.Count(); |
|
418 for ( TInt j = 0; j < count; j++ ) |
|
419 { |
|
420 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
421 { |
|
422 foundInThisDestination = ETrue; |
|
423 referenceCount++; |
|
424 break; |
|
425 } |
|
426 } |
|
427 |
|
428 // Check unsupported connection methods also. |
|
429 if ( !foundInThisDestination ) |
|
430 { |
|
431 count = iDestinations[i]->iUnsupportedConnMethods.Count(); |
|
432 for ( TInt j = 0; j < count; j++ ) |
|
433 { |
|
434 if ( iDestinations[i]->iUnsupportedConnMethods[j] == aConnMethodId ) |
|
435 { |
|
436 referenceCount++; |
|
437 break; |
|
438 } |
|
439 } |
|
440 } |
|
441 } |
|
442 |
|
443 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODREFERENCECOUNT_EXIT ); |
|
444 return referenceCount; |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // Get database session. |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 CommsDat::CMDBSession& CCmmInstanceMapping::Session() const |
|
452 { |
|
453 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_SESSION_ENTRY ); |
|
454 |
|
455 return iCache.Session(); |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // Discovers all connection methods from database. Unsupported connection |
|
460 // methods are kept separately. |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 void CCmmInstanceMapping::ReadAndValidateConnMethodsL() |
|
464 { |
|
465 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_READANDVALIDATECONNMETHODSL_ENTRY ); |
|
466 |
|
467 CMDBRecordSet<CCDIAPRecord>* iapRecordSet = |
|
468 new( ELeave ) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
469 CleanupStack::PushL( iapRecordSet ); |
|
470 |
|
471 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
472 CleanupStack::PushL( iapRecord ); |
|
473 |
|
474 TRAP_IGNORE( iapRecordSet->LoadL( Session() ) ); |
|
475 |
|
476 //TODO, check from commsdat dump if all high-range IDs are available, or was some records |
|
477 //TODO used up by something. will this possibly affect cm/destination creation with predef ID? (Keijo) |
|
478 |
|
479 iConnMethodItemArray.Reset(); |
|
480 iUnsupportedConnMethods.Reset(); |
|
481 |
|
482 TInt iapRecordCount( iapRecordSet->iRecords.Count() ); |
|
483 TInt err( KErrNone ); |
|
484 TUint32 bearerType( 0 ); |
|
485 TUint bearerPriority( CMManager::KDataMobilitySelectionPolicyPriorityWildCard ); |
|
486 |
|
487 for ( TInt i = 0; i < iapRecordCount; i++ ) |
|
488 { |
|
489 TUint32 connMethodId( iapRecordSet->iRecords[i]->RecordId() ); |
|
490 |
|
491 // Check the connection method is not on the deleted list waiting to be deleted from database. |
|
492 TInt indexInDeletedList = iDeletedConnMethods.FindInOrder( ( TUint )connMethodId ); |
|
493 if ( indexInDeletedList == KErrNotFound ) |
|
494 { |
|
495 // Check the bearer type of the iap. Leaves if iap is unsupported. |
|
496 iapRecord->SetRecordId( connMethodId ); |
|
497 TRAP( err, iCache.BearerInfoFromIapRecordL( iapRecord, bearerType, bearerPriority ) ); //TODO |
|
498 if ( !err ) |
|
499 { |
|
500 TCmmConnMethodItem item( connMethodId, bearerType, bearerPriority, 0 ); |
|
501 iConnMethodItemArray.Append( item ); // Ignore errors. |
|
502 } |
|
503 else if ( err == KErrNotSupported ) |
|
504 { |
|
505 iUnsupportedConnMethods.Append( connMethodId ); // Ignore errors. |
|
506 } |
|
507 else if ( err == KErrNoMemory ) |
|
508 { |
|
509 User::Leave( err ); //TODO, check what this will cause. |
|
510 } |
|
511 } |
|
512 } |
|
513 |
|
514 CleanupStack::PopAndDestroy( iapRecord ); |
|
515 CleanupStack::PopAndDestroy( iapRecordSet ); |
|
516 |
|
517 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_READANDVALIDATECONNMETHODSL_EXIT ); |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // Discovers all destinations and the connection methods inside them. |
|
522 // Unsupported connection methods are kept separately. |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 void CCmmInstanceMapping::ReadAndValidateDestinationsL() |
|
526 { |
|
527 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_READANDVALIDATEDESTINATIONSL_ENTRY ); |
|
528 |
|
529 // Make 2 loops, first add destinations and then connection methods / embedded destinations. |
|
530 iDestinations.ResetAndDestroy(); |
|
531 |
|
532 // Explicitly build a TLinearOrder<class>. Used as parameter to RArray::InsertInOrder(). |
|
533 TLinearOrder<TCmmConnMethodItem> connMethodItemOrderingLogic( TCmmConnMethodItem::Compare ); |
|
534 |
|
535 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* snapRecordSet = |
|
536 new( ELeave ) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
537 iCache.TableId( ECmmDbSnapRecord ) ); |
|
538 CleanupStack::PushL( snapRecordSet ); |
|
539 |
|
540 CCDDataMobilitySelectionPolicyRecord* snapRecord = |
|
541 new( ELeave ) CCDDataMobilitySelectionPolicyRecord( |
|
542 iCache.TableId( ECmmDbSnapRecord ) ); |
|
543 CleanupStack::PushL( snapRecord ); |
|
544 |
|
545 TRAP_IGNORE( snapRecordSet->LoadL( Session() ) ); |
|
546 |
|
547 // Read snap ID, connection method ID and embedded destination ID. |
|
548 const TInt snapRecordCount( snapRecordSet->iRecords.Count() ); |
|
549 for ( TInt i = 0; i < snapRecordCount; i++ ) |
|
550 { |
|
551 snapRecord->SetElementId( snapRecordSet->iRecords[i]->ElementId() ); |
|
552 snapRecord->LoadL( Session() ); |
|
553 |
|
554 TUint32 destinationId = (TUint32)( snapRecord->iSNAP ); |
|
555 TInt indexInDeletedList = iDeletedDestinations.FindInOrder( ( TUint )destinationId ); |
|
556 if ( indexInDeletedList == KErrNotFound ) |
|
557 { |
|
558 TUint32 connMethodId = ( snapRecord->iIAP & KCDMaskShowRecordId ) >> 8; |
|
559 TUint32 embeddedDestinationId = (TUint32)( snapRecord->iEmbeddedSNAP ); |
|
560 |
|
561 // If connMethodId and embeddedDestinationId are 0 this is a destination. |
|
562 if ( connMethodId == 0 && embeddedDestinationId == 0 ) |
|
563 { |
|
564 TBool destAlreadyExists( EFalse ); |
|
565 for ( TInt j = 0; j < iDestinations.Count(); j++ ) |
|
566 { |
|
567 if ( destinationId == iDestinations[j]->iId ) |
|
568 { |
|
569 destAlreadyExists = ETrue; |
|
570 break; |
|
571 } |
|
572 } |
|
573 |
|
574 if ( !destAlreadyExists ) |
|
575 { |
|
576 CDestination* dest = CDestination::NewL(); |
|
577 dest->iId = destinationId; |
|
578 iDestinations.Append( dest ); |
|
579 } |
|
580 } |
|
581 } |
|
582 } |
|
583 |
|
584 // Read snap ID, connection method ID and embedded destination ID. |
|
585 for ( TInt i = 0; i < snapRecordCount; i++ ) |
|
586 { |
|
587 snapRecord->SetElementId( snapRecordSet->iRecords[i]->ElementId() ); |
|
588 snapRecord->LoadL( Session() ); |
|
589 |
|
590 TUint32 destinationId = (TUint32)( snapRecord->iSNAP ); |
|
591 TUint32 connMethodId = ( snapRecord->iIAP & KCDMaskShowRecordId ) >> 8; |
|
592 TUint32 embeddedDestinationId = (TUint32)( snapRecord->iEmbeddedSNAP ); |
|
593 |
|
594 // If connMethodId or embeddedDestinationId differs from 0 this is a connection method object. |
|
595 if ( connMethodId > 0 || embeddedDestinationId > 0 ) |
|
596 { |
|
597 // Find destination. |
|
598 CDestination* destination( NULL ); |
|
599 for ( TInt j = 0; j < iDestinations.Count(); j++ ) |
|
600 { |
|
601 if ( destinationId == iDestinations[j]->iId ) |
|
602 { |
|
603 destination = iDestinations[j]; |
|
604 break; |
|
605 } |
|
606 } |
|
607 |
|
608 if ( destination ) |
|
609 { |
|
610 if ( connMethodId ) |
|
611 { |
|
612 // Connection method, not embedded destination. |
|
613 TBool found( EFalse ); |
|
614 TCmmConnMethodItem item; |
|
615 |
|
616 // Find connection method. |
|
617 for ( TInt j = 0; j < iConnMethodItemArray.Count(); j++ ) |
|
618 { |
|
619 if ( iConnMethodItemArray[j].iId == connMethodId ) |
|
620 { |
|
621 item = iConnMethodItemArray[j]; |
|
622 found = ETrue; |
|
623 break; |
|
624 } |
|
625 } |
|
626 if ( found ) |
|
627 { |
|
628 // Make sure no duplicate entries are allowed. Any |
|
629 // duplicate would imply a corrupted CommsDat. |
|
630 TInt index = destination->iConnMethodItemArray.Find<TUint32>( |
|
631 connMethodId, |
|
632 TCmmConnMethodItem::FindCompare ); |
|
633 if ( index == KErrNotFound ) |
|
634 { |
|
635 item.iPriority = snapRecord->iPriority; |
|
636 destination->iConnMethodItemArray.InsertInOrderAllowRepeats( //TODO, if prio is 256, bearer type used? embeded should always be last. |
|
637 item, |
|
638 connMethodItemOrderingLogic ); // Ignore errors. |
|
639 } |
|
640 } |
|
641 else |
|
642 { |
|
643 // Check if the connection method is unsupported instead. |
|
644 for ( TInt j = 0; j < iUnsupportedConnMethods.Count(); j++ ) |
|
645 { |
|
646 if ( iUnsupportedConnMethods[j] == connMethodId ) |
|
647 { |
|
648 found = ETrue; |
|
649 break; |
|
650 } |
|
651 } |
|
652 if ( found ) |
|
653 { |
|
654 destination->iUnsupportedConnMethods.Append( connMethodId ); // Ignore errors. //TODO, allow repeats? |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 else |
|
660 { |
|
661 // Embedded destination, not IAP. |
|
662 // Prevent destinations from embedding themselves. |
|
663 if ( embeddedDestinationId != destinationId ) |
|
664 { |
|
665 // Check embedded destination ID is valid. |
|
666 TBool found( EFalse ); |
|
667 for ( TInt j = 0; j < iDestinations.Count(); j++ ) |
|
668 { |
|
669 if ( embeddedDestinationId == iDestinations[j]->iId ) |
|
670 { |
|
671 found = ETrue; |
|
672 break; |
|
673 } |
|
674 } |
|
675 if ( found ) |
|
676 { |
|
677 TCmmConnMethodItem item( |
|
678 embeddedDestinationId, |
|
679 KUidEmbeddedDestination, |
|
680 CMManager::KDataMobilitySelectionPolicyPriorityWildCard, |
|
681 CMManager::KDataMobilitySelectionPolicyPriorityWildCard ); |
|
682 destination->iConnMethodItemArray.InsertInOrderAllowRepeats( |
|
683 item, |
|
684 connMethodItemOrderingLogic ); |
|
685 } |
|
686 } |
|
687 } |
|
688 } |
|
689 } |
|
690 } |
|
691 CleanupStack::PopAndDestroy( snapRecord ); |
|
692 CleanupStack::PopAndDestroy( snapRecordSet ); |
|
693 |
|
694 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_READANDVALIDATEDESTINATIONSL_EXIT ); |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // Returns all conenction method IDs. Unsupported connection methods are |
|
699 // included if aCheckBearerType is set to EFalse. |
|
700 // --------------------------------------------------------------------------- |
|
701 // |
|
702 void CCmmInstanceMapping::GetAllConnMethodsL( |
|
703 RArray<TUint32>& aConnMethodArray, |
|
704 TBool aCheckBearerType ) const |
|
705 { |
|
706 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODSL_ENTRY ); |
|
707 |
|
708 TInt connMethodCount = iConnMethodItemArray.Count(); |
|
709 aConnMethodArray.Reset(); |
|
710 |
|
711 if ( aCheckBearerType ) |
|
712 { |
|
713 aConnMethodArray.ReserveL( connMethodCount ); |
|
714 } |
|
715 else |
|
716 { |
|
717 aConnMethodArray.ReserveL( connMethodCount + iUnsupportedConnMethods.Count() ); |
|
718 } |
|
719 |
|
720 for ( TInt i = 0; i < connMethodCount; i++ ) |
|
721 { |
|
722 aConnMethodArray.AppendL( iConnMethodItemArray[i].iId ); |
|
723 } |
|
724 if ( !aCheckBearerType ) |
|
725 { |
|
726 // Include unsupported connection methods also. |
|
727 for ( TInt i = 0; i < iUnsupportedConnMethods.Count(); i++ ) |
|
728 { |
|
729 aConnMethodArray.AppendL( iUnsupportedConnMethods[i] ); |
|
730 } |
|
731 } |
|
732 |
|
733 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODSL_EXIT ); |
|
734 } |
|
735 |
|
736 // --------------------------------------------------------------------------- |
|
737 // Return the number of destinations in database. |
|
738 // --------------------------------------------------------------------------- |
|
739 // |
|
740 TInt CCmmInstanceMapping::GetDestinationCount() const |
|
741 { |
|
742 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATIONCOUNT_ENTRY ); |
|
743 |
|
744 return iDestinations.Count(); |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // Return an array containing all destination IDs. |
|
749 // --------------------------------------------------------------------------- |
|
750 // |
|
751 void CCmmInstanceMapping::GetDestinationsL( RArray<TUint32>& aDestinationArray ) const |
|
752 { |
|
753 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETDESTINATIONSL_ENTRY ); |
|
754 |
|
755 aDestinationArray.Reset(); |
|
756 aDestinationArray.ReserveL( iDestinations.Count() ); // Re-allocates only if more is needed. |
|
757 |
|
758 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
759 { |
|
760 aDestinationArray.AppendL( iDestinations[i]->iId ); |
|
761 } |
|
762 |
|
763 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETDESTINATIONSL_EXIT ); |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // Inserts all the valid connection methods inside the given destination into |
|
768 // the provided connection method item array. The array is reset first. |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void CCmmInstanceMapping::GetConnMethodsFromDestinationL( |
|
772 const TUint32& aDestinationId, |
|
773 RArray<TCmmConnMethodItem>& aConnMethodArray ) const |
|
774 { |
|
775 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_GETCONNMETHODSFROMDESTINATIONL_ENTRY ); |
|
776 |
|
777 TBool destinationFound( EFalse ); |
|
778 |
|
779 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
780 { |
|
781 if ( iDestinations[i]->iId == aDestinationId ) |
|
782 { |
|
783 destinationFound = ETrue; |
|
784 aConnMethodArray.Reset(); |
|
785 aConnMethodArray.ReserveL( iDestinations[i]->iConnMethodItemArray.Count() ); |
|
786 |
|
787 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
788 { |
|
789 aConnMethodArray.AppendL( iDestinations[i]->iConnMethodItemArray[j] ); |
|
790 } |
|
791 break; |
|
792 } |
|
793 } |
|
794 if ( !destinationFound ) |
|
795 { |
|
796 User::Leave( KErrNotFound ); |
|
797 } |
|
798 |
|
799 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_GETCONNMETHODSFROMDESTINATIONL_EXIT ); |
|
800 } |
|
801 |
|
802 // --------------------------------------------------------------------------- |
|
803 // Check if the given connection method belongs to any other destination than |
|
804 // the one provided. |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 TBool CCmmInstanceMapping::ConnMethodInOtherDestination( |
|
808 const TUint32& aConnMethodId, |
|
809 const TUint32& aDestinationId ) |
|
810 { |
|
811 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_ENTRY ); |
|
812 |
|
813 // Loop through all destinations. |
|
814 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
815 { |
|
816 // Skip the specified destination. |
|
817 if ( iDestinations[i]->iId != aDestinationId ) |
|
818 { |
|
819 // Loop through all connection methods in the current destination. |
|
820 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
821 { |
|
822 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
823 { |
|
824 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
825 return ETrue; |
|
826 } |
|
827 } |
|
828 } |
|
829 } |
|
830 |
|
831 OstTraceFunctionExit0( DUP1_CCMMINSTANCEMAPPING_CONNMETHODINOTHERDESTINATION_EXIT ); |
|
832 return EFalse; |
|
833 } |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // Return the EasyWLAN IAP ID, zero if not found or WLAN not supported. |
|
837 // --------------------------------------------------------------------------- |
|
838 // |
|
839 TUint32 CCmmInstanceMapping::EasyWlanIdL() |
|
840 { |
|
841 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_EASYWLANIDL_ENTRY ); |
|
842 |
|
843 iEasyWlanId = 0; |
|
844 |
|
845 // Check WLAN support. |
|
846 if ( iCache.WlanSupported() ) |
|
847 { |
|
848 CMDBRecordSet<CCDIAPRecord>* iapRecordSet = |
|
849 new( ELeave ) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
850 CleanupStack::PushL( iapRecordSet ); |
|
851 TRAP_IGNORE( iapRecordSet->LoadL( Session() ) ); |
|
852 |
|
853 TInt iapRecordCount( iapRecordSet->iRecords.Count() ); |
|
854 for ( TInt i = 0; i < iapRecordCount; i++ ) |
|
855 { |
|
856 CCDIAPRecord* iapRecord = ( CCDIAPRecord* )iapRecordSet->iRecords[i]; |
|
857 |
|
858 if ( TPtrC( iapRecord->iServiceType ) == TPtrC( KCDTypeNameLANService ) && |
|
859 TPtrC( iapRecord->iBearerType ) == TPtrC( KCDTypeNameLANBearer ) ) |
|
860 { |
|
861 TUint32 serviceId = iapRecord->iService; |
|
862 |
|
863 CCDWlanServiceRecord* wlanServ = |
|
864 new( ELeave ) CCDWlanServiceRecord( |
|
865 CCDWlanServiceRecord::TableIdL( Session() ) ); |
|
866 CleanupStack::PushL( wlanServ ); |
|
867 |
|
868 wlanServ->iWlanServiceId.SetL( serviceId ); |
|
869 if ( wlanServ->FindL( Session() ) ) |
|
870 { |
|
871 wlanServ->LoadL( Session() ); |
|
872 // Only EasyWLAN IAP has NULL in SSID field. |
|
873 if ( wlanServ->iWLanSSID.IsNull() || |
|
874 !( TPtrC( wlanServ->iWLanSSID ).Compare( KNullDesC ) ) ) |
|
875 { |
|
876 iEasyWlanId = iapRecord->RecordId(); |
|
877 } |
|
878 } |
|
879 CleanupStack::PopAndDestroy( wlanServ ); |
|
880 } |
|
881 if ( iEasyWlanId != 0 ) |
|
882 { |
|
883 break; |
|
884 } |
|
885 } |
|
886 CleanupStack::PopAndDestroy( iapRecordSet ); |
|
887 } |
|
888 |
|
889 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_EASYWLANIDL_EXIT ); |
|
890 return iEasyWlanId; |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
|
894 // Find out the internet destination ID. ID is set to 0 if not found. |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 void CCmmInstanceMapping::InternetDestinationIdL( TUint& aInternetDestinationId ) |
|
898 { |
|
899 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_INTERNETDESTINATIONIDL_ENTRY ); |
|
900 |
|
901 // Set to zero in case the destination is not found. |
|
902 aInternetDestinationId = 0; |
|
903 |
|
904 CommsDat::CMDBRecordSet<CCDSNAPMetadataRecord>* metaSet = |
|
905 new( ELeave )CommsDat::CMDBRecordSet<CCDSNAPMetadataRecord>( |
|
906 iCache.TableId( ECmmDestMetadataRecord ) ); |
|
907 CleanupStack::PushL( metaSet ); |
|
908 |
|
909 TRAP_IGNORE( metaSet->LoadL( Session() ) ); |
|
910 |
|
911 CCDSNAPMetadataRecord* metadataRecord = |
|
912 new( ELeave ) CCDSNAPMetadataRecord( |
|
913 iCache.TableId( ECmmDestMetadataRecord ) ); |
|
914 CleanupStack::PushL( metadataRecord ); |
|
915 |
|
916 for ( TInt i = 0; i < metaSet->iRecords.Count(); i++ ) |
|
917 { |
|
918 metadataRecord->SetRecordId( metaSet->iRecords[i]->RecordId() ); |
|
919 metadataRecord->LoadL( Session() ); |
|
920 |
|
921 TUint32 metadata = metadataRecord->iMetadata; |
|
922 |
|
923 TUint32 internet = metadata & CMManager::ESnapMetadataInternet; |
|
924 TUint32 localizationValue = ( metadata & CMManager::ESnapMetadataDestinationIsLocalised ) >> 4; |
|
925 TUint32 purposeValue = ( metadata & CMManager::ESnapMetadataPurpose ) >> 8; |
|
926 |
|
927 // The first record that has a matching value in any of the 3 metadata |
|
928 // fields will be taken as the internet snap. |
|
929 if ( internet || |
|
930 ( localizationValue == CMManager::ELocalisedDestInternet ) || |
|
931 ( purposeValue == CMManager::ESnapPurposeInternet ) ) |
|
932 { |
|
933 TInt id = metadataRecord->iSNAP; |
|
934 if ( ValidDestinationId( ( TUint32 )id ) ) |
|
935 { |
|
936 aInternetDestinationId = ( TUint )id; |
|
937 break; |
|
938 } |
|
939 } |
|
940 } |
|
941 CleanupStack::PopAndDestroy( metadataRecord ); |
|
942 CleanupStack::PopAndDestroy( metaSet ); |
|
943 |
|
944 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_INTERNETDESTINATIONIDL_EXIT ); |
|
945 } |
|
946 |
|
947 // --------------------------------------------------------------------------- |
|
948 // Add a connection method ID to deleted list. Ignores any duplicates. Also |
|
949 // removes the connection method from destination/connection method structures |
|
950 // so Refresh()-call is not needed. Use this method if the connection method |
|
951 // has not been removed from database yet. |
|
952 // --------------------------------------------------------------------------- |
|
953 // |
|
954 void CCmmInstanceMapping::AddConnMethodToDeletedListL( const TUint& aConnMethodId ) |
|
955 { |
|
956 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDCONNMETHODTODELETEDLISTL_ENTRY ); |
|
957 |
|
958 iDeletedConnMethods.InsertInOrderL( aConnMethodId ); |
|
959 |
|
960 // Remove the connection method from current destination/connection method structures. |
|
961 RemoveConnMethod( aConnMethodId ); |
|
962 |
|
963 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_ADDCONNMETHODTODELETEDLISTL_EXIT ); |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // Remove a connection method ID from deleted list. Nothing happens if ID is |
|
968 // not found from the list. |
|
969 // --------------------------------------------------------------------------- |
|
970 // |
|
971 void CCmmInstanceMapping::RemoveConnMethodFromDeletedList( const TUint& aConnMethodId ) |
|
972 { |
|
973 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDELETEDLIST_ENTRY ); |
|
974 |
|
975 TInt index = iDeletedConnMethods.FindInOrder( aConnMethodId ); |
|
976 if ( index != KErrNotFound ) |
|
977 { |
|
978 iDeletedConnMethods.Remove( index ); |
|
979 } |
|
980 |
|
981 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDELETEDLIST_EXIT ); |
|
982 } |
|
983 |
|
984 // --------------------------------------------------------------------------- |
|
985 // Add a destination ID to deleted list. Ignores any duplicates. Also removes |
|
986 // the destination from destination/connection method structures so |
|
987 // Refresh()-call is not needed. Use this method if the connection method has |
|
988 // not been removed from database yet. |
|
989 // --------------------------------------------------------------------------- |
|
990 // |
|
991 void CCmmInstanceMapping::AddDestinationToDeletedListL( const TUint& aDestinationId ) |
|
992 { |
|
993 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_ADDDESTINATIONTODELETEDLISTL_ENTRY ); |
|
994 |
|
995 iDeletedDestinations.InsertInOrderL( aDestinationId ); |
|
996 |
|
997 // Remove the destination from current destination/connection method structures. |
|
998 RemoveDestination( aDestinationId ); |
|
999 |
|
1000 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_ADDDESTINATIONTODELETEDLISTL_EXIT ); |
|
1001 } |
|
1002 |
|
1003 // --------------------------------------------------------------------------- |
|
1004 // Remove a destination ID from deleted list. Nothing happens if ID is not |
|
1005 // found from the list. |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // |
|
1008 void CCmmInstanceMapping::RemoveDestinationFromDeletedList( const TUint& aDestinationId ) //TODO, check removal is called in all necessary places. |
|
1009 { |
|
1010 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATIONFROMDELETEDLIST_ENTRY ); |
|
1011 |
|
1012 TInt index = iDeletedDestinations.FindInOrder( aDestinationId ); |
|
1013 if ( index != KErrNotFound ) |
|
1014 { |
|
1015 iDeletedDestinations.Remove( index ); |
|
1016 } |
|
1017 |
|
1018 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVEDESTINATIONFROMDELETEDLIST_EXIT ); |
|
1019 } |
|
1020 |
|
1021 // --------------------------------------------------------------------------- |
|
1022 // Remove the connection method from current destination/connection method |
|
1023 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1024 // the connection method has been removed from database. |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // |
|
1027 void CCmmInstanceMapping::RemoveConnMethod( const TUint32& aConnMethodId ) //TODO, check where this is used and if it would be better to use version with array instead? |
|
1028 { |
|
1029 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHOD_ENTRY ); |
|
1030 |
|
1031 // Remove from list of connection methods. |
|
1032 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1033 { |
|
1034 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
1035 { |
|
1036 iConnMethodItemArray.Remove( i ); |
|
1037 break; |
|
1038 } |
|
1039 } |
|
1040 |
|
1041 // Remove connection method from all destinations. |
|
1042 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1043 { |
|
1044 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1045 { |
|
1046 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1047 { |
|
1048 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1049 break; |
|
1050 } |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHOD_EXIT ); |
|
1055 } |
|
1056 |
|
1057 // --------------------------------------------------------------------------- |
|
1058 // Remove the connection method from current destination/connection method |
|
1059 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1060 // the connection method has been removed from database. |
|
1061 // --------------------------------------------------------------------------- |
|
1062 // |
|
1063 void CCmmInstanceMapping::RemoveConnMethod( |
|
1064 const TUint32& aConnMethodId, |
|
1065 RArray<TUint32>& aChangedDestinations ) |
|
1066 { |
|
1067 |
|
1068 // Remove from list of connection methods. |
|
1069 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1070 { |
|
1071 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
1072 { |
|
1073 iConnMethodItemArray.Remove( i ); |
|
1074 break; |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 // Remove connection method from all destinations. |
|
1079 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1080 { |
|
1081 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1082 { |
|
1083 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1084 { |
|
1085 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1086 // Add ID of changed destination into array. Ignore any error. |
|
1087 aChangedDestinations.Append( iDestinations[i]->iId ); |
|
1088 break; |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 } |
|
1094 |
|
1095 // --------------------------------------------------------------------------- |
|
1096 // Remove the destination from current destination/connection method |
|
1097 // structures. This is a lot faster than calling Refresh(). Use this method if |
|
1098 // the connection method has been removed from database. |
|
1099 // --------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CCmmInstanceMapping::RemoveDestination( const TUint32& aDestinationId ) |
|
1102 { |
|
1103 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVEDESTINATION_ENTRY ); |
|
1104 |
|
1105 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1106 { |
|
1107 if ( iDestinations[i]->iId == aDestinationId ) |
|
1108 { |
|
1109 delete iDestinations[i]; |
|
1110 iDestinations.Remove( i ); |
|
1111 i--; |
|
1112 } |
|
1113 else |
|
1114 { |
|
1115 // Check also if the destination is an embedded destination |
|
1116 // anywhere, and remove that reference too. |
|
1117 TInt cmCount( iDestinations[i]->iConnMethodItemArray.Count() ); |
|
1118 if ( cmCount ) |
|
1119 { |
|
1120 if ( iDestinations[i]->iConnMethodItemArray[cmCount - 1].iId == aDestinationId ) |
|
1121 { |
|
1122 iDestinations[i]->iConnMethodItemArray.Remove( cmCount - 1 ); |
|
1123 } |
|
1124 } |
|
1125 } |
|
1126 } |
|
1127 |
|
1128 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVEDESTINATION_EXIT ); |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // Remove the connection method from all destinations in the current |
|
1133 // destination/connection method structures. This is a lot faster than calling |
|
1134 // Refresh(). The ID of any changed destination is added to the |
|
1135 // aChangedDestinations-array. |
|
1136 // --------------------------------------------------------------------------- |
|
1137 // |
|
1138 void CCmmInstanceMapping::RemoveConnMethodFromDestinations( |
|
1139 const TUint32& aConnMethodId, |
|
1140 RArray<TUint32>& aChangedDestinations ) |
|
1141 { |
|
1142 OstTraceFunctionEntry0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_ENTRY ); |
|
1143 |
|
1144 // Remove given connection method from all destinations. |
|
1145 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
1146 { |
|
1147 for ( TInt j = 0; j < iDestinations[i]->iConnMethodItemArray.Count(); j++ ) |
|
1148 { |
|
1149 if ( iDestinations[i]->iConnMethodItemArray[j].iId == aConnMethodId ) |
|
1150 { |
|
1151 iDestinations[i]->iConnMethodItemArray.Remove( j ); |
|
1152 // Add ID of changed destination into array. Ignore any error. |
|
1153 aChangedDestinations.Append( iDestinations[i]->iId ); |
|
1154 break; |
|
1155 } |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 OstTraceFunctionExit0( CCMMINSTANCEMAPPING_REMOVECONNMETHODFROMDESTINATIONS_EXIT ); |
|
1160 } |
|
1161 |
|
1162 // End of file |