|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of CCmManagerImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmmanagerimpl.h" |
|
19 #include <cmpluginbaseeng.h> |
|
20 #include <cmpluginbase.h> |
|
21 #include <cmdestination.h> |
|
22 #include <cmdestinationext.h> |
|
23 #include "cmdestinationimpl.h" |
|
24 #include "cmtransactionhandler.h" |
|
25 #include "cmlogger.h" |
|
26 #include "cmmanager.hrh" |
|
27 #include <cmcommonconstants.h> |
|
28 #include <cmmanagerext.h> |
|
29 #include <cmpluginembdestinationdef.h> |
|
30 #include "cmobjectpool.h" |
|
31 #include "cmcommsdatnotifier.h" |
|
32 |
|
33 #include <sysutil.h> |
|
34 #include <featmgr.h> |
|
35 #include <wlancontainer.h> // CCDWlanServiceRecord |
|
36 #include <StringLoader.h> |
|
37 #include <commsdattypesv1_1.h> |
|
38 #include <e32cmn.h> |
|
39 #include <bautils.h> // BaflUtils |
|
40 #include <cmmanager.rsg> // resource |
|
41 #include <data_caging_path_literals.hrh> |
|
42 #include <ecom/ecom.h> // For REComSession |
|
43 #include <cmmanagerext.h> |
|
44 |
|
45 #include <cmmanager.mbg> // icons |
|
46 #include <AknsUtils.h> |
|
47 |
|
48 #include <commsdattypesv1_1.h> |
|
49 #include <rconnmon.h> |
|
50 |
|
51 using namespace CMManager; |
|
52 using namespace CommsDat; |
|
53 |
|
54 // CONSTANTS |
|
55 |
|
56 const TInt KResFileGranularity = 5; |
|
57 const TInt KPluginGranularity = 3; |
|
58 // if a CmId is grater than KMaxIapId, than it has no iap record |
|
59 // Otherwise cmId is the same as the IapId |
|
60 const TUint32 KMaxIapID = 255; |
|
61 // Safety margin when checking disk space |
|
62 const TUint32 KBytesToWrite = 8000; |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // Test functions |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 /*#ifdef _DEBUG |
|
69 void DumIapTableL( CMDBSession& aSession ) |
|
70 { |
|
71 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = |
|
72 new (ELeave) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
73 CleanupStack::PushL( ptrRecordSet ); |
|
74 |
|
75 TRAP_IGNORE( ptrRecordSet->LoadL( aSession ) ); |
|
76 |
|
77 TInt iapRecords = ptrRecordSet->iRecords.Count(); |
|
78 CLOG_WRITE_1_PTR( NULL, "Dumping IAP Table\nNo. of IAPs: [%d]", iapRecords ); |
|
79 for ( TInt i = 0; i < iapRecords; i++ ) |
|
80 { |
|
81 CCDIAPRecord* iapRecord = (*ptrRecordSet)[i]; |
|
82 |
|
83 CLOG_WRITE_4_PTR( NULL, "Rec id:[%d] - Name: [%S] - Service Type: [%S] - Bearer Type: [%S]", |
|
84 iapRecord->RecordId(), |
|
85 &FIELD_TO_TDESC( iapRecord->iRecordName ), |
|
86 &FIELD_TO_TDESC( iapRecord->iServiceType ), |
|
87 &FIELD_TO_TDESC( iapRecord->iBearerType ) |
|
88 ); |
|
89 } |
|
90 |
|
91 CleanupStack::PopAndDestroy( ptrRecordSet ); |
|
92 } |
|
93 #endif */ // _DEBUG |
|
94 |
|
95 //============================================================================= |
|
96 // CONSTRUCTION / DESTRUCTION API |
|
97 //============================================================================= |
|
98 // |
|
99 |
|
100 //----------------------------------------------------------------------------- |
|
101 // CCmManagerImpl::NewL() |
|
102 //----------------------------------------------------------------------------- |
|
103 // |
|
104 CCmManagerImpl* CCmManagerImpl::NewL( TBool aCreateTables ) |
|
105 { |
|
106 CCmManagerImpl* self = new (ELeave) CCmManagerImpl(); |
|
107 CleanupStack::PushL( self ); |
|
108 self->iCreateTables = aCreateTables; |
|
109 self->ConstructL(); |
|
110 CleanupStack::Pop( self ); // self |
|
111 |
|
112 return self; |
|
113 } |
|
114 |
|
115 //----------------------------------------------------------------------------- |
|
116 // CCmManagerImpl::CCmManagerImpl() |
|
117 //----------------------------------------------------------------------------- |
|
118 // |
|
119 CCmManagerImpl::CCmManagerImpl() |
|
120 :iDefConnSupported(EFalse),iCreateTables(ETrue) |
|
121 { |
|
122 CLOG_CREATE; |
|
123 |
|
124 Dll::SetTls( this ); |
|
125 } |
|
126 |
|
127 //----------------------------------------------------------------------------- |
|
128 // CCmManagerImpl::CCmManagerImpl() |
|
129 //----------------------------------------------------------------------------- |
|
130 // |
|
131 CCmManagerImpl::~CCmManagerImpl() |
|
132 { |
|
133 CLOG_WRITE( "CCmManagerImpl::~CCmManagerImpl" ); |
|
134 |
|
135 if ( iBearerPriorityArray ) |
|
136 { |
|
137 CleanupGlobalPriorityArray( *iBearerPriorityArray ); |
|
138 delete iBearerPriorityArray; |
|
139 } |
|
140 |
|
141 if ( iPlugins ) |
|
142 { |
|
143 iPlugins->ResetAndDestroy(); |
|
144 delete iPlugins; |
|
145 } |
|
146 |
|
147 |
|
148 if ( iResourceFiles ) |
|
149 { |
|
150 TInt resCount = iResourceFiles->Count(); |
|
151 for ( TInt i = 0; i < resCount; ++i ) |
|
152 { |
|
153 // close the resource file |
|
154 (*iResourceFiles)[0]->iFile.Close(); |
|
155 // delete the structure |
|
156 delete (*iResourceFiles)[0]; |
|
157 // delete array item |
|
158 iResourceFiles->Delete( 0 ); |
|
159 } |
|
160 |
|
161 iResourceFiles->Reset(); |
|
162 delete iResourceFiles; |
|
163 } |
|
164 |
|
165 iFs.Close(); |
|
166 |
|
167 delete iPluginImpl; |
|
168 |
|
169 delete &Session(); |
|
170 delete iTrans; |
|
171 |
|
172 if( iIsFeatureManagerInitialised ) |
|
173 { |
|
174 FeatureManager::UnInitializeLib(); |
|
175 } |
|
176 |
|
177 REComSession::FinalClose(); |
|
178 |
|
179 delete iObjectPool; |
|
180 |
|
181 delete iCommsDatIapNotifier; |
|
182 delete iCommsDatSnapNotifier; |
|
183 |
|
184 CLOG_CLOSE; |
|
185 } |
|
186 |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CCmManagerImpl::CheckTablesL() |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CCmManagerImpl::CheckTablesL() |
|
193 { |
|
194 LOGGER_ENTERFN( "CCmManagerImpl::CheckDestinationNetworkTableL" ); |
|
195 |
|
196 TInt err( 0 ); |
|
197 |
|
198 CLOG_WRITE( "Destination network" ); |
|
199 if (iCreateTables) |
|
200 { |
|
201 TRAP( err, iDestinationTableId = |
|
202 CCDDataMobilitySelectionPolicyRecord::TableIdL( Session() )); |
|
203 CLOG_WRITE_1( "err: [%d]", err ); |
|
204 if( err == KErrNotFound ) |
|
205 { |
|
206 iDestinationTableId = |
|
207 CCDDataMobilitySelectionPolicyRecord::CreateTableL( Session() ); |
|
208 } |
|
209 else |
|
210 { |
|
211 User::LeaveIfError( err ); |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 iDestinationTableId = |
|
217 CCDDataMobilitySelectionPolicyRecord::TableIdL( Session() ); |
|
218 } |
|
219 |
|
220 CLOG_WRITE( "Global Bearer Type Priorization Table" ); |
|
221 TRAP( err, iBearerTypePriorizationTableId = |
|
222 CCDGlobalBearerTypePriorizationRecord::TableIdL( Session() ) ); |
|
223 CLOG_WRITE_1( "err: [%d]", err ); |
|
224 if( err == KErrNotFound ) |
|
225 { |
|
226 iBearerTypePriorizationTableId = |
|
227 CCDGlobalBearerTypePriorizationRecord::CreateTableL( Session() ); |
|
228 } |
|
229 else |
|
230 { |
|
231 User::LeaveIfError( err ); |
|
232 } |
|
233 |
|
234 CLOG_WRITE( "Destination network - Icon table" ); |
|
235 TRAP( err, iIconTableId = CCDSNAPMetadataRecord::TableIdL( Session() ) ); |
|
236 if( err == KErrNotFound ) |
|
237 { |
|
238 iIconTableId = CCDSNAPMetadataRecord::CreateTableL( Session() ); |
|
239 } |
|
240 else |
|
241 { |
|
242 User::LeaveIfError( err ); |
|
243 } |
|
244 |
|
245 CLOG_WRITE( "Seamlessness table" ); |
|
246 TRAP( err, iSeamlessnessTableId = CCDIAPMetadataRecord::TableIdL( Session() ) ); |
|
247 CLOG_WRITE_1( "err: [%d]", err ); |
|
248 if( err == KErrNotFound ) |
|
249 { |
|
250 iSeamlessnessTableId = CCDIAPMetadataRecord::CreateTableL( Session() ); |
|
251 } |
|
252 else |
|
253 { |
|
254 User::LeaveIfError( err ); |
|
255 } |
|
256 if ( IsDefConnSupported() ) |
|
257 { |
|
258 CLOG_WRITE( "Default connection table" ); |
|
259 TRAP( err, iDefConnTableId = CCDDefConnRecord::TableIdL( Session() ) ); |
|
260 CLOG_WRITE_1( "err: [%d]", err ); |
|
261 if( err == KErrNotFound ) |
|
262 { |
|
263 iDefConnTableId = CCDDefConnRecord::CreateTableL( Session() ); |
|
264 } |
|
265 else |
|
266 { |
|
267 User::LeaveIfError( err ); |
|
268 } |
|
269 } |
|
270 } |
|
271 |
|
272 //----------------------------------------------------------------------------- |
|
273 // CCmManagerImpl::CreateBearerPriorityArrayL() |
|
274 //----------------------------------------------------------------------------- |
|
275 // |
|
276 void CCmManagerImpl::CreateBearerPriorityArrayL() |
|
277 { |
|
278 LOGGER_ENTERFN( "CCmManagerImpl:CreateBearerPriorityArray" ); |
|
279 |
|
280 iBearerPriorityArray = |
|
281 new ( ELeave ) RArray<TBearerPriority>( KCmArrayBigGranularity ); |
|
282 |
|
283 CMDBRecordSet<CCmBearerPriRec>* bpRS = |
|
284 new (ELeave) CMDBRecordSet<CCmBearerPriRec>( |
|
285 iBearerTypePriorizationTableId ); |
|
286 CleanupStack::PushL( bpRS ); |
|
287 |
|
288 OpenTransactionLC(); |
|
289 TRAP_IGNORE( bpRS->LoadL( Session() ) ); |
|
290 RollbackTransaction(); |
|
291 |
|
292 TInt bpCount = bpRS->iRecords.Count(); |
|
293 TInt i( 0 ); |
|
294 |
|
295 while ( i < bpCount ) // loop the Bearer Priority table |
|
296 { |
|
297 // Bearer Priority record ID |
|
298 HBufC* bpServiceType = QUERY_HBUFC_FIELD( (*bpRS)[i], |
|
299 KCDTIdGlobalServiceType ); |
|
300 |
|
301 TInt bpPriority = ( QUERY_INT_FIELD( (*bpRS)[i], |
|
302 KCDTIdGlobalServicePriority ) ); |
|
303 TInt uiPriority = ( QUERY_INT_FIELD( (*bpRS)[i], |
|
304 KCDTIdGlobalServiceUIPriority ) ); |
|
305 CLOG_WRITE( "Bearer Priority Table Values" ); |
|
306 CLOG_WRITE_1( "Service Type: [%S]", bpServiceType ); |
|
307 CLOG_WRITE_1( "Bearer Priority: [%d]", bpPriority ); |
|
308 CLOG_WRITE_1( "UI Priority: [%d]", uiPriority ); |
|
309 TBearerPriority bp; |
|
310 bp.iServiceType = bpServiceType->AllocL(); |
|
311 bp.iPriority = bpPriority; |
|
312 bp.iUIPriority = uiPriority; |
|
313 iBearerPriorityArray->AppendL( bp ); |
|
314 i++; |
|
315 } |
|
316 |
|
317 CleanupStack::PopAndDestroy( bpRS ); |
|
318 } |
|
319 |
|
320 //----------------------------------------------------------------------------- |
|
321 // CCmManagerImpl::BearerPriorityArrayL() |
|
322 //----------------------------------------------------------------------------- |
|
323 // |
|
324 void CCmManagerImpl::BearerPriorityArrayL( RArray<TBearerPriority>& aArray ) const |
|
325 { |
|
326 LOGGER_ENTERFN( "CCmManagerImpl:BearerPriorityArray" ); |
|
327 TRAPD( err, CopyBearerPriorityArrayL( aArray ) ); |
|
328 if( err ) |
|
329 // in case of any problem we clean up this array |
|
330 { |
|
331 User::Leave( err ); |
|
332 } |
|
333 } |
|
334 |
|
335 //----------------------------------------------------------------------------- |
|
336 // CCmManagerImpl::CopyBearerPriorityArrayL() |
|
337 //----------------------------------------------------------------------------- |
|
338 // |
|
339 void CCmManagerImpl::CopyBearerPriorityArrayL( |
|
340 RArray<TBearerPriority>& aArray ) const |
|
341 { |
|
342 LOGGER_ENTERFN( "CCmManagerImpl:BearerPriorityArray" ); |
|
343 for ( TInt i = 0; i < iBearerPriorityArray->Count(); i++ ) |
|
344 { |
|
345 TBearerPriority item; |
|
346 |
|
347 TBearerPriority* orgItem = &(*iBearerPriorityArray)[i]; |
|
348 |
|
349 item.iServiceType = HBufC::NewLC( orgItem->iServiceType->Length() ); |
|
350 item.iServiceType->Des().Copy( *orgItem->iServiceType ); |
|
351 item.iPriority = orgItem->iPriority; |
|
352 item.iUIPriority = orgItem->iUIPriority; |
|
353 |
|
354 User::LeaveIfError( aArray.Append( item ) ); |
|
355 |
|
356 CleanupStack::Pop(); // item->iServiceType |
|
357 } |
|
358 } |
|
359 |
|
360 //----------------------------------------------------------------------------- |
|
361 // CCmManagerImpl::UpdateBearerPriorityArrayL() |
|
362 //----------------------------------------------------------------------------- |
|
363 // |
|
364 void CCmManagerImpl::UpdateBearerPriorityArrayL( |
|
365 const RArray<TBearerPriority>& aArray ) |
|
366 { |
|
367 LOGGER_ENTERFN( "CCmManagerImpl::UpdateBearerPriorityArray" ); |
|
368 |
|
369 OpenTransactionLC(); |
|
370 |
|
371 CMDBRecordSet<CCmBearerPriRec>* bpRS = new (ELeave) |
|
372 CMDBRecordSet<CCmBearerPriRec>( iBearerTypePriorizationTableId ); |
|
373 CleanupStack::PushL( bpRS ); // 1 |
|
374 TRAP_IGNORE( bpRS->LoadL( Session() ) ); |
|
375 |
|
376 // Delete the old record |
|
377 for ( TInt i = 0; i < bpRS->iRecords.Count(); ++i ) |
|
378 { |
|
379 bpRS->iRecords[i]->DeleteL( Session() ); |
|
380 } |
|
381 |
|
382 CleanupGlobalPriorityArray( *iBearerPriorityArray ); |
|
383 |
|
384 CleanupStack::PopAndDestroy( bpRS ); |
|
385 bpRS = NULL; |
|
386 |
|
387 // Add the new content |
|
388 CCmBearerPriRec* bpRcd = |
|
389 new (ELeave) CCmBearerPriRec( iBearerTypePriorizationTableId ); |
|
390 CleanupStack::PushL( bpRcd ); // 2 |
|
391 |
|
392 CLOG_WRITE( "Store bearer info to table" ); |
|
393 for ( TInt i = 0; i < aArray.Count(); ++i ) |
|
394 { |
|
395 bpRcd->SetRecordId( KCDNewRecordRequest ); |
|
396 |
|
397 HBufC* serviceTypeVal = aArray[i].iServiceType; |
|
398 TInt priorityVal = aArray[i].iPriority; |
|
399 TInt uiPriorityVal = aArray[i].iUIPriority; |
|
400 |
|
401 CLOG_WRITE_FORMAT( "Set service type: [%S ]", serviceTypeVal ); |
|
402 SET_HBUFC_FIELD( bpRcd, |
|
403 KCDTIdGlobalServiceType, |
|
404 serviceTypeVal ); |
|
405 CLOG_WRITE_1( "Set priority: [%d]", priorityVal ); |
|
406 SET_INT_FIELD( bpRcd, |
|
407 KCDTIdGlobalServicePriority, |
|
408 priorityVal ); |
|
409 CLOG_WRITE_1( "Set uipriority: [%d]", uiPriorityVal ); |
|
410 SET_INT_FIELD( bpRcd, |
|
411 KCDTIdGlobalServiceUIPriority, |
|
412 uiPriorityVal ); |
|
413 bpRcd->StoreL( Session() ); |
|
414 |
|
415 TBearerPriority item; |
|
416 |
|
417 item.iServiceType = serviceTypeVal->AllocLC(); |
|
418 item.iPriority = priorityVal; |
|
419 item.iUIPriority = uiPriorityVal; |
|
420 iBearerPriorityArray->AppendL( item ); |
|
421 CleanupStack::Pop( item.iServiceType ); |
|
422 } |
|
423 |
|
424 CleanupStack::PopAndDestroy( bpRcd ); |
|
425 |
|
426 CommitTransactionL( KErrNone ); |
|
427 } |
|
428 |
|
429 //----------------------------------------------------------------------------- |
|
430 // CCmManagerImpl::GlobalBearerPriority() |
|
431 //----------------------------------------------------------------------------- |
|
432 // |
|
433 TInt CCmManagerImpl::GlobalBearerPriority( TBool aUiPriority, |
|
434 const TDesC& aServiceType ) const |
|
435 { |
|
436 for ( TInt i = 0; i < iBearerPriorityArray->Count(); ++i ) |
|
437 { |
|
438 if ( !aServiceType.CompareF( *(*iBearerPriorityArray)[i].iServiceType ) ) |
|
439 { |
|
440 if( aUiPriority ) |
|
441 { |
|
442 return (*iBearerPriorityArray)[i].iUIPriority; |
|
443 } |
|
444 else |
|
445 { |
|
446 return (*iBearerPriorityArray)[i].iPriority; |
|
447 } |
|
448 } |
|
449 } |
|
450 |
|
451 return KDataMobilitySelectionPolicyPriorityWildCard; |
|
452 } |
|
453 |
|
454 //----------------------------------------------------------------------------- |
|
455 // CCmManagerImpl::CleanupGlobalPriorityArray() |
|
456 //----------------------------------------------------------------------------- |
|
457 // |
|
458 void CCmManagerImpl::CleanupGlobalPriorityArray( |
|
459 RArray<TBearerPriority>& aArray ) const |
|
460 { |
|
461 LOGGER_ENTERFN( "CCmManagerImpl::CleanupGlobalPriorityArray" ); |
|
462 |
|
463 for ( TInt i = 0; i < aArray.Count(); ++i ) |
|
464 { |
|
465 delete aArray[i].iServiceType; |
|
466 } |
|
467 |
|
468 aArray.Reset(); |
|
469 aArray.Close(); |
|
470 } |
|
471 |
|
472 //----------------------------------------------------------------------------- |
|
473 // CCmManagerImpl::AddResourceFileL() |
|
474 //----------------------------------------------------------------------------- |
|
475 // |
|
476 void CCmManagerImpl::AddResourceFileL( TFileName& aName ) |
|
477 { |
|
478 LOGGER_ENTERFN( "CCmManagerImpl::AddResourceFileL" ); |
|
479 |
|
480 TInt index = FindResourceFile( aName ); |
|
481 |
|
482 if ( index != KErrNotFound ) |
|
483 { |
|
484 ++(*iResourceFiles)[index]->iRefs; |
|
485 return; |
|
486 } |
|
487 |
|
488 TResourceFiles* newRes = new (ELeave) TResourceFiles; |
|
489 CleanupStack::PushL( newRes ); |
|
490 |
|
491 RResourceFile resFile; |
|
492 resFile.OpenL( iFs, aName ); |
|
493 CleanupClosePushL( resFile ); |
|
494 |
|
495 resFile.ConfirmSignatureL(0); |
|
496 |
|
497 newRes->iFile = resFile; |
|
498 newRes->iFName.Copy( aName ); |
|
499 newRes->iRefs = 1; // 1 reference to this resource file |
|
500 |
|
501 iResourceFiles->AppendL( newRes ); |
|
502 |
|
503 CleanupStack::Pop( 2 ); // resFile, newRes |
|
504 } |
|
505 |
|
506 //----------------------------------------------------------------------------- |
|
507 // CCmManagerImpl::RemoveResourceFile() |
|
508 //----------------------------------------------------------------------------- |
|
509 // |
|
510 void CCmManagerImpl::RemoveResourceFile( TFileName& aName ) |
|
511 { |
|
512 LOGGER_ENTERFN( "CCmManagerImpl::RemoveResourceFile" ); |
|
513 |
|
514 TInt index = FindResourceFile( aName ); |
|
515 |
|
516 if ( index == KErrNotFound ) |
|
517 { |
|
518 return; |
|
519 } |
|
520 |
|
521 if ( !--(*iResourceFiles)[index]->iRefs ) |
|
522 // it was the last reference |
|
523 { |
|
524 (*iResourceFiles)[index]->iFile.Close(); |
|
525 delete (*iResourceFiles)[index]; |
|
526 |
|
527 iResourceFiles->Delete( index ); |
|
528 } |
|
529 } |
|
530 |
|
531 //----------------------------------------------------------------------------- |
|
532 // CCmManagerImpl::FindResourceFile() |
|
533 //----------------------------------------------------------------------------- |
|
534 // |
|
535 TInt CCmManagerImpl::FindResourceFile( TFileName& aName ) const |
|
536 { |
|
537 LOGGER_ENTERFN( "CCmManagerImpl::FindResourceFile" ); |
|
538 |
|
539 BaflUtils::NearestLanguageFile( iFs, aName ); |
|
540 |
|
541 for ( TInt i = 0; i < iResourceFiles->Count(); ++i ) |
|
542 { |
|
543 if ( !(*iResourceFiles)[i]->iFName.CompareF( aName ) ) |
|
544 { |
|
545 return i; |
|
546 } |
|
547 } |
|
548 |
|
549 return KErrNotFound; |
|
550 } |
|
551 |
|
552 //----------------------------------------------------------------------------- |
|
553 // CCmManagerImpl::AllocReadL() |
|
554 //----------------------------------------------------------------------------- |
|
555 // |
|
556 HBufC* CCmManagerImpl::AllocReadL( TInt aResourceId ) const |
|
557 { |
|
558 LOGGER_ENTERFN( "CCmManagerImpl::AllocReadL" ); |
|
559 |
|
560 HBufC* retVal = NULL; |
|
561 |
|
562 // Scan all resource files to find owner |
|
563 for (TInt i=0; i < iResourceFiles->Count(); i++) |
|
564 { |
|
565 RResourceFile& file=(*iResourceFiles)[i]->iFile; |
|
566 if ( file.OwnsResourceId(aResourceId) ) |
|
567 { |
|
568 HBufC8* readBuffer = file.AllocReadLC( aResourceId ); |
|
569 // as we are expecting HBufC16... |
|
570 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(), |
|
571 readBuffer->Length() >> 1 ); |
|
572 retVal=HBufC16::NewL( ptrReadBuffer.Length() ); |
|
573 retVal->Des().Copy( ptrReadBuffer ); |
|
574 CleanupStack::PopAndDestroy( readBuffer ); // readBuffer |
|
575 |
|
576 // exit from loop |
|
577 break; |
|
578 } |
|
579 } |
|
580 |
|
581 return retVal; |
|
582 } |
|
583 |
|
584 //----------------------------------------------------------------------------- |
|
585 // CCmManagerImpl::ConstructL() |
|
586 //----------------------------------------------------------------------------- |
|
587 // |
|
588 void CCmManagerImpl::ConstructL() |
|
589 { |
|
590 LOGGER_ENTERFN( "CCmManagerImpl::ConstructL" ); |
|
591 CLOG_NAME_1( _L("ManagerImpl_0x%x"), this ); |
|
592 |
|
593 iObjectPool = new (ELeave) CCMObjectPool(*this); |
|
594 |
|
595 FeatureManager::InitializeLibL(); |
|
596 iIsFeatureManagerInitialised = ETrue; |
|
597 iHelp = FeatureManager::FeatureSupported( KFeatureIdHelp ); |
|
598 iDefConnSupported = ETrue; |
|
599 //iDefConnSupported = FeatureManager::FeatureSupported( KFeatureIdDefaultConnection ); |
|
600 iWLan = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ); |
|
601 |
|
602 CMDBSession* db = CMDBSession::NewL( KCDVersion1_2 ); |
|
603 |
|
604 iTrans = CCmTransactionHandler::NewL( *db ); |
|
605 CLOG_ATTACH( iTrans, this ); |
|
606 |
|
607 User::LeaveIfError( iFs.Connect() ); |
|
608 |
|
609 iResourceFiles = new (ELeave) CArrayPtrFlat<TResourceFiles>( |
|
610 KResFileGranularity ); |
|
611 |
|
612 TParse fp; |
|
613 TInt err = fp.Set( KACMManagerResDirAndFileName, |
|
614 &KDC_RESOURCE_FILES_DIR, |
|
615 NULL ); |
|
616 CLOG_WRITE_1( "Set: [%d]", err ); |
|
617 if ( err != KErrNone) |
|
618 { |
|
619 User::Leave( err ); |
|
620 } |
|
621 |
|
622 TFileName fName; |
|
623 |
|
624 fName.Copy( fp.FullName() ); |
|
625 |
|
626 AddResourceFileL( fName ); |
|
627 |
|
628 CheckTablesL(); |
|
629 CreateBearerPriorityArrayL(); |
|
630 |
|
631 BuildPluginArrayL(); |
|
632 |
|
633 TCmPluginInitParam params( *this ); |
|
634 |
|
635 params.iParentDest = NULL; |
|
636 iPluginImpl = CCmConnectionMethodInfo::NewL( ¶ms ); |
|
637 CLOG_ATTACH( iPluginImpl, this ); |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 // CCmManagerImpl::OpenTransactionLC |
|
642 // --------------------------------------------------------------------------- |
|
643 // |
|
644 void CCmManagerImpl::OpenTransactionLC( TBool aSetAttribs ) |
|
645 { |
|
646 LOGGER_ENTERFN( "CCmManagerImpl::OpenTransactionL" ); |
|
647 |
|
648 iTrans->OpenTransactionLC( aSetAttribs ); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // CCmDestinationImpl::CommitTransactionL |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CCmManagerImpl::CommitTransactionL( TInt aError ) |
|
656 { |
|
657 LOGGER_ENTERFN( "CCmManagerImpl::CommitTransactionL" ); |
|
658 |
|
659 iTrans->CommitTransactionL( aError ); |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------------------------- |
|
663 // CCmDestinationImpl::CommitTransactionL |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 void CCmManagerImpl::RollbackTransaction() |
|
667 { |
|
668 LOGGER_ENTERFN( "CCmManagerImpl::RollbackTransaction" ); |
|
669 CleanupStack::Pop( iTrans ); |
|
670 iTrans->Close(); |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------------------------- |
|
674 // CCmDestinationImpl::StartCommsDatNotifier |
|
675 // --------------------------------------------------------------------------- |
|
676 // |
|
677 void CCmManagerImpl::StartCommsDatNotifierL() |
|
678 { |
|
679 // Two instances of class CCmCommsDatNotifier are created here and |
|
680 // referred by all watchers in CmManager. One is to watch change in Iap Table |
|
681 // and the other is to watch change in Snap Table. |
|
682 iCommsDatIapNotifier = CCmCommsDatNotifier::NewL( KCDTIdIAPRecord ); |
|
683 |
|
684 TUint32 snapTableId = GetSnapTableIdL(); |
|
685 iCommsDatSnapNotifier = CCmCommsDatNotifier::NewL( snapTableId ); |
|
686 } |
|
687 |
|
688 //============================================================================= |
|
689 // CREATION / DELETION API |
|
690 //============================================================================= |
|
691 // |
|
692 |
|
693 //----------------------------------------------------------------------------- |
|
694 // CCmManagerImpl::CreateDestinationL( const TDesC& aName ) |
|
695 //----------------------------------------------------------------------------- |
|
696 // |
|
697 CCmDestinationImpl* CCmManagerImpl::CreateDestinationL( const TDesC& aName ) |
|
698 { |
|
699 LOGGER_ENTERFN( "CCmManagerImpl::CreateDestinationL" ); |
|
700 |
|
701 CheckAvailableSpaceL(); |
|
702 |
|
703 if ( aName.Length() == 0 ) |
|
704 { |
|
705 User::Leave( KErrArgument ); |
|
706 } |
|
707 |
|
708 return iObjectPool->GetDestinationL( aName ); |
|
709 } |
|
710 |
|
711 //----------------------------------------------------------------------------- |
|
712 // CCmManagerImpl::CreateDestinationL( const TDesC& aName, TUint32 |
|
713 // aDestId ) |
|
714 //----------------------------------------------------------------------------- |
|
715 // |
|
716 CCmDestinationImpl* CCmManagerImpl::CreateDestinationL( |
|
717 const TDesC& aName, |
|
718 TUint32 aDestId ) |
|
719 { |
|
720 LOGGER_ENTERFN( "CCmManagerImpl::CreateDestinationL" ); |
|
721 |
|
722 CheckAvailableSpaceL(); |
|
723 |
|
724 if ( aName.Length() == 0 ) |
|
725 { |
|
726 User::Leave( KErrArgument ); |
|
727 } |
|
728 |
|
729 if ( aDestId == 0 ) |
|
730 { |
|
731 return CreateDestinationL( aName ); |
|
732 } |
|
733 |
|
734 return iObjectPool->CreateDestinationL( aName, aDestId ); |
|
735 } |
|
736 |
|
737 |
|
738 //----------------------------------------------------------------------------- |
|
739 // CCmManagerImpl::DestinationUpdated( CCmDestinationImpl* aDestination ) |
|
740 //----------------------------------------------------------------------------- |
|
741 // |
|
742 void CCmManagerImpl::DestinationUpdated( CCmDestinationImpl* aDestination ) |
|
743 { |
|
744 LOGGER_ENTERFN( "CCmManagerImpl::DestinationUpdatedL" ); |
|
745 iObjectPool->DestinationUpdated( aDestination ); |
|
746 } |
|
747 |
|
748 // -------------------------------------------------------------------------- |
|
749 // CCmManagerImpl::CreateConnectionMethodL() |
|
750 // -------------------------------------------------------------------------- |
|
751 // |
|
752 CCmPluginBase* |
|
753 CCmManagerImpl::CreateConnectionMethodL( CCmPluginBaseEng* pluginBaseEng ) |
|
754 { |
|
755 LOGGER_ENTERFN( "CCmManagerImpl::CreateConnectionMethodL 2" ); |
|
756 |
|
757 CheckAvailableSpaceL(); |
|
758 |
|
759 return iObjectPool->CreateConnectionMethodL( pluginBaseEng ); |
|
760 } |
|
761 |
|
762 // -------------------------------------------------------------------------- |
|
763 // CCmManagerImpl::InsertConnectionMethodL() |
|
764 // -------------------------------------------------------------------------- |
|
765 // |
|
766 void CCmManagerImpl::InsertConnectionMethodL( CCmPluginBaseEng* pluginBaseEng ) |
|
767 { |
|
768 iObjectPool->InsertConnectionMethodL( pluginBaseEng ); |
|
769 } |
|
770 |
|
771 // -------------------------------------------------------------------------- |
|
772 // CCmManagerImpl::CreateConnectionMethodL() |
|
773 // -------------------------------------------------------------------------- |
|
774 // |
|
775 CCmPluginBase* |
|
776 CCmManagerImpl::CreateConnectionMethodL( TUint32 aImplementationUid, |
|
777 CCmDestinationImpl* aParentDestination ) |
|
778 { |
|
779 LOGGER_ENTERFN( "CCmManagerImpl::CreateConnectionMethodL" ); |
|
780 |
|
781 CheckAvailableSpaceL(); |
|
782 |
|
783 TCmPluginInitParam params( *this ); |
|
784 if (aParentDestination) |
|
785 { |
|
786 params.iParentDest = aParentDestination->Id(); |
|
787 } |
|
788 |
|
789 return iObjectPool->CreateConnectionMethodL( aImplementationUid, params ); |
|
790 } |
|
791 |
|
792 // -------------------------------------------------------------------------- |
|
793 // CCmManagerImpl::CreateConnectionMethodL() |
|
794 // -------------------------------------------------------------------------- |
|
795 // |
|
796 CCmPluginBase* |
|
797 CCmManagerImpl::CreateConnectionMethodL( TUint32 aImplementationUid, |
|
798 TUint32 aConnMethodId, |
|
799 CCmDestinationImpl* aParentDestination ) |
|
800 { |
|
801 LOGGER_ENTERFN( "CCmManagerImpl::CreateConnectionMethodL" ); |
|
802 |
|
803 CheckAvailableSpaceL(); |
|
804 |
|
805 TCmPluginInitParam params( *this ); |
|
806 if ( aParentDestination ) |
|
807 { |
|
808 params.iParentDest = aParentDestination->Id(); |
|
809 } |
|
810 |
|
811 return iObjectPool->CreateConnectionMethodL( aImplementationUid, |
|
812 params, |
|
813 aConnMethodId); |
|
814 } |
|
815 |
|
816 // -------------------------------------------------------------------------- |
|
817 // CCmManagerImpl::DoCreateConnectionMethodL() |
|
818 // -------------------------------------------------------------------------- |
|
819 // |
|
820 CCmPluginBaseEng* |
|
821 CCmManagerImpl::DoCreateConnectionMethodL( TUint32 aImplementationUid, |
|
822 TCmPluginInitParam& aParams ) |
|
823 { |
|
824 LOGGER_ENTERFN( "CCmManagerImpl::DoCreateConnectionMethodL" ); |
|
825 |
|
826 const TUid KMCMmImplementationUid = { aImplementationUid }; |
|
827 TAny* ptr = REComSession::CreateImplementationL( KMCMmImplementationUid, |
|
828 _FOFF( CCmPluginBaseEng, |
|
829 iDtor_ID_Key ), |
|
830 (TAny*)&aParams ); |
|
831 |
|
832 CCmPluginBaseEng* plugin = STATIC_CAST( CCmPluginBaseEng*, ptr ); |
|
833 CleanupStack::PushL( plugin ); |
|
834 |
|
835 plugin->CreateNewL(); |
|
836 plugin->SetIdValidity(EFalse); |
|
837 CleanupStack::Pop( plugin ); // plugin |
|
838 |
|
839 return plugin; |
|
840 } |
|
841 |
|
842 // -------------------------------------------------------------------------- |
|
843 // CCmManagerImpl::DoCreateConnectionMethodL() |
|
844 // -------------------------------------------------------------------------- |
|
845 // |
|
846 CCmPluginBaseEng* |
|
847 CCmManagerImpl::DoCreateConnectionMethodL( TUint32 aImplementationUid, |
|
848 TCmPluginInitParam& aParams, |
|
849 TUint32 aConnMethodId ) |
|
850 { |
|
851 LOGGER_ENTERFN( "CCmManagerImpl::DoCreateConnectionMethodL" ); |
|
852 |
|
853 const TUid KMCMmImplementationUid = { aImplementationUid }; |
|
854 TAny* ptr = REComSession::CreateImplementationL( KMCMmImplementationUid, |
|
855 _FOFF( CCmPluginBaseEng, |
|
856 iDtor_ID_Key ), |
|
857 (TAny*)&aParams ); |
|
858 |
|
859 CCmPluginBaseEng* plugin = STATIC_CAST( CCmPluginBaseEng*, ptr ); |
|
860 CleanupStack::PushL( plugin ); |
|
861 |
|
862 plugin->CreateNewL(); |
|
863 plugin->SetIdValidity( EFalse ); |
|
864 plugin->SetPreDefinedId( aConnMethodId ); |
|
865 CleanupStack::Pop( plugin ); // plugin |
|
866 |
|
867 return plugin; |
|
868 } |
|
869 |
|
870 //----------------------------------------------------------------------------- |
|
871 // CCmManagerImpl::ConnectionMethodL( TUint aId ) |
|
872 //----------------------------------------------------------------------------- |
|
873 // |
|
874 EXPORT_C CCmPluginBaseEng* |
|
875 CCmManagerImpl::ConnectionMethodL( TUint32 /*aCmId*/ ) |
|
876 { |
|
877 LOGGER_ENTERFN( "Error: Obsolete function CCmManagerImpl::ConnectionMethodL used" ); |
|
878 User::Panic( _L("CMManager"), KErrNotSupported ); |
|
879 return NULL; |
|
880 } |
|
881 |
|
882 //----------------------------------------------------------------------------- |
|
883 // CCmManagerImpl::GetConnectionMethodL( TUint aId ) |
|
884 //----------------------------------------------------------------------------- |
|
885 // |
|
886 EXPORT_C CCmPluginBase* |
|
887 CCmManagerImpl::GetConnectionMethodL( TUint32 aCmId ) |
|
888 { |
|
889 LOGGER_ENTERFN( "CCmManagerImpl::GetConnectionMethodL" ); |
|
890 |
|
891 CCmPluginBase* plugin = DoFindConnMethodL( aCmId, NULL ); |
|
892 |
|
893 return plugin; |
|
894 } |
|
895 |
|
896 |
|
897 //----------------------------------------------------------------------------- |
|
898 // CCmManagerImpl::AppendUncatCmListL |
|
899 //----------------------------------------------------------------------------- |
|
900 // |
|
901 void CCmManagerImpl::AppendUncatCmListL( RPointerArray<CCmPluginBase>& aCMArray, |
|
902 TBool aCheckBearerType, |
|
903 TBool aLegacyOnly, |
|
904 TBool aEasyWlan, |
|
905 TBool aSortByBearer ) |
|
906 { |
|
907 LOGGER_ENTERFN( "CCmManagerImpl::AppendUncatCmListL" ); |
|
908 |
|
909 RArray<TUint32> cmUidArray; |
|
910 CleanupClosePushL(cmUidArray); |
|
911 ConnectionMethodL(cmUidArray, aCheckBearerType, aLegacyOnly, aEasyWlan, aSortByBearer); |
|
912 AppendCmListFromUidsL( cmUidArray, aCMArray ); |
|
913 |
|
914 CleanupStack::PopAndDestroy(&cmUidArray); |
|
915 } |
|
916 |
|
917 //----------------------------------------------------------------------------- |
|
918 // CCmManagerImpl::AppendUncatCmListLC |
|
919 //----------------------------------------------------------------------------- |
|
920 // |
|
921 void CCmManagerImpl::AppendUncatCmListLC( RPointerArray<CCmPluginBase>& aCMArray, |
|
922 TBool aCheckBearerType, |
|
923 TBool aLegacyOnly, |
|
924 TBool aEasyWlan, |
|
925 TBool aSortByBearer ) |
|
926 { |
|
927 LOGGER_ENTERFN( "CCmManagerImpl::AppendUncatCmListLC" ); |
|
928 |
|
929 AppendUncatCmListL( aCMArray, aCheckBearerType, aLegacyOnly, aEasyWlan, aSortByBearer); |
|
930 |
|
931 CleanupResetAndDestroyPushL< RPointerArray<CCmPluginBase> >( aCMArray ); |
|
932 } |
|
933 |
|
934 // ----------------------------------------------------------------------------- |
|
935 // CCmDestinationImpl::AppendCmListLC |
|
936 // ----------------------------------------------------------------------------- |
|
937 // |
|
938 void CCmManagerImpl::AppendCmListLC( TUint32 aDestintaionId, RPointerArray<CCmPluginBase>& aCMArray ) |
|
939 { |
|
940 LOGGER_ENTERFN( "CCmManagerImpl::AppendCmListLC" ); |
|
941 |
|
942 AppendCmListL( aDestintaionId, aCMArray ); |
|
943 CCmManagerImpl::CleanupResetAndDestroyPushL< RPointerArray<CCmPluginBase> >( aCMArray ); |
|
944 } |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CCmDestinationImpl::AppendCmListL |
|
948 // ----------------------------------------------------------------------------- |
|
949 // |
|
950 void CCmManagerImpl::AppendCmListL( TUint32 aDestintaionId, RPointerArray<CCmPluginBase>& aCMArray ) |
|
951 { |
|
952 LOGGER_ENTERFN( "CCmManagerImpl::AppendCmListL" ); |
|
953 |
|
954 CCmDestinationImpl* dest = DestinationL( aDestintaionId ); |
|
955 CleanupStack::PushL(dest); |
|
956 RArray<TUint32> cmIdList; |
|
957 CleanupClosePushL(cmIdList); |
|
958 dest->ConnectMethodIdArrayL( cmIdList ); |
|
959 AppendCmListFromUidsL( cmIdList, aCMArray ); |
|
960 CleanupStack::PopAndDestroy(&cmIdList); |
|
961 CleanupStack::PopAndDestroy(dest); |
|
962 } |
|
963 // ----------------------------------------------------------------------------- |
|
964 // CCmDestinationImpl::AppendCmListFromUidsL |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 void CCmManagerImpl::AppendCmListFromUidsL( RArray<TUint32>& cmIdList, RPointerArray<CCmPluginBase>& aCMArray ) |
|
968 { |
|
969 LOGGER_ENTERFN( "CCmManagerImpl::AppendCmListFromUidsL" ); |
|
970 |
|
971 TInt count = cmIdList.Count(); |
|
972 for ( TInt i = 0; i< count; i++ ) |
|
973 { |
|
974 CCmPluginBase* cm = NULL; |
|
975 TRAPD( err,cm = GetConnectionMethodL( cmIdList[i] )); |
|
976 if (err == KErrNone) |
|
977 { |
|
978 aCMArray.AppendL( cm ); |
|
979 } |
|
980 } |
|
981 } |
|
982 |
|
983 //----------------------------------------------------------------------------- |
|
984 // CCmManagerImpl::ConnectionMethodL |
|
985 //----------------------------------------------------------------------------- |
|
986 // |
|
987 EXPORT_C void CCmManagerImpl::ConnectionMethodL( RArray<TUint32>& aCMArray, |
|
988 TBool aCheckBearerType, |
|
989 TBool aLegacyOnly, |
|
990 TBool aEasyWlan, |
|
991 TBool aSortByBearer ) |
|
992 { |
|
993 LOGGER_ENTERFN( "CCmManagerImpl::ConnectionMethodL" ); |
|
994 |
|
995 OpenTransactionLC(); |
|
996 |
|
997 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = AllIapsL(); |
|
998 CleanupStack::PushL( ptrRecordSet ); |
|
999 |
|
1000 TInt iapRecords = ptrRecordSet->iRecords.Count(); |
|
1001 CLOG_WRITE_1_PTR( NULL, "Record num [%d]", iapRecords ); |
|
1002 |
|
1003 // Time optimization to load the entire destination table |
|
1004 TInt destTblId = DestinationTableId(); |
|
1005 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* ptrDestSet = |
|
1006 new (ELeave) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
1007 destTblId ); |
|
1008 CleanupStack::PushL( ptrDestSet ); |
|
1009 TRAP_IGNORE( ptrDestSet->LoadL( Session() ) ); |
|
1010 |
|
1011 for ( TInt i = 0; i < iapRecords; i++ ) |
|
1012 { |
|
1013 TUint32 iapId = (*ptrRecordSet)[i]->RecordId(); |
|
1014 CLOG_WRITE_1_PTR( NULL, "IAP ID [%d]", iapId ); |
|
1015 if ( aCheckBearerType ) |
|
1016 { |
|
1017 TUint32 bearerType( 0 ); |
|
1018 TRAPD( err, |
|
1019 bearerType = BearerTypeFromIapRecordL( (*ptrRecordSet)[i] )); |
|
1020 if ( !err && bearerType ) |
|
1021 { |
|
1022 // append the IAP id - if aLegacyOnly is ETrue, only for legacy IAPs |
|
1023 if ( !aLegacyOnly || |
|
1024 !NumOfConnMethodReferencesL( iapId, ptrDestSet ) ) |
|
1025 { |
|
1026 if( !aEasyWlan && IsEasyWLanL( (*ptrRecordSet)[i] ) ) |
|
1027 { |
|
1028 continue; |
|
1029 } |
|
1030 |
|
1031 aCMArray.Append( iapId ); |
|
1032 } |
|
1033 } |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 // append the IAP id - if aLegacyOnly is ETrue, only for legacy IAPs |
|
1038 if ( !aLegacyOnly || |
|
1039 !NumOfConnMethodReferencesL( iapId, ptrDestSet ) ) |
|
1040 { |
|
1041 if( !aEasyWlan && IsEasyWLanL( (*ptrRecordSet)[i] ) ) |
|
1042 { |
|
1043 continue; |
|
1044 } |
|
1045 |
|
1046 aCMArray.Append( iapId ); |
|
1047 } |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 // Re-order the array according to the global bearer ordering rules |
|
1052 if ( aSortByBearer ) |
|
1053 { |
|
1054 RArray<TUint32> bearers( KCmArrayMediumGranularity ); |
|
1055 CleanupClosePushL( bearers ); |
|
1056 SupportedBearersL( bearers ); |
|
1057 |
|
1058 TInt prevInsertedPos = -1; |
|
1059 for ( TInt i = 0; i < bearers.Count(); i++ ) |
|
1060 { |
|
1061 for ( TInt j = prevInsertedPos + 1; j < aCMArray.Count(); j++ ) |
|
1062 { |
|
1063 // Check if CM belongs to this bearer |
|
1064 TUint cmBearerId = GetConnectionMethodInfoIntL( aCMArray[j], |
|
1065 ECmBearerType ); |
|
1066 if ( cmBearerId == bearers[i] ) |
|
1067 { |
|
1068 // copy the cm id to the next 'sorted position' in the array |
|
1069 // the item removed will always be after the insertion position |
|
1070 TUint cmId = aCMArray[j]; |
|
1071 aCMArray.Remove(j); |
|
1072 aCMArray.Insert( cmId, ++prevInsertedPos ); |
|
1073 } |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 CleanupStack::PopAndDestroy( &bearers ); |
|
1078 } |
|
1079 |
|
1080 CleanupStack::PopAndDestroy( 2, ptrRecordSet ); |
|
1081 |
|
1082 RollbackTransaction(); |
|
1083 } |
|
1084 |
|
1085 //----------------------------------------------------------------------------- |
|
1086 // CCmManagerImpl::DoFindConnMethodL |
|
1087 //----------------------------------------------------------------------------- |
|
1088 // |
|
1089 CCmPluginBase* CCmManagerImpl::DoFindConnMethodL( TUint32 aCmId, |
|
1090 CCmDestinationImpl* aParentDest ) |
|
1091 { |
|
1092 LOGGER_ENTERFN( "CCmManagerImpl::DoFindConnMethodL" ); |
|
1093 return iObjectPool->GetConnectionMethodL(aCmId, aParentDest); |
|
1094 } |
|
1095 |
|
1096 //----------------------------------------------------------------------------- |
|
1097 // CCmManagerImpl::FindConnMethodL |
|
1098 //----------------------------------------------------------------------------- |
|
1099 // |
|
1100 CCmPluginBaseEng* CCmManagerImpl::DoFindConnMethL( TUint32 aCmId, |
|
1101 CCmDestinationImpl* aParentDest ) |
|
1102 { |
|
1103 LOGGER_ENTERFN( "CCmManagerImpl::FindConnMethodL" ); |
|
1104 |
|
1105 // Step through each bearer to find which the CMId belongs to |
|
1106 CCmPluginBaseEng* plugin = NULL; |
|
1107 |
|
1108 TCmPluginInitParam params( *this ); |
|
1109 if (aParentDest) |
|
1110 { |
|
1111 params.iParentDest = aParentDest->Id(); |
|
1112 } |
|
1113 else |
|
1114 { |
|
1115 params.iParentDest = ParentDestinationL( aCmId ); |
|
1116 } |
|
1117 |
|
1118 TUint32 bearerType = BearerTypeFromCmIdL( aCmId ); |
|
1119 |
|
1120 for ( TInt i=0; i<iPlugins->Count(); i++ ) |
|
1121 { |
|
1122 if( (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ) == bearerType ) |
|
1123 { |
|
1124 plugin = (*iPlugins)[i]->CreateInstanceL( params ); |
|
1125 break; |
|
1126 } |
|
1127 } |
|
1128 |
|
1129 if ( !plugin ) |
|
1130 { |
|
1131 return plugin; |
|
1132 } |
|
1133 |
|
1134 CleanupStack::PushL( plugin ); |
|
1135 |
|
1136 plugin->LoadL( aCmId ); |
|
1137 |
|
1138 CleanupStack::Pop( plugin ); // 1 |
|
1139 plugin->SetIdValidity(ETrue); |
|
1140 |
|
1141 return plugin; |
|
1142 } |
|
1143 |
|
1144 //----------------------------------------------------------------------------- |
|
1145 // CCmManagerImpl::BearerTypeFromIapL( TUint aId ) |
|
1146 //----------------------------------------------------------------------------- |
|
1147 // |
|
1148 TUint32 CCmManagerImpl::BearerTypeFromCmIdL( TUint32 aCmId ) |
|
1149 { |
|
1150 LOGGER_ENTERFN( "CCmManagerImpl::BearerTypeFromIapL" ); |
|
1151 TUint32 bearerType; |
|
1152 if ( aCmId > KMaxIapID ) |
|
1153 { |
|
1154 bearerType = KUidEmbeddedDestination; |
|
1155 } |
|
1156 else |
|
1157 {//aCmId is an IapId |
|
1158 // Load this IAP record from the IAP table |
|
1159 // This is an optimization that plugins doesn't have |
|
1160 // to do it every time the CanHandleIapIdL() is called. |
|
1161 CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *> |
|
1162 (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
1163 CleanupStack::PushL( iapRecord ); // 1 |
|
1164 iapRecord->SetRecordId( aCmId ); |
|
1165 |
|
1166 OpenTransactionLC(); |
|
1167 iapRecord->LoadL( Session() ); |
|
1168 RollbackTransaction(); |
|
1169 |
|
1170 bearerType = BearerTypeFromIapRecordL( iapRecord ); |
|
1171 |
|
1172 CleanupStack::PopAndDestroy( iapRecord ); // 0 |
|
1173 } |
|
1174 return bearerType; |
|
1175 } |
|
1176 |
|
1177 //----------------------------------------------------------------------------- |
|
1178 // CCmManagerImpl::BearerTypeFromIapRecordL( CCDIAPRecord* aIapRecord ) |
|
1179 //----------------------------------------------------------------------------- |
|
1180 // |
|
1181 TUint32 CCmManagerImpl::BearerTypeFromIapRecordL( CCDIAPRecord* aIapRecord ) const |
|
1182 { |
|
1183 LOGGER_ENTERFN( "CCmManagerImpl::BearerTypeFromIapRecordL" ); |
|
1184 |
|
1185 CLOG_WRITE_1( "Plugin count: [%d]", iPlugins->Count() ); |
|
1186 |
|
1187 TInt err( KErrNone ); |
|
1188 TUint32 extLevel( 0 ); |
|
1189 TInt bearerType( 0 ); |
|
1190 TBool canHandle( EFalse ); |
|
1191 |
|
1192 // Check which bearer handles the given IAPid |
|
1193 for ( TInt i=0; i<iPlugins->Count(); i++ ) |
|
1194 { |
|
1195 // a defective, or a wrong AP can't cause any trouble. |
|
1196 TRAP( err, canHandle = (*iPlugins)[i]->CanHandleIapIdL( aIapRecord ) ); |
|
1197 CLOG_WRITE_3( "plugin [%d] returned with error %d, CanH: %d", |
|
1198 i, err, TUint32(canHandle) ); |
|
1199 if ( !err && canHandle ) |
|
1200 { |
|
1201 if ( extLevel < |
|
1202 (*iPlugins)[i]->GetIntAttributeL( ECmExtensionLevel ) ) |
|
1203 { |
|
1204 extLevel = (*iPlugins)[i]->GetIntAttributeL(ECmExtensionLevel); |
|
1205 bearerType = (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ); |
|
1206 } |
|
1207 } |
|
1208 else if ( err == KErrNoMemory ) |
|
1209 { |
|
1210 User::Leave( err ); |
|
1211 } |
|
1212 } |
|
1213 |
|
1214 if ( !bearerType ) |
|
1215 // No supporting plugin found. |
|
1216 { |
|
1217 CLOG_WRITE( "Plugin not found, Leaving." ); |
|
1218 User::Leave( KErrNotSupported ); |
|
1219 } |
|
1220 CLOG_WRITE_1( "Returning bearertype: [%d]", bearerType ); |
|
1221 return bearerType; |
|
1222 } |
|
1223 |
|
1224 //----------------------------------------------------------------------------- |
|
1225 // CCmManagerImpl::AllDestinationsL() |
|
1226 //----------------------------------------------------------------------------- |
|
1227 // |
|
1228 EXPORT_C void CCmManagerImpl::AllDestinationsL( RArray<TUint32>& aDestArray ) |
|
1229 { |
|
1230 LOGGER_ENTERFN( "CCmManagerImpl::AllDestinationsL" ); |
|
1231 |
|
1232 OpenTransactionLC(); |
|
1233 |
|
1234 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* destRecordSet = |
|
1235 new ( ELeave ) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
1236 iDestinationTableId ); |
|
1237 CleanupStack::PushL( destRecordSet ); |
|
1238 |
|
1239 TRAP_IGNORE( destRecordSet->LoadL( Session() ) ); |
|
1240 |
|
1241 iDestinationCount = destRecordSet->iRecords.Count(); |
|
1242 |
|
1243 //========================================================================= |
|
1244 // Step through every item in the NW Table and check whether it is linked |
|
1245 // in the DN_IAP table |
|
1246 // |
|
1247 for ( TInt i = 0; i < iDestinationCount; ++i ) |
|
1248 { |
|
1249 TInt nwId = QUERY_INT_FIELD( destRecordSet->iRecords[i], |
|
1250 KCDTIdDataMobilitySelectionPolicyNetwork ); |
|
1251 TBool found( EFalse ); |
|
1252 |
|
1253 for ( TInt j = 0; j < aDestArray.Count(); ++j ) |
|
1254 { |
|
1255 if ( aDestArray[j] == nwId ) |
|
1256 { |
|
1257 found = ETrue; |
|
1258 break; |
|
1259 } |
|
1260 } |
|
1261 |
|
1262 if ( !found ) |
|
1263 { |
|
1264 aDestArray.AppendL( nwId ); |
|
1265 CLOG_WRITE_2( "Dest(%d): [%d]", aDestArray.Count(), nwId ); |
|
1266 } |
|
1267 } |
|
1268 |
|
1269 CleanupStack::PopAndDestroy( destRecordSet ); |
|
1270 |
|
1271 RollbackTransaction(); |
|
1272 |
|
1273 CLOG_WRITE_1( "No. of dests found: [%d] ", aDestArray.Count() ); |
|
1274 } |
|
1275 |
|
1276 //----------------------------------------------------------------------------- |
|
1277 // CCmManagerImpl::DestinationL() |
|
1278 //----------------------------------------------------------------------------- |
|
1279 // |
|
1280 EXPORT_C CCmDestinationImpl* CCmManagerImpl::DestinationL( TUint32 aId ) |
|
1281 { |
|
1282 LOGGER_ENTERFN( "CCmManagerImpl::DestinationL" ); |
|
1283 |
|
1284 // Create destination object |
|
1285 return iObjectPool->GetDestinationL( aId ); |
|
1286 } |
|
1287 |
|
1288 //----------------------------------------------------------------------------- |
|
1289 // CCmManagerImpl::RemoveDestFromPool |
|
1290 //----------------------------------------------------------------------------- |
|
1291 // |
|
1292 EXPORT_C void CCmManagerImpl::RemoveDestFromPool( CCmDestinationImpl* aDestination ) |
|
1293 { |
|
1294 LOGGER_ENTERFN( "CCmManagerImpl::RemoveDestFromPool" ); |
|
1295 iObjectPool->RemoveDestination(aDestination); |
|
1296 } |
|
1297 |
|
1298 //----------------------------------------------------------------------------- |
|
1299 // CCmManagerImpl::RemoveDestFromPool |
|
1300 //----------------------------------------------------------------------------- |
|
1301 // |
|
1302 void CCmManagerImpl::RemoveDestFromPool( CCmDestinationData* aDestination ) |
|
1303 { |
|
1304 LOGGER_ENTERFN( "CCmManagerImpl::RemoveDestFromPool" ); |
|
1305 iObjectPool->RemoveDestination(aDestination); |
|
1306 } |
|
1307 |
|
1308 //----------------------------------------------------------------------------- |
|
1309 // CCmManagerImpl::RemoveCMFromPool |
|
1310 //----------------------------------------------------------------------------- |
|
1311 // |
|
1312 void CCmManagerImpl::RemoveCMFromPoolL( CCmPluginBaseEng* aCM ) |
|
1313 { |
|
1314 LOGGER_ENTERFN( "CCmManagerImpl::RemoveCMFromPool" ); |
|
1315 iObjectPool->RemoveConnectionMethodL( aCM ); |
|
1316 } |
|
1317 |
|
1318 //----------------------------------------------------------------------------- |
|
1319 // CCmManagerImpl::RemoveCMFromPool |
|
1320 //----------------------------------------------------------------------------- |
|
1321 // |
|
1322 void CCmManagerImpl::RemoveCMFromPoolL( CCmPluginBase* aCM ) |
|
1323 { |
|
1324 LOGGER_ENTERFN( "CCmManagerImpl::RemoveCMFromPool" ); |
|
1325 iObjectPool->RemoveConnectionMethodL( aCM ); |
|
1326 } |
|
1327 |
|
1328 //----------------------------------------------------------------------------- |
|
1329 // CCmManagerImpl::CopyConnectionMethodL() |
|
1330 //----------------------------------------------------------------------------- |
|
1331 // |
|
1332 TInt CCmManagerImpl::CopyConnectionMethodL( |
|
1333 CCmDestinationImpl& aTargetDestination, |
|
1334 CCmPluginBase& aConnectionMethod ) |
|
1335 { |
|
1336 LOGGER_ENTERFN( "CCmManagerImpl::CopyConnectionMethodL" ); |
|
1337 |
|
1338 OpenTransactionLC(); |
|
1339 TInt index = aTargetDestination.AddConnectionMethodL( aConnectionMethod ); |
|
1340 aTargetDestination.UpdateL(); |
|
1341 CommitTransactionL( 0 ); |
|
1342 |
|
1343 return index; |
|
1344 } |
|
1345 |
|
1346 //----------------------------------------------------------------------------- |
|
1347 // CCmManagerImpl::MoveConnectionMethodL() |
|
1348 //----------------------------------------------------------------------------- |
|
1349 // |
|
1350 TInt CCmManagerImpl::MoveConnectionMethodL( |
|
1351 CCmDestinationImpl& aSourceDestination, |
|
1352 CCmDestinationImpl& aTargetDestination, |
|
1353 CCmPluginBase& aConnectionMethod ) |
|
1354 { |
|
1355 LOGGER_ENTERFN( "CCmManagerImpl::MoveConnectionMethodL" ); |
|
1356 |
|
1357 OpenTransactionLC(); |
|
1358 |
|
1359 TInt index = CopyConnectionMethodL( aTargetDestination, aConnectionMethod ); |
|
1360 aSourceDestination.RemoveConnectionMethodL( aConnectionMethod ); |
|
1361 aSourceDestination.UpdateL(); |
|
1362 |
|
1363 CommitTransactionL( KErrNone ); |
|
1364 |
|
1365 return index; |
|
1366 } |
|
1367 |
|
1368 //----------------------------------------------------------------------------- |
|
1369 // CCmManagerImpl::RemoveConnectionMethodL() |
|
1370 //----------------------------------------------------------------------------- |
|
1371 // |
|
1372 void CCmManagerImpl::RemoveConnectionMethodL( |
|
1373 CCmDestinationImpl& aDestination, |
|
1374 CCmPluginBase& aConnectionMethod ) |
|
1375 { |
|
1376 LOGGER_ENTERFN( "CCmManagerImpl::RemoveConnectionMethodL" ); |
|
1377 |
|
1378 OpenTransactionLC(); |
|
1379 aDestination.RemoveConnectionMethodL( aConnectionMethod ); |
|
1380 aDestination.UpdateL(); |
|
1381 CommitTransactionL( 0 ); |
|
1382 } |
|
1383 |
|
1384 //----------------------------------------------------------------------------- |
|
1385 // RCmManagerExt::SupportedBearers() |
|
1386 //----------------------------------------------------------------------------- |
|
1387 // |
|
1388 void CCmManagerImpl::SupportedBearersL( RArray<TUint32>& aArray ) const |
|
1389 { |
|
1390 LOGGER_ENTERFN( "CCmManagerImpl::SupportedBearersL" ); |
|
1391 |
|
1392 for ( TInt i = 0; i < iPlugins->Count(); i++ ) |
|
1393 { |
|
1394 TUint32 bearerType( (*iPlugins)[i]->GetIntAttributeL(ECmBearerType) ); |
|
1395 |
|
1396 if ( KUidEmbeddedDestination != bearerType ) |
|
1397 { |
|
1398 aArray.AppendL( (*iPlugins)[i]->GetIntAttributeL(ECmBearerType) ); |
|
1399 } |
|
1400 } |
|
1401 } |
|
1402 |
|
1403 // ----------------------------------------------------------------------------- |
|
1404 // CCmManagerImpl::NumOfConnMethodReferencesL() |
|
1405 // ----------------------------------------------------------------------------- |
|
1406 // |
|
1407 TUint32 CCmManagerImpl::NumOfConnMethodReferencesL( |
|
1408 TUint32 aId, |
|
1409 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* aRecSet ) |
|
1410 { |
|
1411 LOGGER_ENTERFN( "CCmManagerImpl::NumOfConnMethodReferencesL" ); |
|
1412 |
|
1413 OpenTransactionLC(); |
|
1414 |
|
1415 TUint32 retVal( 0 ); |
|
1416 |
|
1417 if ( aRecSet ) |
|
1418 { |
|
1419 TMDBElementId id( IAP_ELEMENT_ID(aId) ); |
|
1420 |
|
1421 for ( TInt i = 0; i < aRecSet->iRecords.Count(); ++i ) |
|
1422 { |
|
1423 if ( QUERY_UINT32_FIELD( (*aRecSet)[i], |
|
1424 KCDTIdDataMobilitySelectionPolicyIAP ) == |
|
1425 id ) |
|
1426 { |
|
1427 ++retVal; |
|
1428 } |
|
1429 } |
|
1430 } |
|
1431 else |
|
1432 { |
|
1433 // Just to test how many record we have |
|
1434 TInt destTblId = DestinationTableId(); |
|
1435 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* ptrRecordSet = |
|
1436 new (ELeave) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
1437 destTblId ); |
|
1438 CleanupStack::PushL( ptrRecordSet ); |
|
1439 |
|
1440 // Prime record |
|
1441 CCDDataMobilitySelectionPolicyRecord* record = |
|
1442 new (ELeave) CCDDataMobilitySelectionPolicyRecord( |
|
1443 DestinationTableId() ); |
|
1444 CleanupStack::PushL( record ); |
|
1445 |
|
1446 record->iIAP = IAP_ELEMENT_ID( aId ); |
|
1447 ptrRecordSet->iRecords.AppendL( record ); |
|
1448 |
|
1449 CleanupStack::Pop( record ); |
|
1450 record = NULL; |
|
1451 |
|
1452 if ( ptrRecordSet->FindL(Session()) ) |
|
1453 { |
|
1454 // we have a match |
|
1455 retVal = ptrRecordSet->iRecords.Count(); |
|
1456 CLOG_WRITE_1( "Found: [%d]", retVal ); |
|
1457 } |
|
1458 else |
|
1459 { |
|
1460 CLOG_WRITE( "Nothing" ); |
|
1461 } |
|
1462 |
|
1463 CleanupStack::PopAndDestroy( ); // ptrRecordSet |
|
1464 } |
|
1465 |
|
1466 RollbackTransaction(); |
|
1467 |
|
1468 return retVal; |
|
1469 } |
|
1470 |
|
1471 // ----------------------------------------------------------------------------- |
|
1472 // CCmManagerImpl::HasUnprotectedDestinationsL |
|
1473 // ----------------------------------------------------------------------------- |
|
1474 // |
|
1475 TBool CCmManagerImpl::HasUnprotectedDestinationsL() |
|
1476 { |
|
1477 LOGGER_ENTERFN( "CCmManagerImpl::HasUnprotectedDestinationsL" ); |
|
1478 |
|
1479 TBool hasUnprotectedDests( EFalse ); |
|
1480 |
|
1481 RArray<TUint32> destIdArray( KCmArrayBigGranularity ); |
|
1482 AllDestinationsL( destIdArray ); |
|
1483 CleanupClosePushL( destIdArray ); |
|
1484 |
|
1485 CCmDestinationImpl* dest = NULL; |
|
1486 for ( TInt i = 0; i < destIdArray.Count(); i++ ) |
|
1487 { |
|
1488 dest = DestinationL( destIdArray[i] ); |
|
1489 CleanupStack::PushL( dest ); |
|
1490 if ( dest->ProtectionLevel() != EProtLevel1 ) |
|
1491 { |
|
1492 hasUnprotectedDests = ETrue; |
|
1493 CleanupStack::PopAndDestroy( dest ); |
|
1494 break; |
|
1495 } |
|
1496 CleanupStack::PopAndDestroy( dest ); |
|
1497 } |
|
1498 |
|
1499 CleanupStack::PopAndDestroy( &destIdArray ); |
|
1500 |
|
1501 return hasUnprotectedDests; |
|
1502 } |
|
1503 |
|
1504 |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // CCmManagerImpl::BuildPluginArrayL() |
|
1507 // ----------------------------------------------------------------------------- |
|
1508 // |
|
1509 void CCmManagerImpl::BuildPluginArrayL() |
|
1510 { |
|
1511 LOGGER_ENTERFN( "CCmManagerImpl::BuildPluginArrayL" ); |
|
1512 iPlugins = new (ELeave) CArrayPtrFlat<const CCmPluginBaseEng>( |
|
1513 KPluginGranularity ); |
|
1514 |
|
1515 // Get a list of all the bearer types |
|
1516 RImplInfoPtrArray implArray; |
|
1517 REComSession::ListImplementationsL( TUid::Uid( KCMPluginInterfaceUid ), |
|
1518 implArray ); |
|
1519 |
|
1520 CleanupClosePushL( implArray ); // 1 |
|
1521 |
|
1522 CCmPluginBaseEng* plugin = NULL; |
|
1523 for ( TInt i=0; i<implArray.Count(); i++ ) |
|
1524 { |
|
1525 TCmPluginInitParam params( *this ); |
|
1526 params.iParentDest = NULL; |
|
1527 |
|
1528 // This is the Util implementation |
|
1529 // Trap it to be able to work even if there's a faulty plugin installed |
|
1530 // in the phone. |
|
1531 TRAPD( err, plugin = STATIC_CAST( CCmPluginBaseEng*, |
|
1532 REComSession::CreateImplementationL( |
|
1533 (implArray)[i]->ImplementationUid(), |
|
1534 _FOFF( CCmPluginBaseEng, |
|
1535 iDtor_ID_Key ), |
|
1536 (TAny*)¶ms )) ); |
|
1537 |
|
1538 if ( !err ) |
|
1539 { |
|
1540 CLOG_ATTACH( plugin, this ); |
|
1541 |
|
1542 CleanupStack::PushL( plugin ); |
|
1543 |
|
1544 TBool inserted( EFalse ); |
|
1545 TInt defaultPriority( KDataMobilitySelectionPolicyPriorityWildCard ); |
|
1546 |
|
1547 // No UI priority -> wildcard |
|
1548 TRAP_IGNORE( defaultPriority = plugin->GetIntAttributeL( ECmDefaultUiPriority ) ); |
|
1549 |
|
1550 for( TInt j( 0 ); j < iPlugins->Count(); ++j ) |
|
1551 { |
|
1552 if( defaultPriority > (*iPlugins)[j]->GetIntAttributeL( ECmDefaultUiPriority ) ) |
|
1553 { |
|
1554 continue; |
|
1555 } |
|
1556 else if( defaultPriority == (*iPlugins)[j]->GetIntAttributeL( ECmDefaultUiPriority ) ) |
|
1557 { |
|
1558 if( plugin->GetIntAttributeL( ECmExtensionLevel ) > |
|
1559 (*iPlugins)[j]->GetIntAttributeL( ECmExtensionLevel ) ) |
|
1560 { |
|
1561 iPlugins->InsertL( j, plugin ); |
|
1562 inserted = ETrue; |
|
1563 break; |
|
1564 } |
|
1565 } |
|
1566 else |
|
1567 { |
|
1568 iPlugins->InsertL( j, plugin ); |
|
1569 inserted = ETrue; |
|
1570 break; |
|
1571 } |
|
1572 } |
|
1573 |
|
1574 if( !inserted ) |
|
1575 { |
|
1576 iPlugins->AppendL( plugin ); |
|
1577 } |
|
1578 |
|
1579 CleanupStack::Pop( plugin ); |
|
1580 } |
|
1581 } |
|
1582 |
|
1583 implArray.ResetAndDestroy(); |
|
1584 |
|
1585 CleanupStack::PopAndDestroy(); // implArray; |
|
1586 } |
|
1587 |
|
1588 // ----------------------------------------------------------------------------- |
|
1589 // CCmManagerImpl::GetBearerInfoIntL() |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // |
|
1592 EXPORT_C TUint32 CCmManagerImpl::GetBearerInfoIntL( TUint32 aBearerType, |
|
1593 TUint32 aAttribute ) const |
|
1594 { |
|
1595 LOGGER_ENTERFN( "CCmManagerImpl::GetBearerInfoIntL" ); |
|
1596 for ( TInt i = 0; i < iPlugins->Count(); ++i ) |
|
1597 { |
|
1598 if ( aBearerType == (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ) ) |
|
1599 { |
|
1600 return (*iPlugins)[i]->GetIntAttributeL( aAttribute ); |
|
1601 } |
|
1602 } |
|
1603 |
|
1604 User::Leave( KErrNotSupported ); |
|
1605 |
|
1606 return 0; |
|
1607 } |
|
1608 |
|
1609 // ----------------------------------------------------------------------------- |
|
1610 // CCmManagerImpl::GetBearerInfoBoolL() |
|
1611 // ----------------------------------------------------------------------------- |
|
1612 // |
|
1613 EXPORT_C TBool CCmManagerImpl::GetBearerInfoBoolL( TUint32 aBearerType, |
|
1614 TUint32 aAttribute ) const |
|
1615 { |
|
1616 LOGGER_ENTERFN( "CCmManagerImpl::GetBearerInfoBoolL" ); |
|
1617 for ( TInt i = 0; i < iPlugins->Count(); ++i ) |
|
1618 { |
|
1619 if ( aBearerType == (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ) ) |
|
1620 { |
|
1621 return (*iPlugins)[i]->GetBoolAttributeL( aAttribute ); |
|
1622 } |
|
1623 } |
|
1624 |
|
1625 User::Leave( KErrNotSupported ); |
|
1626 |
|
1627 return EFalse; |
|
1628 } |
|
1629 |
|
1630 // ----------------------------------------------------------------------------- |
|
1631 // CCmManagerImpl::GetBearerInfoStringL() |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // |
|
1634 EXPORT_C HBufC* CCmManagerImpl::GetBearerInfoStringL( TUint32 aBearerType, |
|
1635 TUint32 aAttribute ) const |
|
1636 { |
|
1637 LOGGER_ENTERFN( "CCmManagerImpl::GetBearerInfoStringL" ); |
|
1638 for ( TInt i = 0; i < iPlugins->Count(); ++i ) |
|
1639 { |
|
1640 if ( aBearerType == (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ) ) |
|
1641 { |
|
1642 return (*iPlugins)[i]->GetStringAttributeL( aAttribute ); |
|
1643 } |
|
1644 } |
|
1645 |
|
1646 User::Leave( KErrNotSupported ); |
|
1647 |
|
1648 return NULL; |
|
1649 } |
|
1650 |
|
1651 // ----------------------------------------------------------------------------- |
|
1652 // CCmManagerImpl::GetBearerInfoString8L() |
|
1653 // ----------------------------------------------------------------------------- |
|
1654 // |
|
1655 EXPORT_C HBufC8* CCmManagerImpl::GetBearerInfoString8L( TUint32 aBearerType, |
|
1656 TUint32 aAttribute ) const |
|
1657 { |
|
1658 LOGGER_ENTERFN( "CCmManagerImpl::GetBearerInfoStringL" ); |
|
1659 for ( TInt i = 0; i < iPlugins->Count(); ++i ) |
|
1660 { |
|
1661 if ( aBearerType == (*iPlugins)[i]->GetIntAttributeL( ECmBearerType ) ) |
|
1662 { |
|
1663 return (*iPlugins)[i]->GetString8AttributeL( aAttribute ); |
|
1664 } |
|
1665 } |
|
1666 |
|
1667 User::Leave( KErrNotSupported ); |
|
1668 |
|
1669 return NULL; |
|
1670 } |
|
1671 |
|
1672 // ----------------------------------------------------------------------------- |
|
1673 // CCmManagerImpl::GetConnectionMethodInfoIntL() |
|
1674 // ----------------------------------------------------------------------------- |
|
1675 // |
|
1676 EXPORT_C TUint32 CCmManagerImpl::GetConnectionMethodInfoIntL( TUint32 aCmId, |
|
1677 TUint32 aAttribute ) const |
|
1678 { |
|
1679 LOGGER_ENTERFN( "CCmManagerImpl::GetConnectionMethodInfoIntL" ); |
|
1680 |
|
1681 if ( aAttribute == ECmBearerType ) |
|
1682 { |
|
1683 return const_cast<CCmManagerImpl*>(this)->BearerTypeFromCmIdL( aCmId ); |
|
1684 } |
|
1685 else |
|
1686 { |
|
1687 return iPluginImpl->GetConnectionInfoIntL( aCmId, aAttribute ); |
|
1688 } |
|
1689 } |
|
1690 |
|
1691 // ----------------------------------------------------------------------------- |
|
1692 // CCmManagerImpl::GetConnectionMethodInfoBoolL() |
|
1693 // ----------------------------------------------------------------------------- |
|
1694 // |
|
1695 EXPORT_C TBool CCmManagerImpl::GetConnectionMethodInfoBoolL( TUint32 aCmId, |
|
1696 TUint32 aAttribute ) const |
|
1697 { |
|
1698 LOGGER_ENTERFN( "CCmManagerImpl::GetConnectionMethodInfoBoolL" ); |
|
1699 |
|
1700 TBool retval = EFalse; |
|
1701 if ( aAttribute == ECmVirtual ) |
|
1702 { |
|
1703 TUint32 b = GetConnectionMethodInfoIntL( aCmId, ECmBearerType ); |
|
1704 retval = GetBearerInfoBoolL( b, ECmVirtual ); |
|
1705 } |
|
1706 else |
|
1707 { |
|
1708 retval = iPluginImpl->GetConnectionInfoBoolL( aCmId, aAttribute ); |
|
1709 } |
|
1710 return retval; |
|
1711 } |
|
1712 |
|
1713 // ----------------------------------------------------------------------------- |
|
1714 // CCmManagerImpl::GetConnectionMethodInfoStringL() |
|
1715 // ----------------------------------------------------------------------------- |
|
1716 // |
|
1717 EXPORT_C HBufC* CCmManagerImpl::GetConnectionMethodInfoStringL( |
|
1718 TUint32 aCmId, |
|
1719 TUint32 aAttribute ) const |
|
1720 { |
|
1721 LOGGER_ENTERFN( "CCmManagerImpl::GetConnectionMethodInfoStringL" ); |
|
1722 |
|
1723 return iPluginImpl->GetConnectionInfoStringL( aCmId, aAttribute ); |
|
1724 } |
|
1725 |
|
1726 // ----------------------------------------------------------------------------- |
|
1727 // CCmManagerImpl::GetConnectionMethodInfoStringL() |
|
1728 // ----------------------------------------------------------------------------- |
|
1729 // |
|
1730 EXPORT_C HBufC8* CCmManagerImpl::GetConnectionMethodInfoString8L( |
|
1731 TUint32 aCmId, |
|
1732 TUint32 aAttribute ) const |
|
1733 { |
|
1734 LOGGER_ENTERFN( "CCmManagerImpl::GetConnectionMethodInfoString8L" ); |
|
1735 |
|
1736 return iPluginImpl->GetConnectionInfoString8L( aCmId, aAttribute ); |
|
1737 } |
|
1738 |
|
1739 //----------------------------------------------------------------------------- |
|
1740 // CCmManagerImpl::UncategorizedIconL() |
|
1741 //----------------------------------------------------------------------------- |
|
1742 // |
|
1743 CGulIcon* CCmManagerImpl::UncategorizedIconL() const |
|
1744 { |
|
1745 LOGGER_ENTERFN( "CCmManagerImpl::UncategorizedIconL" ); |
|
1746 |
|
1747 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1748 |
|
1749 TParse mbmFile; |
|
1750 User::LeaveIfError( mbmFile.Set( KManagerIconFilename, |
|
1751 &KDC_BITMAP_DIR, |
|
1752 NULL ) ); |
|
1753 |
|
1754 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
1755 skinInstance, |
|
1756 KAknsIIDQgnPropSetConnDestUncategorized, |
|
1757 mbmFile.FullName(), |
|
1758 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized, |
|
1759 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized_mask ); |
|
1760 |
|
1761 return icon; |
|
1762 } |
|
1763 |
|
1764 //----------------------------------------------------------------------------- |
|
1765 // CCmManagerImpl::UncategorizedIconL() |
|
1766 //----------------------------------------------------------------------------- |
|
1767 // |
|
1768 CMDBSession& CCmManagerImpl::Session() const |
|
1769 { |
|
1770 return iTrans->Session(); |
|
1771 } |
|
1772 |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 // CCmManagerImpl::HasCapabilityL() |
|
1775 // ----------------------------------------------------------------------------- |
|
1776 // |
|
1777 void CCmManagerImpl::HasCapabilityL( TCapability aCapability ) |
|
1778 { |
|
1779 TSecurityInfo info; |
|
1780 |
|
1781 info.SetToCurrentInfo(); |
|
1782 |
|
1783 if( !info.iCaps.HasCapability( aCapability ) ) |
|
1784 { |
|
1785 User::Leave( KErrPermissionDenied ); |
|
1786 } |
|
1787 } |
|
1788 |
|
1789 // --------------------------------------------------------------------------- |
|
1790 // CCmManagerImpl::FeatureSupported |
|
1791 // --------------------------------------------------------------------------- |
|
1792 TBool CCmManagerImpl::FeatureSupported( TInt aFeature ) |
|
1793 { |
|
1794 return FeatureManager::FeatureSupported( aFeature ); |
|
1795 } |
|
1796 |
|
1797 // --------------------------------------------------------------------------- |
|
1798 // CCmManagerImpl::IsEasyWLan |
|
1799 // |
|
1800 // We can't have any dependecy to WLan plugin, but |
|
1801 // in some cases we need to filter out EasyWLan access points. |
|
1802 // --------------------------------------------------------------------------- |
|
1803 TBool CCmManagerImpl::IsEasyWLanL( CCDIAPRecord* aIapRecord ) const |
|
1804 { |
|
1805 LOGGER_ENTERFN( "CCmManagerImpl::IsEasyWLanL" ); |
|
1806 if (!iWLan) |
|
1807 { |
|
1808 return EFalse; |
|
1809 } |
|
1810 if( (TPtrC(aIapRecord->iServiceType) != TPtrC(KCDTypeNameLANService) ) || |
|
1811 TPtrC(aIapRecord->iBearerType) != TPtrC(KCDTypeNameLANBearer) ) |
|
1812 { |
|
1813 return EFalse; |
|
1814 } |
|
1815 |
|
1816 TBool retVal( EFalse ); |
|
1817 TUint32 serviceId = aIapRecord->iService; |
|
1818 |
|
1819 CCDWlanServiceRecord* wLanServ = |
|
1820 new (ELeave) CCDWlanServiceRecord( CCDWlanServiceRecord::TableIdL( Session() ) ); |
|
1821 |
|
1822 CleanupStack::PushL( wLanServ ); |
|
1823 |
|
1824 wLanServ->iWlanServiceId.SetL( serviceId ); |
|
1825 |
|
1826 if( wLanServ->FindL( Session() ) ) |
|
1827 { |
|
1828 wLanServ->LoadL( Session() ); |
|
1829 |
|
1830 if( wLanServ->iWLanSSID.IsNull() || |
|
1831 !TPtrC(wLanServ->iWLanSSID).Compare( KNullDesC ) ) |
|
1832 { |
|
1833 retVal = ETrue; |
|
1834 } |
|
1835 } |
|
1836 |
|
1837 CleanupStack::PopAndDestroy( wLanServ ); |
|
1838 |
|
1839 return retVal; |
|
1840 } |
|
1841 |
|
1842 // ----------------------------------------------------------------------------- |
|
1843 // CCmManagerImpl::EasyWlanIdL() |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // |
|
1846 EXPORT_C TUint32 CCmManagerImpl::EasyWlanIdL() |
|
1847 { |
|
1848 LOGGER_ENTERFN( "CCmManagerImpl::EasyWlanId" ); |
|
1849 |
|
1850 OpenTransactionLC(); |
|
1851 |
|
1852 TUint32 easyId( 0 ); |
|
1853 |
|
1854 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = AllIapsL(); |
|
1855 CleanupStack::PushL( ptrRecordSet ); |
|
1856 TInt iapRecords = ptrRecordSet->iRecords.Count(); |
|
1857 CLOG_WRITE_1_PTR( NULL, "Record num [%d]", iapRecords ); |
|
1858 |
|
1859 for ( TInt i = 0; i < iapRecords; i++ ) |
|
1860 { |
|
1861 CCDIAPRecord* iapRecord = (*ptrRecordSet)[i]; |
|
1862 |
|
1863 if( (TPtrC(iapRecord->iServiceType) == TPtrC(KCDTypeNameLANService) ) && |
|
1864 TPtrC(iapRecord->iBearerType) == TPtrC(KCDTypeNameLANBearer) ) |
|
1865 { |
|
1866 if( IsEasyWLanL( iapRecord ) ) |
|
1867 { |
|
1868 easyId = (*ptrRecordSet)[i]->RecordId(); |
|
1869 break; |
|
1870 } |
|
1871 } |
|
1872 } |
|
1873 |
|
1874 CleanupStack::PopAndDestroy( ptrRecordSet ); |
|
1875 |
|
1876 RollbackTransaction(); |
|
1877 |
|
1878 return easyId; |
|
1879 } |
|
1880 |
|
1881 // ----------------------------------------------------------------------------- |
|
1882 // CCmManagerImpl::AllIapsL() |
|
1883 // ----------------------------------------------------------------------------- |
|
1884 // |
|
1885 CMDBRecordSet<CCDIAPRecord>* CCmManagerImpl::AllIapsL() |
|
1886 { |
|
1887 LOGGER_ENTERFN( "CCmManagerImpl::AllIapsL" ); |
|
1888 |
|
1889 OpenTransactionLC(); |
|
1890 |
|
1891 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = |
|
1892 new (ELeave) CMDBRecordSet<CCDIAPRecord>( KCDTIdIAPRecord ); |
|
1893 |
|
1894 TRAP_IGNORE( ptrRecordSet->LoadL( Session() ) ); |
|
1895 |
|
1896 RollbackTransaction(); |
|
1897 |
|
1898 return ptrRecordSet; |
|
1899 } |
|
1900 |
|
1901 // ----------------------------------------------------------------------------- |
|
1902 // CCmManagerImpl::AllSNAPRecordsL() |
|
1903 // ----------------------------------------------------------------------------- |
|
1904 // |
|
1905 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* |
|
1906 CCmManagerImpl::AllSNAPRecordsL( TUint32 aSnapElementId ) |
|
1907 { |
|
1908 LOGGER_ENTERFN( "CCmManagerImpl::AllSNAPRecordsL" ); |
|
1909 |
|
1910 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* ptrRecordSet = |
|
1911 new (ELeave) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
1912 DestinationTableId() ); |
|
1913 CleanupStack::PushL( ptrRecordSet ); |
|
1914 |
|
1915 OpenTransactionLC(); |
|
1916 if( aSnapElementId ) |
|
1917 { |
|
1918 // Prime record |
|
1919 CCDSnapRecord* record = SNAPRecordL( 0 ); |
|
1920 CleanupStack::PushL( record ); |
|
1921 record->iEmbeddedSNAP = aSnapElementId; |
|
1922 ptrRecordSet->iRecords.AppendL( record ); |
|
1923 |
|
1924 CleanupStack::Pop( record ); |
|
1925 record = NULL; |
|
1926 |
|
1927 ptrRecordSet->FindL( Session() ); |
|
1928 } |
|
1929 else |
|
1930 { |
|
1931 ptrRecordSet->LoadL( Session() ); |
|
1932 } |
|
1933 |
|
1934 RollbackTransaction(); |
|
1935 |
|
1936 return ptrRecordSet; |
|
1937 } |
|
1938 |
|
1939 // ----------------------------------------------------------------------------- |
|
1940 // CCmManagerImpl::IsIapLinkedL() |
|
1941 // ----------------------------------------------------------------------------- |
|
1942 // |
|
1943 TBool CCmManagerImpl::IsIapLinkedL( const CCmPluginBaseEng& aPlugin ) |
|
1944 { |
|
1945 LOGGER_ENTERFN( "CCmManagerImpl::IsIapLinkedL" ); |
|
1946 |
|
1947 TUint32 iapId = aPlugin.GetIntAttributeL( ECmId ); |
|
1948 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = AllIapsL(); |
|
1949 CleanupStack::PushL( ptrRecordSet ); |
|
1950 |
|
1951 TInt iapRecords = ptrRecordSet->iRecords.Count(); |
|
1952 CLOG_WRITE_1_PTR( NULL, "Record num [%d]", iapRecords ); |
|
1953 |
|
1954 TBool linked( EFalse ); |
|
1955 for ( TInt i = 0; !linked && i < iapRecords; i++ ) |
|
1956 { |
|
1957 CCDIAPRecord* iapRecord = (*ptrRecordSet)[i]; |
|
1958 |
|
1959 if( iapRecord->RecordId() == iapId ) |
|
1960 { |
|
1961 continue; |
|
1962 } |
|
1963 |
|
1964 TUint32 bearerType( 0 ); |
|
1965 |
|
1966 TRAP_IGNORE( bearerType = BearerTypeFromIapRecordL( iapRecord ) ); |
|
1967 if( bearerType ) |
|
1968 { |
|
1969 if( GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1970 { |
|
1971 CCmPluginBase* plugin = NULL; |
|
1972 |
|
1973 TRAP_IGNORE( plugin = GetConnectionMethodL( iapRecord->RecordId() ) ); |
|
1974 if( plugin ) |
|
1975 { |
|
1976 linked = plugin->IsLinkedToIap( iapId ); |
|
1977 } |
|
1978 |
|
1979 delete plugin; |
|
1980 } |
|
1981 } |
|
1982 } |
|
1983 CleanupStack::PopAndDestroy( ptrRecordSet ); |
|
1984 |
|
1985 return linked; |
|
1986 } |
|
1987 |
|
1988 // ----------------------------------------------------------------------------- |
|
1989 // CCmManagerImpl::RemoveAllReferencesL() |
|
1990 // ----------------------------------------------------------------------------- |
|
1991 // |
|
1992 void CCmManagerImpl::RemoveAllReferencesL( const CCmPluginBaseEng& aPlugin ) |
|
1993 { |
|
1994 RArray<TUint32> dests; |
|
1995 CleanupClosePushL( dests ); |
|
1996 OpenTransactionLC(); |
|
1997 |
|
1998 AllDestinationsL( dests ); |
|
1999 |
|
2000 for( TInt i = 0; i < dests.Count(); ++i ) |
|
2001 { |
|
2002 CCmDestinationImpl* dest = DestinationL( dests[i] ); |
|
2003 CleanupStack::PushL( dest ); |
|
2004 TRAPD( err, dest->RemoveConnectionMethodL( aPlugin ) ); |
|
2005 |
|
2006 if( err != KErrNotFound ) |
|
2007 { |
|
2008 User::LeaveIfError( err ); |
|
2009 |
|
2010 dest->UpdateL(); |
|
2011 } |
|
2012 |
|
2013 CleanupStack::PopAndDestroy( dest ); |
|
2014 } |
|
2015 |
|
2016 CommitTransactionL( 0 ); |
|
2017 CleanupStack::PopAndDestroy( &dests ); |
|
2018 } |
|
2019 |
|
2020 // ----------------------------------------------------------------------------- |
|
2021 // CCmManagerImpl::RemoveAllReferencesLWoTransL() |
|
2022 // ----------------------------------------------------------------------------- |
|
2023 // |
|
2024 void CCmManagerImpl::RemoveAllReferencesWoTransL( const CCmPluginBaseEng& aPlugin ) |
|
2025 { |
|
2026 LOGGER_ENTERFN( "CCmManagerImpl::RemoveAllReferencesWoTransL" ); |
|
2027 |
|
2028 RArray<TUint32> dests; |
|
2029 CleanupClosePushL( dests ); |
|
2030 |
|
2031 AllDestinationsL( dests ); |
|
2032 |
|
2033 for( TInt i = 0; i < dests.Count(); ++i ) |
|
2034 { |
|
2035 CCmDestinationImpl* dest = DestinationL( dests[i] ); |
|
2036 CleanupStack::PushL( dest ); |
|
2037 TRAPD( err, dest->RemoveConnectionMethodL( aPlugin ) ); |
|
2038 |
|
2039 if( err != KErrNotFound ) |
|
2040 { |
|
2041 User::LeaveIfError( err ); |
|
2042 |
|
2043 dest->UpdateL(); |
|
2044 } |
|
2045 |
|
2046 CleanupStack::PopAndDestroy( dest ); |
|
2047 } |
|
2048 CleanupStack::PopAndDestroy( &dests ); |
|
2049 } |
|
2050 |
|
2051 // ----------------------------------------------------------------------------- |
|
2052 // CCmManagerImpl::HandleDefConnDeletedL() |
|
2053 // ----------------------------------------------------------------------------- |
|
2054 // |
|
2055 void CCmManagerImpl::HandleDefConnDeletedL( TCmDefConnValue& aDCSetting ) |
|
2056 { |
|
2057 LOGGER_ENTERFN( "CCmManagerImpl::HandleDefConnDeletedL" ); |
|
2058 |
|
2059 if ( IsDefConnSupported() ) |
|
2060 { |
|
2061 TCmDefConnValue defConn; |
|
2062 ReadDefConnWoTransL(defConn); |
|
2063 if ( defConn == aDCSetting ) |
|
2064 { |
|
2065 // Default connection deleted, setting it to default value. |
|
2066 TUint32 destId = GetInternetDestinationIdL(); |
|
2067 |
|
2068 if ( destId && ( destId != aDCSetting.iId ) ) |
|
2069 { |
|
2070 defConn.iType = ECmDefConnDestination; |
|
2071 defConn.iId = destId; |
|
2072 } |
|
2073 else |
|
2074 { |
|
2075 // Internet destination not found. Initialise to zero. |
|
2076 defConn.iType = TCmDefConnType ( 0 ); |
|
2077 defConn.iId = 0; |
|
2078 } |
|
2079 |
|
2080 WriteDefConnWoTransL( defConn ); |
|
2081 } |
|
2082 } // do nothing if default connection is not supported |
|
2083 } |
|
2084 |
|
2085 // ----------------------------------------------------------------------------- |
|
2086 // CCmManagerImpl::ReadDefConnWoTransL() |
|
2087 // ----------------------------------------------------------------------------- |
|
2088 // |
|
2089 void CCmManagerImpl::ReadDefConnWoTransL( TCmDefConnValue& aDCSetting ) |
|
2090 { |
|
2091 LOGGER_ENTERFN( "CCmManagerImpl::ReadDefConnWoTransL" ); |
|
2092 if ( IsDefConnSupported() ) |
|
2093 { |
|
2094 CMDBRecordSet<CCDDefConnRecord>* defConnRecordSet = |
|
2095 new ( ELeave ) CMDBRecordSet<CCDDefConnRecord>( iDefConnTableId ); |
|
2096 CleanupStack::PushL( defConnRecordSet ); |
|
2097 |
|
2098 TRAPD( err, defConnRecordSet->LoadL( Session() ) ); |
|
2099 if (err == KErrNone) |
|
2100 { |
|
2101 TInt mode = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], |
|
2102 KCDTIdDefConnType ); |
|
2103 aDCSetting.iType= TCmDefConnType (mode); |
|
2104 |
|
2105 aDCSetting.iId = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], |
|
2106 KCDTIdDefConnUid ); |
|
2107 CLOG_WRITE( "Default Connection read OK " ); |
|
2108 } |
|
2109 else |
|
2110 { |
|
2111 //deleting old record, writing Always Ask (default value) |
|
2112 //aDCSetting.iType = ECmDefConnAlwaysAsk; |
|
2113 //aDCSetting.iId = 0; |
|
2114 TUint32 destId = GetInternetDestinationIdL(); |
|
2115 |
|
2116 if ( destId ) |
|
2117 { |
|
2118 aDCSetting.iType = ECmDefConnDestination; |
|
2119 aDCSetting.iId = destId; |
|
2120 } |
|
2121 else |
|
2122 { |
|
2123 // Internet destination not found. Initialise to zero. |
|
2124 aDCSetting.iType = TCmDefConnType ( 0 ); |
|
2125 aDCSetting.iId = 0; |
|
2126 } |
|
2127 |
|
2128 CLOG_WRITE( "Default Connection read FAILED, storing Always Ask! " ); |
|
2129 ReplaceDefConnRecordL( aDCSetting ); |
|
2130 } |
|
2131 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2132 } |
|
2133 else |
|
2134 { |
|
2135 CLOG_WRITE( "Default Connection NOT supported, leaving with KErrNotSupported" ); |
|
2136 User::Leave(KErrNotSupported); |
|
2137 } |
|
2138 } |
|
2139 |
|
2140 //----------------------------------------------------------------------------- |
|
2141 // CCmManagerImpl::WriteDefConnWoTransL() |
|
2142 //----------------------------------------------------------------------------- |
|
2143 // |
|
2144 void CCmManagerImpl::WriteDefConnWoTransL( const TCmDefConnValue& aDCSetting ) |
|
2145 { |
|
2146 LOGGER_ENTERFN( "CCmManagerImpl::WriteDefConnWoTransL" ); |
|
2147 |
|
2148 if ( IsDefConnSupported() ) |
|
2149 { |
|
2150 ReplaceDefConnRecordL( aDCSetting ); |
|
2151 } |
|
2152 else |
|
2153 { |
|
2154 CLOG_WRITE( "Default Connection NOT supported, leaving with KErrNotSupported" ); |
|
2155 User::Leave(KErrNotSupported); |
|
2156 } |
|
2157 } |
|
2158 |
|
2159 // ----------------------------------------------------------------------------- |
|
2160 // CCmManagerImpl::ReadDefConnL() |
|
2161 // ----------------------------------------------------------------------------- |
|
2162 // |
|
2163 void CCmManagerImpl::ReadDefConnL( TCmDefConnValue& aDCSetting ) |
|
2164 { |
|
2165 LOGGER_ENTERFN( "CCmManagerImpl::ReadDefConn" ); |
|
2166 |
|
2167 if ( IsDefConnSupported() ) |
|
2168 { |
|
2169 OpenTransactionLC(); |
|
2170 CMDBRecordSet<CCDDefConnRecord>* defConnRecordSet = |
|
2171 new ( ELeave ) CMDBRecordSet<CCDDefConnRecord>( iDefConnTableId ); |
|
2172 CleanupStack::PushL( defConnRecordSet ); |
|
2173 |
|
2174 TRAPD( err, defConnRecordSet->LoadL( Session() ) ); |
|
2175 if (err == KErrNone) |
|
2176 { |
|
2177 TInt mode = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], |
|
2178 KCDTIdDefConnType ); |
|
2179 aDCSetting.iType= TCmDefConnType ( mode ); |
|
2180 |
|
2181 aDCSetting.iId = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], |
|
2182 KCDTIdDefConnUid ); |
|
2183 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2184 RollbackTransaction(); |
|
2185 } |
|
2186 else |
|
2187 { |
|
2188 //deleting old record, writing Always Ask (default value) |
|
2189 //aDCSetting.iType = ECmDefConnAlwaysAsk; |
|
2190 //aDCSetting.iId = 0; |
|
2191 |
|
2192 TUint32 destId = GetInternetDestinationIdL(); |
|
2193 |
|
2194 if ( destId ) |
|
2195 { |
|
2196 aDCSetting.iType = ECmDefConnDestination; |
|
2197 aDCSetting.iId = destId; |
|
2198 } |
|
2199 else |
|
2200 { |
|
2201 // Internet destination not found. Initialise to zero. |
|
2202 aDCSetting.iType = TCmDefConnType ( 0 ); |
|
2203 aDCSetting.iId = 0; |
|
2204 } |
|
2205 |
|
2206 CLOG_WRITE( "Default Connection read FAILED, storing Always Ask! " ); |
|
2207 ReplaceDefConnRecordL( aDCSetting ); |
|
2208 |
|
2209 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2210 CommitTransactionL( KErrNone ); |
|
2211 } |
|
2212 } |
|
2213 else |
|
2214 { |
|
2215 CLOG_WRITE( "Default Connection NOT supported" ); |
|
2216 User::Leave(KErrNotSupported); |
|
2217 } |
|
2218 } |
|
2219 |
|
2220 //----------------------------------------------------------------------------- |
|
2221 // CCmManagerImpl::ReplaceDefConnRecordL() |
|
2222 //----------------------------------------------------------------------------- |
|
2223 // |
|
2224 void CCmManagerImpl::ReplaceDefConnRecordL( const TCmDefConnValue aDCSetting ) |
|
2225 { |
|
2226 |
|
2227 LOGGER_ENTERFN( "CCmManagerImpl::ReplaceDefConnRecordL" ); |
|
2228 // Check the Id first (that it exists) |
|
2229 if ( aDCSetting.iType == ECmDefConnConnectionMethod ) |
|
2230 { |
|
2231 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord *> |
|
2232 ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
2233 CleanupStack::PushL( iapRecord ); |
|
2234 iapRecord->SetRecordId( aDCSetting.iId ); |
|
2235 TRAPD( err, iapRecord->LoadL( Session() ) ); |
|
2236 if ( err == KErrNotFound ) |
|
2237 { |
|
2238 User::Leave( KErrArgument ); |
|
2239 } |
|
2240 CleanupStack::PopAndDestroy( iapRecord ); |
|
2241 |
|
2242 // Check that Connection Method is not hidden |
|
2243 if ( GetConnectionMethodInfoBoolL( aDCSetting.iId, ECmHidden ) ) |
|
2244 { |
|
2245 User::Leave( KErrArgument ); |
|
2246 } |
|
2247 } |
|
2248 else if ( aDCSetting.iType == ECmDefConnDestination ) |
|
2249 { |
|
2250 TUint32 destId = GetInternetDestinationIdL(); |
|
2251 |
|
2252 // Allow empty Internet destination, others must have some content |
|
2253 if ( destId != aDCSetting.iId ) |
|
2254 { |
|
2255 CCDAccessPointRecord* destAPRecord = static_cast<CCDAccessPointRecord *>( |
|
2256 CCDRecordBase::RecordFactoryL( KCDTIdAccessPointRecord ) ); |
|
2257 CleanupStack::PushL( destAPRecord ); |
|
2258 |
|
2259 destAPRecord->iRecordTag = aDCSetting.iId; |
|
2260 if ( !destAPRecord->FindL( Session() ) ) |
|
2261 { |
|
2262 User::Leave( KErrArgument ); |
|
2263 } |
|
2264 CleanupStack::PopAndDestroy( destAPRecord ); |
|
2265 } |
|
2266 } |
|
2267 |
|
2268 TInt ret = KErrNone; |
|
2269 TCmGenConnSettings genConnSettings; |
|
2270 |
|
2271 SetGenConnSettingsToDefault( genConnSettings ); |
|
2272 |
|
2273 CMDBRecordSet<CCDDefConnRecord>* defConnRecordSet = |
|
2274 new ( ELeave ) CMDBRecordSet<CCDDefConnRecord>( iDefConnTableId ); |
|
2275 CleanupStack::PushL( defConnRecordSet ); |
|
2276 |
|
2277 TRAP( ret, defConnRecordSet->LoadL( Session() ) ); |
|
2278 |
|
2279 if (ret == KErrNone) |
|
2280 { |
|
2281 TInt value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdUsageOfWlan ); |
|
2282 genConnSettings.iUsageOfWlan = TCmUsageOfWlan( value ); |
|
2283 |
|
2284 value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdSeamlessnessHome ); |
|
2285 genConnSettings.iSeamlessnessHome = TCmSeamlessnessValue( value ); |
|
2286 |
|
2287 value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdSeamlessnessVisitor ); |
|
2288 genConnSettings.iSeamlessnessVisitor = TCmSeamlessnessValue( value ); |
|
2289 } |
|
2290 |
|
2291 TInt typeVal = aDCSetting.iType; |
|
2292 TInt uidVal = aDCSetting.iId; |
|
2293 |
|
2294 // Delete the old record |
|
2295 for ( TInt i = 0; i < defConnRecordSet->iRecords.Count(); ++i ) |
|
2296 { |
|
2297 defConnRecordSet->iRecords[i]->DeleteL( Session() ); |
|
2298 } |
|
2299 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2300 |
|
2301 CCDDefConnRecord* dcRcd = |
|
2302 new (ELeave) CCDDefConnRecord( iDefConnTableId ); |
|
2303 CleanupStack::PushL( dcRcd ); // 2 |
|
2304 |
|
2305 dcRcd->SetRecordId( KCDNewRecordRequest ); |
|
2306 |
|
2307 SET_INT_FIELD(dcRcd, KCDTIdUsageOfWlan, genConnSettings.iUsageOfWlan ); |
|
2308 SET_INT_FIELD(dcRcd, KCDTIdSeamlessnessHome, genConnSettings.iSeamlessnessHome ); |
|
2309 SET_INT_FIELD(dcRcd, KCDTIdSeamlessnessVisitor, genConnSettings.iSeamlessnessVisitor ); |
|
2310 |
|
2311 CLOG_WRITE_FORMAT( "Set default connection type: [%d]", typeVal ); |
|
2312 SET_INT_FIELD( dcRcd, |
|
2313 KCDTIdDefConnType, |
|
2314 typeVal ); |
|
2315 CLOG_WRITE_1( "Set uid: [%d]", uidVal ); |
|
2316 SET_INT_FIELD( dcRcd, |
|
2317 KCDTIdDefConnUid, |
|
2318 uidVal ); |
|
2319 dcRcd->StoreL( Session() ); |
|
2320 CleanupStack::PopAndDestroy( dcRcd ); |
|
2321 } |
|
2322 |
|
2323 //----------------------------------------------------------------------------- |
|
2324 // CCmManagerImpl::WriteDefConnL() |
|
2325 //----------------------------------------------------------------------------- |
|
2326 // |
|
2327 void CCmManagerImpl::WriteDefConnL( const TCmDefConnValue& aDCSetting ) |
|
2328 { |
|
2329 LOGGER_ENTERFN( "CCmManagerImpl::WriteDefConnL" ); |
|
2330 |
|
2331 if ( ( aDCSetting.iType == ECmDefConnAlwaysAsk ) || |
|
2332 ( aDCSetting.iType == ECmDefConnAskOnce ) ) |
|
2333 { |
|
2334 User::Leave( KErrNotSupported ); |
|
2335 } |
|
2336 if ( IsDefConnSupported() ) |
|
2337 { |
|
2338 OpenTransactionLC(); |
|
2339 |
|
2340 ReplaceDefConnRecordL( aDCSetting ); |
|
2341 CommitTransactionL( KErrNone ); |
|
2342 } |
|
2343 else |
|
2344 { |
|
2345 CLOG_WRITE( "Default Connection NOT supported, leaving with KErrNotSupported" ); |
|
2346 User::Leave(KErrNotSupported); |
|
2347 } |
|
2348 } |
|
2349 |
|
2350 //----------------------------------------------------------------------------- |
|
2351 // CCmManagerImpl::IsDefConnSupported() |
|
2352 //----------------------------------------------------------------------------- |
|
2353 // |
|
2354 TBool CCmManagerImpl::IsDefConnSupported( ) |
|
2355 { |
|
2356 LOGGER_ENTERFN( "CCmManagerImpl::IsDefConnSupported" ); |
|
2357 |
|
2358 return iDefConnSupported; |
|
2359 } |
|
2360 |
|
2361 // ----------------------------------------------------------------------------- |
|
2362 // CCmManagerImpl::ReadGenConneSettingsL() |
|
2363 // ----------------------------------------------------------------------------- |
|
2364 // |
|
2365 void CCmManagerImpl::ReadGenConnSettingsL( TCmGenConnSettings& aGenConnSettings ) |
|
2366 { |
|
2367 LOGGER_ENTERFN( "CCmManagerImpl::ReadGenConnSettingsL" ); |
|
2368 |
|
2369 OpenTransactionLC(); |
|
2370 CMDBRecordSet<CCDDefConnRecord>* defConnRecordSet = |
|
2371 new ( ELeave ) CMDBRecordSet<CCDDefConnRecord>( iDefConnTableId ); |
|
2372 CleanupStack::PushL( defConnRecordSet ); |
|
2373 |
|
2374 defConnRecordSet->LoadL( Session() ); |
|
2375 |
|
2376 TInt value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdUsageOfWlan ); |
|
2377 aGenConnSettings.iUsageOfWlan = TCmUsageOfWlan( value ); |
|
2378 |
|
2379 value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdSeamlessnessHome ); |
|
2380 aGenConnSettings.iSeamlessnessHome = TCmSeamlessnessValue( value ); |
|
2381 |
|
2382 value = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdSeamlessnessVisitor ); |
|
2383 aGenConnSettings.iSeamlessnessVisitor = TCmSeamlessnessValue( value ); |
|
2384 |
|
2385 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2386 RollbackTransaction(); |
|
2387 } |
|
2388 |
|
2389 //----------------------------------------------------------------------------- |
|
2390 // CCmManagerImpl::ReplaceGenConnSettingsL() |
|
2391 //----------------------------------------------------------------------------- |
|
2392 // |
|
2393 void CCmManagerImpl::ReplaceGenConnSettingsL( const TCmGenConnSettings& aGenConnSettings ) |
|
2394 { |
|
2395 |
|
2396 LOGGER_ENTERFN( "CCmManagerImpl::ReplaceGenConnSettingsL" ); |
|
2397 |
|
2398 TInt ret = KErrNone; |
|
2399 TCmDefConnValue defConn; |
|
2400 |
|
2401 defConn.iType = TCmDefConnType ( 0 ); |
|
2402 defConn.iId = 0; |
|
2403 |
|
2404 CMDBRecordSet<CCDDefConnRecord>* defConnRecordSet = |
|
2405 new ( ELeave ) CMDBRecordSet<CCDDefConnRecord>( iDefConnTableId ); |
|
2406 CleanupStack::PushL( defConnRecordSet ); |
|
2407 |
|
2408 TRAP(ret, defConnRecordSet->LoadL(Session())); |
|
2409 |
|
2410 if (ret == KErrNone) |
|
2411 { |
|
2412 TInt type = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdDefConnType); |
|
2413 defConn.iType = TCmDefConnType( type ); |
|
2414 TInt id = QUERY_INT_FIELD( defConnRecordSet->iRecords[0], KCDTIdDefConnUid); |
|
2415 defConn.iId = id; |
|
2416 } |
|
2417 |
|
2418 TInt usageOfNewWlan = aGenConnSettings.iUsageOfWlan; |
|
2419 TInt seamlessnessHome = aGenConnSettings.iSeamlessnessHome; |
|
2420 TInt seamlessnessVisitor = aGenConnSettings.iSeamlessnessVisitor; |
|
2421 |
|
2422 // Delete the old record |
|
2423 for ( TInt i = 0; i < defConnRecordSet->iRecords.Count(); ++i ) |
|
2424 { |
|
2425 defConnRecordSet->iRecords[i]->DeleteL( Session() ); |
|
2426 } |
|
2427 CleanupStack::PopAndDestroy( defConnRecordSet ); |
|
2428 |
|
2429 CCDDefConnRecord* dcRcd = |
|
2430 new (ELeave) CCDDefConnRecord( iDefConnTableId ); |
|
2431 CleanupStack::PushL( dcRcd ); // 2 |
|
2432 |
|
2433 dcRcd->SetRecordId( KCDNewRecordRequest ); |
|
2434 |
|
2435 SET_INT_FIELD(dcRcd, KCDTIdDefConnType, defConn.iType); |
|
2436 SET_INT_FIELD(dcRcd, KCDTIdDefConnUid, defConn.iId); |
|
2437 |
|
2438 CLOG_WRITE_1( "Set wlan usage: [%d]", usageOfNewWlan ); |
|
2439 SET_INT_FIELD(dcRcd, KCDTIdUsageOfWlan, usageOfNewWlan ); |
|
2440 |
|
2441 CLOG_WRITE_1( "Set seamlessnessHome: [%d]", seamlessnessHome ); |
|
2442 SET_INT_FIELD(dcRcd, KCDTIdSeamlessnessHome, seamlessnessHome ); |
|
2443 |
|
2444 CLOG_WRITE_1( "Set seamlessnessVisitor: [%d]", seamlessnessVisitor ); |
|
2445 SET_INT_FIELD(dcRcd, KCDTIdSeamlessnessVisitor, seamlessnessVisitor ); |
|
2446 |
|
2447 dcRcd->StoreL( Session() ); |
|
2448 CleanupStack::PopAndDestroy( dcRcd ); |
|
2449 } |
|
2450 |
|
2451 //----------------------------------------------------------------------------- |
|
2452 // CCmManagerImpl::WriteGenConnSettingsL() |
|
2453 //----------------------------------------------------------------------------- |
|
2454 // |
|
2455 void CCmManagerImpl::WriteGenConnSettingsL( const TCmGenConnSettings& aGenConnSettings ) |
|
2456 { |
|
2457 LOGGER_ENTERFN( "CCmManagerImpl::WriteGenConnSettingsL" ); |
|
2458 |
|
2459 OpenTransactionLC(); |
|
2460 |
|
2461 ReplaceGenConnSettingsL( aGenConnSettings ); |
|
2462 CommitTransactionL( KErrNone ); |
|
2463 } |
|
2464 |
|
2465 //----------------------------------------------------------------------------- |
|
2466 // CCmManagerImpl::IsMemoryLow() |
|
2467 //----------------------------------------------------------------------------- |
|
2468 // |
|
2469 TBool CCmManagerImpl::IsMemoryLow() |
|
2470 { |
|
2471 LOGGER_ENTERFN( "CCmManagerImpl::IsMemoryLow" ); |
|
2472 |
|
2473 TBool ret( EFalse ); |
|
2474 // Any plugin can be used here, because CheckSpaceBelowCriticalLevelL |
|
2475 // is defined in their father class CCmPluginBaseEng |
|
2476 TRAPD( err, ret = (*iPlugins)[0]->CheckSpaceBelowCriticalLevelL() ); |
|
2477 if( err != KErrNone ) |
|
2478 { |
|
2479 ret = ETrue; |
|
2480 return ret; |
|
2481 } |
|
2482 return ret; |
|
2483 } |
|
2484 |
|
2485 // ----------------------------------------------------------------------------- |
|
2486 // CCmManagerImpl::SNAPRecordL |
|
2487 // ----------------------------------------------------------------------------- |
|
2488 CCDSnapRecord* CCmManagerImpl::SNAPRecordL( TUint32 aRecordId ) const |
|
2489 { |
|
2490 CCDSnapRecord* record = new (ELeave) CCDSnapRecord( |
|
2491 DestinationTableId() ); |
|
2492 |
|
2493 if( aRecordId ) |
|
2494 { |
|
2495 record->SetRecordId( aRecordId ); |
|
2496 |
|
2497 CleanupStack::PushL( record ); |
|
2498 record->LoadL( Session() ); |
|
2499 CleanupStack::Pop( record ); |
|
2500 } |
|
2501 |
|
2502 return record; |
|
2503 } |
|
2504 |
|
2505 // ----------------------------------------------------------------------------- |
|
2506 // CCmManagerImpl::SNAPRecordL |
|
2507 // ----------------------------------------------------------------------------- |
|
2508 CCDSnapRecord* CCmManagerImpl::CreateSNAPRecordL( TUint32 aRecordId ) const |
|
2509 { |
|
2510 CCDSnapRecord* record = new (ELeave) CCDSnapRecord( |
|
2511 DestinationTableId() ); |
|
2512 |
|
2513 if( aRecordId ) |
|
2514 { |
|
2515 record->SetRecordId( aRecordId ); |
|
2516 } |
|
2517 |
|
2518 return record; |
|
2519 } |
|
2520 |
|
2521 //----------------------------------------------------------------------------- |
|
2522 // CCmManagerImpl::WrapCmManager() |
|
2523 //----------------------------------------------------------------------------- |
|
2524 // |
|
2525 EXPORT_C void CCmManagerImpl::WrapCmManager( RCmManagerExt& aCmManagerExt ) |
|
2526 { |
|
2527 aCmManagerExt.iImplementation = this; |
|
2528 } |
|
2529 |
|
2530 // -------------------------------------------------------------------------- |
|
2531 // CCmManagerImpl::FilterOutVirtualsL |
|
2532 // -------------------------------------------------------------------------- |
|
2533 // |
|
2534 EXPORT_C void CCmManagerImpl::FilterOutVirtualsL( RPointerArray<CCmPluginBase>& aCmDataArray ) |
|
2535 { |
|
2536 LOGGER_ENTERFN( "CCmManagerImpl::FilterOutVirtualsL" ); |
|
2537 |
|
2538 TInt count = aCmDataArray.Count(); |
|
2539 |
|
2540 for ( TInt i = 0; i < aCmDataArray.Count(); i++ ) |
|
2541 { |
|
2542 if ( aCmDataArray[i]->GetBoolAttributeL( ECmVirtual ) ) |
|
2543 { |
|
2544 delete aCmDataArray[i]; |
|
2545 aCmDataArray.Remove(i); |
|
2546 i--; |
|
2547 } |
|
2548 } |
|
2549 } |
|
2550 |
|
2551 // -------------------------------------------------------------------------- |
|
2552 // CCmManagerImpl::CreateFlatCMListLC |
|
2553 // -------------------------------------------------------------------------- |
|
2554 // |
|
2555 EXPORT_C void CCmManagerImpl::CreateFlatCMListLC( TUint32 aDestinationId , |
|
2556 RPointerArray<CCmPluginBase>& aCmArray ) |
|
2557 { |
|
2558 LOGGER_ENTERFN( "CCmManagerImpl::CreateFlatCMListLC" ); |
|
2559 |
|
2560 CreateFlatCMListL(aDestinationId, aCmArray); |
|
2561 CleanupResetAndDestroyPushL< RPointerArray<CCmPluginBase> >(aCmArray); |
|
2562 } |
|
2563 |
|
2564 // -------------------------------------------------------------------------- |
|
2565 // CCmManagerImpl::CreateFlatCMListL |
|
2566 // -------------------------------------------------------------------------- |
|
2567 // |
|
2568 EXPORT_C void CCmManagerImpl::CreateFlatCMListL( TUint32 aDestinationId , |
|
2569 RPointerArray<CCmPluginBase>& aCmArray ) |
|
2570 { |
|
2571 LOGGER_ENTERFN( "CCmManagerImpl::CreateFlatCMListL" ); |
|
2572 // get the uncategorised connection methods |
|
2573 if ( aDestinationId == KDestItemUncategorized ) |
|
2574 { |
|
2575 AppendUncatCmListLC( aCmArray); |
|
2576 } |
|
2577 else |
|
2578 { |
|
2579 // Get the CM ids from the destination |
|
2580 AppendCmListLC( aDestinationId, aCmArray ); |
|
2581 } |
|
2582 |
|
2583 // get the possible embedded destinations to be able to list their content, too |
|
2584 // we only have to check in cmArray |
|
2585 // put them in a sep. array and get their data into another. |
|
2586 TInt cmCount = aCmArray.Count(); |
|
2587 RArray<TUint32> cmEmbDestArray ( KCmArrayMediumGranularity ); |
|
2588 CleanupClosePushL( cmEmbDestArray ); |
|
2589 for ( TInt i = 0; i < cmCount; i++ ) |
|
2590 { |
|
2591 if ( aCmArray[i]->GetBoolAttributeL( ECmDestination ) ) |
|
2592 { |
|
2593 cmEmbDestArray.AppendL( aCmArray[i]->GetIntAttributeL( ECmId ) ); |
|
2594 //remove embedded destination right now |
|
2595 delete aCmArray[i]; |
|
2596 aCmArray.Remove(i); |
|
2597 // i--; |
|
2598 } |
|
2599 } |
|
2600 // now we stored the needed emb.dest, |
|
2601 // we can filter out all virtual ones |
|
2602 //iCmManager.FilterOutVirtualsL( cmArray ); //no filtering here, we can do it later |
|
2603 |
|
2604 // now we have the list of emb.dest. inside current destination, |
|
2605 // now get their CM's data appended to one flat list |
|
2606 RPointerArray<CCmPluginBase> cmLinkedDataArray ( KCmArrayMediumGranularity ); |
|
2607 CleanupResetAndDestroyPushL< RPointerArray<CCmPluginBase> >( cmLinkedDataArray ); |
|
2608 TInt embdestcount = cmEmbDestArray.Count(); |
|
2609 for ( TInt i = 0; i < embdestcount; i++ ) |
|
2610 { |
|
2611 // get the list of CM's |
|
2612 CCmPluginBase* emdestcm = |
|
2613 GetConnectionMethodL( cmEmbDestArray[i] ); |
|
2614 CleanupStack::PushL( emdestcm ); |
|
2615 TUint destUid = emdestcm->Destination()->Id(); |
|
2616 AppendCmListL( destUid, cmLinkedDataArray ); |
|
2617 CleanupStack::PopAndDestroy( emdestcm ); |
|
2618 } |
|
2619 // filter out virtuals |
|
2620 //iCmManager.FilterOutVirtualsL( cmLinkedDataArray ); //still no filtering here |
|
2621 |
|
2622 // now we have the original, sorted list and an unsorted cmLinkedDataArray, |
|
2623 // add each element to original array with sorting |
|
2624 |
|
2625 CombineArraysForPriorityOrderL( aCmArray, cmLinkedDataArray ); |
|
2626 |
|
2627 // now we do no longer need the linked array |
|
2628 CleanupStack::Pop( &cmLinkedDataArray ); // don't destroy the cm objects! |
|
2629 |
|
2630 cmLinkedDataArray.Close(); // they are appended to aCmArray!!! |
|
2631 CleanupStack::PopAndDestroy( &cmEmbDestArray ); |
|
2632 |
|
2633 CleanupStack::Pop(&aCmArray); |
|
2634 } |
|
2635 |
|
2636 // -------------------------------------------------------------------------- |
|
2637 // CCmManagerImpl::CombineCmListsL |
|
2638 // -------------------------------------------------------------------------- |
|
2639 // |
|
2640 EXPORT_C void CCmManagerImpl::CombineArraysForPriorityOrderL( |
|
2641 RPointerArray<CCmPluginBase>& aCmArray , |
|
2642 RPointerArray<CCmPluginBase>& aCmLinkedArray ) |
|
2643 { |
|
2644 LOGGER_ENTERFN( "CCmManagerImpl::CombineArraysForPriorityOrderL" ); |
|
2645 |
|
2646 // now we have two arrays, the first is sorted as needed, |
|
2647 // the second is not. |
|
2648 // we have to insert the items from the second to the first into their |
|
2649 // correct position based on the bearer type priorities |
|
2650 |
|
2651 // so loop on the second array, and for ech element, find it's place |
|
2652 TInt count = aCmLinkedArray.Count(); |
|
2653 for ( TInt i = 0; i < count; i++ ) |
|
2654 { |
|
2655 TUint32 linkedpriority( aCmLinkedArray[i]->GetIntAttributeL( ECmDefaultPriority ) ); |
|
2656 // InsertItemL( aCmArray, aCmLinkedArray[i]); |
|
2657 // higher priority means smaller number |
|
2658 // if same priority elements exist, then |
|
2659 // - we need to insert our element inside the elements |
|
2660 // of the same priority according to |
|
2661 // bearetypes and extension levels |
|
2662 // or before the first element having higher priority numbers. |
|
2663 TInt cc = aCmArray.Count(); |
|
2664 if ( cc ) |
|
2665 { |
|
2666 TInt ii = 0; |
|
2667 for ( ; ii < cc; ii++ ) |
|
2668 { |
|
2669 if ( linkedpriority < aCmArray[ii]->GetIntAttributeL( ECmDefaultPriority ) ) |
|
2670 { |
|
2671 // the next element already has larger number, |
|
2672 // we must insert it HERE |
|
2673 break; |
|
2674 } |
|
2675 else |
|
2676 { |
|
2677 // priorities either same, then we need to check bearer, |
|
2678 // ext.level, etc |
|
2679 // or we simply still need to go to next element |
|
2680 if ( linkedpriority == aCmArray[ii]->GetIntAttributeL( ECmDefaultPriority )) |
|
2681 { |
|
2682 // check if the same bearer |
|
2683 if ( aCmArray[ii]->GetIntAttributeL( ECmBearerType ) == |
|
2684 aCmLinkedArray[i]->GetIntAttributeL( ECmBearerType ) ) |
|
2685 { |
|
2686 // we need to find the last one of these bearers, |
|
2687 // and insert after the last one |
|
2688 do |
|
2689 { |
|
2690 ii++; |
|
2691 }while ( ( ii < cc ) |
|
2692 && (aCmArray[ii]->GetIntAttributeL( ECmBearerType ) == |
|
2693 aCmLinkedArray[i]->GetIntAttributeL( ECmBearerType )) ); |
|
2694 // now we either found a correct place or |
|
2695 // we are at the end of the list |
|
2696 break; |
|
2697 } |
|
2698 else |
|
2699 { |
|
2700 // diff. bearers, check Ext.level |
|
2701 if ( aCmArray[ii]->GetIntAttributeL( ECmExtensionLevel ) < aCmLinkedArray[i]->GetIntAttributeL( ECmExtensionLevel ) ) |
|
2702 { |
|
2703 break; |
|
2704 } |
|
2705 // if not, then go for the next one... |
|
2706 } |
|
2707 } |
|
2708 } |
|
2709 } |
|
2710 // now we either found a correct place or |
|
2711 // we are at the end of the list |
|
2712 // ( we break-ed for cycle when found the correct place ) |
|
2713 if ( ii == cc ) |
|
2714 { |
|
2715 // end of the list, append |
|
2716 aCmArray.AppendL( aCmLinkedArray[i]); |
|
2717 } |
|
2718 else |
|
2719 { |
|
2720 // we found the place to be inserted |
|
2721 aCmArray.InsertL( aCmLinkedArray[i], ii ); |
|
2722 } |
|
2723 } |
|
2724 else |
|
2725 { |
|
2726 // no elements in original array yet, |
|
2727 // so simply append |
|
2728 aCmArray.AppendL( aCmLinkedArray[i]); |
|
2729 } |
|
2730 } |
|
2731 } |
|
2732 |
|
2733 |
|
2734 // -------------------------------------------------------------------------- |
|
2735 // CCmManagerImpl::ParentDestinationL |
|
2736 // -------------------------------------------------------------------------- |
|
2737 // |
|
2738 TUint32 CCmManagerImpl::ParentDestinationL( TUint32 aCmId ) |
|
2739 { |
|
2740 LOGGER_ENTERFN( "CCmManagerImpl::ParentDestinationL" ); |
|
2741 |
|
2742 TUint32 retval(0); |
|
2743 |
|
2744 TUint32 destTblId = DestinationTableId(); |
|
2745 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* ptrRecordSet = |
|
2746 new (ELeave) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
2747 destTblId ); |
|
2748 CleanupStack::PushL( ptrRecordSet ); |
|
2749 |
|
2750 // Prime record |
|
2751 CCDDataMobilitySelectionPolicyRecord* record = |
|
2752 new (ELeave) CCDDataMobilitySelectionPolicyRecord( |
|
2753 DestinationTableId() ); |
|
2754 CleanupStack::PushL( record ); |
|
2755 |
|
2756 record->iIAP = IAP_ELEMENT_ID( aCmId ); |
|
2757 ptrRecordSet->iRecords.AppendL( record ); |
|
2758 |
|
2759 CleanupStack::Pop( record ); |
|
2760 record = NULL; |
|
2761 |
|
2762 if ( ptrRecordSet->FindL(Session()) ) |
|
2763 { |
|
2764 // we have a match |
|
2765 retval = QUERY_INT_FIELD( (*ptrRecordSet)[0], |
|
2766 KCDTIdDataMobilitySelectionPolicyNetwork ); |
|
2767 |
|
2768 } |
|
2769 CleanupStack::PopAndDestroy( ptrRecordSet ); |
|
2770 |
|
2771 return retval; |
|
2772 } |
|
2773 |
|
2774 // -------------------------------------------------------------------------- |
|
2775 // CCmManagerImpl::GetInternetDestinationIdL |
|
2776 // -------------------------------------------------------------------------- |
|
2777 // |
|
2778 TUint32 CCmManagerImpl::GetInternetDestinationIdL() |
|
2779 { |
|
2780 |
|
2781 LOGGER_ENTERFN( "CCmManagerImpl::GetInternetDestinationIdL" ); |
|
2782 |
|
2783 TUint32 destId = 0; |
|
2784 |
|
2785 // Get all destinations |
|
2786 RArray<TUint32> destIdArray( KCmArrayBigGranularity ); |
|
2787 AllDestinationsL( destIdArray ); |
|
2788 CleanupClosePushL( destIdArray ); |
|
2789 |
|
2790 CCmDestinationImpl* dest = NULL; |
|
2791 |
|
2792 for ( TInt i = 0; i < destIdArray.Count(); i++ ) |
|
2793 { |
|
2794 dest = DestinationL( destIdArray[i] ); |
|
2795 CleanupStack::PushL( dest ); |
|
2796 |
|
2797 // Check if destination is internet |
|
2798 if ( dest->MetadataL(ESnapMetadataInternet) ) |
|
2799 { |
|
2800 destId = destIdArray[i]; |
|
2801 } |
|
2802 |
|
2803 CleanupStack::PopAndDestroy( dest ); |
|
2804 |
|
2805 if ( destId ) |
|
2806 { |
|
2807 break; |
|
2808 } |
|
2809 } |
|
2810 |
|
2811 CleanupStack::PopAndDestroy( &destIdArray ); |
|
2812 |
|
2813 return destId; |
|
2814 } |
|
2815 |
|
2816 // ----------------------------------------------------------------------------- |
|
2817 // CCmManagerImpl::SetGenConnSettingsToDefault() |
|
2818 // ----------------------------------------------------------------------------- |
|
2819 // |
|
2820 void CCmManagerImpl::SetGenConnSettingsToDefault( TCmGenConnSettings& aGenConnSettings ) |
|
2821 { |
|
2822 LOGGER_ENTERFN( "CCmManagerImpl::SetGenConnSettingsToDefault" ); |
|
2823 |
|
2824 aGenConnSettings.iUsageOfWlan = ECmUsageOfWlanKnown; |
|
2825 aGenConnSettings.iSeamlessnessHome = ECmSeamlessnessConfirmFirst; |
|
2826 aGenConnSettings.iSeamlessnessVisitor = ECmSeamlessnessConfirmFirst; |
|
2827 } |
|
2828 |
|
2829 |
|
2830 // ----------------------------------------------------------------------------- |
|
2831 // CCmManagerImpl::CheckAvailableSpaceL() |
|
2832 // ----------------------------------------------------------------------------- |
|
2833 // |
|
2834 void CCmManagerImpl::CheckAvailableSpaceL() |
|
2835 { |
|
2836 LOGGER_ENTERFN( "CCmManagerImpl::CheckAvailableSpaceL" ); |
|
2837 TBool belowCritical = SysUtil::FFSSpaceBelowCriticalLevelL( &(this->iFs), KBytesToWrite ); |
|
2838 CLOG_WRITE_1( "belowCritical: [%d]", belowCritical ); |
|
2839 if ( belowCritical ) |
|
2840 { |
|
2841 User::Leave( KErrDiskFull ); |
|
2842 } |
|
2843 } |
|
2844 |
|
2845 |
|
2846 // -------------------------------------------------------------------------- |
|
2847 // CCmManagerImpl::WatcherRegisterL |
|
2848 // -------------------------------------------------------------------------- |
|
2849 // |
|
2850 EXPORT_C void CCmManagerImpl::WatcherRegisterL( MCmCommsDatWatcher* aWatcher ) |
|
2851 { |
|
2852 iCommsDatIapNotifier->WatcherRegisterL( aWatcher ); |
|
2853 iCommsDatSnapNotifier->WatcherRegisterL( aWatcher ); |
|
2854 } |
|
2855 |
|
2856 // -------------------------------------------------------------------------- |
|
2857 // CCmManagerImpl::WatcherUnRegister |
|
2858 // -------------------------------------------------------------------------- |
|
2859 // |
|
2860 EXPORT_C void CCmManagerImpl::WatcherUnRegister() |
|
2861 { |
|
2862 iCommsDatIapNotifier->WatcherUnRegister(); |
|
2863 iCommsDatSnapNotifier->WatcherUnRegister(); |
|
2864 } |
|
2865 |
|
2866 // -------------------------------------------------------------------------- |
|
2867 // CCmManagerImpl::DestinationStillExistedL |
|
2868 // -------------------------------------------------------------------------- |
|
2869 // |
|
2870 EXPORT_C TBool CCmManagerImpl::DestinationStillExistedL( CCmDestinationImpl* aDest ) |
|
2871 { |
|
2872 TUint32 destId = aDest->Id(); |
|
2873 TBool found( EFalse ); |
|
2874 TInt count; |
|
2875 |
|
2876 OpenTransactionLC(); |
|
2877 |
|
2878 CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>* destRecordSet = |
|
2879 new ( ELeave ) CMDBRecordSet<CCDDataMobilitySelectionPolicyRecord>( |
|
2880 iDestinationTableId ); |
|
2881 CleanupStack::PushL( destRecordSet ); |
|
2882 |
|
2883 TRAP_IGNORE( destRecordSet->LoadL( Session() ) ); |
|
2884 |
|
2885 count = destRecordSet->iRecords.Count(); |
|
2886 |
|
2887 for ( TInt i = 0; i < count; ++i ) |
|
2888 { |
|
2889 TInt nwId = QUERY_INT_FIELD( destRecordSet->iRecords[i], |
|
2890 KCDTIdDataMobilitySelectionPolicyNetwork ); |
|
2891 //nwId = RECORD_FROM_ELEMENT_ID( nwId ); |
|
2892 |
|
2893 if( nwId == destId ) |
|
2894 { |
|
2895 found = ETrue; |
|
2896 break; |
|
2897 } |
|
2898 } |
|
2899 |
|
2900 CleanupStack::PopAndDestroy( destRecordSet ); |
|
2901 |
|
2902 RollbackTransaction(); |
|
2903 |
|
2904 return found; |
|
2905 } |
|
2906 |
|
2907 // -------------------------------------------------------------------------- |
|
2908 // CCmManagerImpl::IapStillExistedL |
|
2909 // -------------------------------------------------------------------------- |
|
2910 // |
|
2911 EXPORT_C TBool CCmManagerImpl::IapStillExistedL( const CCmPluginBaseEng& aPlugin ) |
|
2912 { |
|
2913 TUint32 iapId = aPlugin.GetIntAttributeL( ECmId ); |
|
2914 CMDBRecordSet<CCDIAPRecord>* ptrRecordSet = AllIapsL(); |
|
2915 CleanupStack::PushL( ptrRecordSet ); |
|
2916 |
|
2917 TInt iapRecords = ptrRecordSet->iRecords.Count(); |
|
2918 |
|
2919 TBool found( EFalse ); |
|
2920 for ( TInt i = 0; !found && i < iapRecords; i++ ) |
|
2921 { |
|
2922 CCDIAPRecord* iapRecord = (*ptrRecordSet)[i]; |
|
2923 |
|
2924 if( iapRecord->RecordId() == iapId ) |
|
2925 { |
|
2926 found = ETrue; |
|
2927 break; |
|
2928 } |
|
2929 } |
|
2930 |
|
2931 CleanupStack::PopAndDestroy( ptrRecordSet ); |
|
2932 |
|
2933 return found; |
|
2934 } |
|
2935 |
|
2936 // -------------------------------------------------------------------------- |
|
2937 // CCmManagerImpl::IsIapStillInDestL |
|
2938 // -------------------------------------------------------------------------- |
|
2939 // |
|
2940 EXPORT_C TBool CCmManagerImpl::IsIapStillInDestL( |
|
2941 CCmDestinationImpl* aDest, |
|
2942 const CCmPluginBaseEng& aPlugin ) |
|
2943 { |
|
2944 TUint32 iapId = aPlugin.GetIntAttributeL( ECmId ); |
|
2945 |
|
2946 aDest->ReLoadConnectionMethodsL(); |
|
2947 RArray<TUint32> cmIds; |
|
2948 aDest->ConnectMethodIdArrayL( cmIds ); |
|
2949 CleanupClosePushL( cmIds ); |
|
2950 |
|
2951 TBool found( EFalse ); |
|
2952 for ( TInt i = 0; i < cmIds.Count(); i++ ) |
|
2953 { |
|
2954 if( cmIds[i] == iapId ) |
|
2955 { |
|
2956 found = ETrue; |
|
2957 break; |
|
2958 } |
|
2959 } |
|
2960 |
|
2961 CleanupStack::PopAndDestroy( &cmIds ); |
|
2962 |
|
2963 return found; |
|
2964 } |
|
2965 |
|
2966 // -------------------------------------------------------------------------- |
|
2967 // CCmManagerImpl::GetSnapTableIdL |
|
2968 // -------------------------------------------------------------------------- |
|
2969 // |
|
2970 TUint32 CCmManagerImpl::GetSnapTableIdL() |
|
2971 { |
|
2972 TUint32 snapTableId; |
|
2973 |
|
2974 CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() ); |
|
2975 db->SetAttributeMask( ECDHidden | ECDProtectedWrite ); |
|
2976 |
|
2977 snapTableId = CCDDataMobilitySelectionPolicyRecord::TableIdL( *db ); |
|
2978 |
|
2979 CleanupStack::PopAndDestroy( db ); |
|
2980 |
|
2981 return snapTableId; |
|
2982 } |