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