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