1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of application setting UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <coemain.h> |
|
19 #include <featmgr.h> |
|
20 #include <data_caging_path_literals.hrh> |
|
21 #include <StringLoader.h> |
|
22 #include <cmmanager.rsg> |
|
23 #include <AknsUtils.h> |
|
24 #include <ConnectionUiUtilities.h> |
|
25 |
|
26 |
|
27 #include <cmcommonconstants.h> |
|
28 #include "cmapplicationsettingsui.h" |
|
29 #include <cmmanager.h> |
|
30 #include "cmmanagerimpl.h" |
|
31 #include "cmdestinationimpl.h" |
|
32 #include "cmmanagerimpl.h" |
|
33 #include <cmpluginbaseeng.h> |
|
34 #include <cmpluginbase.h> |
|
35 #include "cmconnsettingsuiimpl.h" |
|
36 #include "cmconnselectrbpage.h" |
|
37 |
|
38 using namespace CMManager; |
|
39 |
|
40 typedef struct |
|
41 { |
|
42 TInt iCmIapId; |
|
43 TInt iCmDefaultPriority; |
|
44 }TCmListItem; |
|
45 |
|
46 //--------------------------------------------------------------------------- |
|
47 // CCmConnSettingsUiImpl::NewL |
|
48 //--------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C CCmConnSettingsUiImpl* CCmConnSettingsUiImpl::NewL( CCmManagerImpl* aCCmManagerImpl ) |
|
51 { |
|
52 CCmConnSettingsUiImpl* self = |
|
53 new (ELeave) CCmConnSettingsUiImpl(); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aCCmManagerImpl ); |
|
56 CleanupStack::Pop( self ); // self |
|
57 return self; |
|
58 } |
|
59 |
|
60 //--------------------------------------------------------------------------- |
|
61 // CCmConnSettingsUiImpl::NewL |
|
62 //--------------------------------------------------------------------------- |
|
63 // |
|
64 CCmConnSettingsUiImpl* CCmConnSettingsUiImpl::NewWithoutTablesL() |
|
65 { |
|
66 CCmConnSettingsUiImpl* self = |
|
67 new (ELeave) CCmConnSettingsUiImpl(); |
|
68 CleanupStack::PushL( self ); |
|
69 self->iCreateTables = EFalse; |
|
70 self->ConstructL( NULL ); |
|
71 CleanupStack::Pop( self ); // self |
|
72 return self; |
|
73 } |
|
74 |
|
75 //--------------------------------------------------------------------------- |
|
76 // CCmConnSettingsUiImpl::TCmDCSettingSelection |
|
77 //--------------------------------------------------------------------------- |
|
78 // |
|
79 CCmConnSettingsUiImpl::CCmConnSettingsUiImpl() |
|
80 : iResourceReader( *CCoeEnv::Static() ) |
|
81 , iAreDestinations ( ETrue ) |
|
82 , iShowAlwaysAsk( EFalse ) |
|
83 , iShowEasyWlan( EFalse ) |
|
84 , iShowVirtualCMs( ETrue ) |
|
85 , iShowEmptyDestinations( EFalse ) |
|
86 , iShowAskOnce( EFalse ) |
|
87 , iShowUncat( EFalse ) |
|
88 , iShowDefConn( EFalse ) |
|
89 , iUsePassedDestinationArray( EFalse ) |
|
90 , iHelpContext ( KSET_HLP_APP_DEST_ASSOC_VIEW ) |
|
91 , iCreateTables( ETrue ) |
|
92 { |
|
93 } |
|
94 |
|
95 //--------------------------------------------------------------------------- |
|
96 // CCmConnSettingsUiImpl::~TCmDCSettingSelection |
|
97 //--------------------------------------------------------------------------- |
|
98 // |
|
99 CCmConnSettingsUiImpl::~CCmConnSettingsUiImpl() |
|
100 { |
|
101 if ( iOwnCmManager ) |
|
102 { |
|
103 delete iCmManagerImpl; |
|
104 } |
|
105 iResourceReader.Close(); |
|
106 iItems.Close(); |
|
107 iPassedDestinations.Close(); |
|
108 } |
|
109 |
|
110 //--------------------------------------------------------------------------- |
|
111 // CCmConnSettingsUiImpl::LoadResourceL |
|
112 // Load the resource for the dll module |
|
113 //--------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CCmConnSettingsUiImpl::LoadResourceL () |
|
116 { |
|
117 // Add resource file. |
|
118 TParse* fp = new(ELeave) TParse(); |
|
119 TInt err = fp->Set( KACMManagerResDirAndFileName, |
|
120 &KDC_RESOURCE_FILES_DIR, |
|
121 NULL ); |
|
122 if ( err != KErrNone) |
|
123 { |
|
124 User::Leave( err ); |
|
125 } |
|
126 |
|
127 TFileName resourceFileNameBuf = fp->FullName(); |
|
128 delete fp; |
|
129 |
|
130 iResourceReader.OpenL( resourceFileNameBuf ); |
|
131 return err; |
|
132 } |
|
133 |
|
134 //--------------------------------------------------------------------------- |
|
135 // CCmConnSettingsUiImpl::ConstructL() |
|
136 //--------------------------------------------------------------------------- |
|
137 // |
|
138 void CCmConnSettingsUiImpl::ConstructL( CCmManagerImpl* aCCmManagerImpl ) |
|
139 { |
|
140 iOwnCmManager = !(aCCmManagerImpl); |
|
141 if ( iOwnCmManager ) |
|
142 { |
|
143 if (iCreateTables) |
|
144 { |
|
145 iCmManagerImpl = CCmManagerImpl::NewL(); |
|
146 } |
|
147 else |
|
148 { |
|
149 iCmManagerImpl = CCmManagerImpl::NewL(EFalse); |
|
150 } |
|
151 } |
|
152 else |
|
153 { |
|
154 iCmManagerImpl = aCCmManagerImpl; |
|
155 } |
|
156 LoadResourceL(); |
|
157 AknsUtils::SetAvkonSkinEnabledL( ETrue ); |
|
158 } |
|
159 |
|
160 //--------------------------------------------------------------------------- |
|
161 // CCmConnSettingsUiImpl::ShowConnSelectRadioPageL |
|
162 //--------------------------------------------------------------------------- |
|
163 // |
|
164 TBool CCmConnSettingsUiImpl::ShowConnSelectRadioPageL( |
|
165 TCmDCSettingSelection& aSelection, |
|
166 const TInt aTitleStringResource, |
|
167 TBearerFilterArray& aFilterArray ) |
|
168 { |
|
169 TBool retVal( EFalse ); |
|
170 // aSelection.iResult = EDCAlwaysAsk; |
|
171 |
|
172 CDesCArrayFlat* items = |
|
173 new ( ELeave ) CDesCArrayFlat( KCmArrayBigGranularity ); |
|
174 CleanupStack::PushL( items ); |
|
175 |
|
176 if (iAreDestinations) |
|
177 { |
|
178 BuildDestinationArrayL( items, aFilterArray ); |
|
179 } |
|
180 else |
|
181 { |
|
182 BuildCMArrayL( items, aFilterArray ); |
|
183 |
|
184 } |
|
185 // Uncategorized connection methods |
|
186 RPointerArray<CCmPluginBase> uncatArray( KCmArraySmallGranularity ); |
|
187 CCmManagerImpl::CleanupResetAndDestroyPushL< RPointerArray<CCmPluginBase> >( uncatArray ); |
|
188 if ( iShowUncat ) |
|
189 { |
|
190 BuildUncatArrayL( uncatArray, items, |
|
191 aFilterArray); |
|
192 } |
|
193 //appending items in reverse order of priority |
|
194 // Check if Ask Once should be shown |
|
195 if ( iShowAskOnce ) |
|
196 { |
|
197 HBufC* buf = StringLoader::LoadLC( R_CMMANAGERUI_SETT_ASK_ONCE ); |
|
198 items->InsertL( 0, *buf ); |
|
199 iItems.InsertL( KDestItemAskOnce, 0 ); |
|
200 CleanupStack::PopAndDestroy( buf ); |
|
201 } |
|
202 |
|
203 // Check if Always Ask should be shown |
|
204 if ( iShowAlwaysAsk ) |
|
205 { |
|
206 HBufC* buf = StringLoader::LoadLC( R_CMMANAGERUI_SETT_ALWAYS_ASK ); |
|
207 items->InsertL( 0, *buf ); |
|
208 iItems.InsertL( KDestItemAlwaysAsk, 0 ); |
|
209 CleanupStack::PopAndDestroy( buf ); |
|
210 } |
|
211 // Check if Default Connection should be shown |
|
212 //feautre flag |
|
213 if ( iCmManagerImpl->IsDefConnSupported() ) |
|
214 { |
|
215 //client's selection |
|
216 if ( iShowDefConn ) |
|
217 { |
|
218 HBufC* buf = StringLoader::LoadLC( R_CMMANAGERUI_SETT_DEFAULT_CONNECTION ); |
|
219 items->InsertL( 0, *buf ); |
|
220 iItems.InsertL( KDestItemDefaultConnection, 0 ); |
|
221 CleanupStack::PopAndDestroy( buf ); |
|
222 } |
|
223 } |
|
224 if (!items->Count()) |
|
225 { |
|
226 User::Leave(KErrConnectionNotFound); |
|
227 } |
|
228 |
|
229 TInt listIndex(0); |
|
230 |
|
231 if (iAreDestinations) |
|
232 { |
|
233 switch ( aSelection.iResult ) |
|
234 { |
|
235 case EDCDestination: |
|
236 { |
|
237 TInt newIndex = iItems.Find(aSelection.iId); |
|
238 if (newIndex >=0) |
|
239 { |
|
240 listIndex = newIndex; |
|
241 } |
|
242 break; |
|
243 } |
|
244 case EDCConnectionMethod: |
|
245 { |
|
246 TInt err(KErrNotFound); |
|
247 CCmPluginBase* cm = NULL; |
|
248 TRAP( err, cm = iCmManagerImpl->GetConnectionMethodL(aSelection.iId)); |
|
249 if ( err == KErrNone ) |
|
250 { |
|
251 // connection method is valid |
|
252 CleanupStack::PushL( cm ); |
|
253 TUint32 parentId = 0; |
|
254 CCmDestinationImpl* parent = cm->ParentDestination(); |
|
255 if (parent) |
|
256 { |
|
257 // it has a parent, get it's id |
|
258 parentId = parent->Id(); |
|
259 delete parent; |
|
260 } |
|
261 else |
|
262 { |
|
263 // no parent means Uncategorised |
|
264 parentId = KDestItemUncategorized; |
|
265 } |
|
266 // get the index based on id |
|
267 TInt tempIndex = iItems.Find( parentId ); |
|
268 if ( tempIndex != KErrNotFound ) |
|
269 { |
|
270 // found destination id in list |
|
271 listIndex = tempIndex; |
|
272 } |
|
273 CleanupStack::PopAndDestroy( cm ); |
|
274 } |
|
275 break; |
|
276 } |
|
277 case EDCDefaultConnection: |
|
278 { |
|
279 TInt newIndex = iItems.Find(KDestItemDefaultConnection); |
|
280 if (newIndex >=0) |
|
281 { |
|
282 listIndex = newIndex; |
|
283 } |
|
284 break; |
|
285 } |
|
286 case EDCAlwaysAsk: |
|
287 { |
|
288 TInt newIndex = iItems.Find(KDestItemAlwaysAsk); |
|
289 if (newIndex >=0) |
|
290 { |
|
291 listIndex = newIndex; |
|
292 } |
|
293 break; |
|
294 } |
|
295 case EDCAskOnce: |
|
296 { |
|
297 TInt newIndex = iItems.Find(KDestItemAskOnce); |
|
298 if (newIndex >=0) |
|
299 { |
|
300 listIndex = newIndex; |
|
301 } |
|
302 break; |
|
303 } |
|
304 default: // use default value (0) |
|
305 { |
|
306 break; |
|
307 } |
|
308 } |
|
309 } |
|
310 else |
|
311 { |
|
312 if (aSelection.iResult == EDCConnectionMethod) |
|
313 { |
|
314 TInt newIndex = iItems.Find(aSelection.iId); |
|
315 if (newIndex >=0) |
|
316 { |
|
317 listIndex = newIndex; |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 if ( aTitleStringResource == R_CMMANAGERUI_DEFAULT_CONNECTION_TITLE ) |
|
323 { |
|
324 // It is not allowed to choose Connection Methods |
|
325 // in Default connection -dialog. |
|
326 // |
|
327 iOpenDestination = EFalse; |
|
328 } |
|
329 |
|
330 if ( UserSelectionDlgL( listIndex, items, aSelection, |
|
331 aTitleStringResource, |
|
332 iOpenDestination) ) |
|
333 { |
|
334 // Handle selection |
|
335 |
|
336 switch ( aSelection.iResult ) |
|
337 { |
|
338 case EDCConnectionMethod: |
|
339 { |
|
340 // from the first list? |
|
341 if (!iAreDestinations) |
|
342 { |
|
343 aSelection.iId = iItems[listIndex]; |
|
344 retVal = ETrue; |
|
345 } |
|
346 else |
|
347 { |
|
348 // Uncategorised? |
|
349 TUint32 destId = iItems[ listIndex ]; |
|
350 if ( destId == KDestItemUncategorized ) |
|
351 { |
|
352 TBearerFilterArray emptyFilter; |
|
353 retVal = ShowConnectionMethodsL( uncatArray, |
|
354 aSelection, aTitleStringResource, emptyFilter ); |
|
355 } |
|
356 else |
|
357 { |
|
358 RPointerArray<CCmPluginBase> cmArray ( KCmArrayMediumGranularity ); |
|
359 if ( iShowVirtualCMs ) //create a flat list to show cms in embedded destinations |
|
360 { |
|
361 iCmManagerImpl->CreateFlatCMListLC( destId, cmArray); |
|
362 } |
|
363 else |
|
364 { |
|
365 //append only the cms in the destination |
|
366 iCmManagerImpl->AppendCmListLC( destId, cmArray ); |
|
367 } |
|
368 retVal = ShowConnectionMethodsL( cmArray, |
|
369 aSelection, aTitleStringResource, |
|
370 aFilterArray ); |
|
371 CleanupStack::PopAndDestroy( &cmArray ); |
|
372 } |
|
373 } |
|
374 break; |
|
375 } |
|
376 case EDCDestination: |
|
377 { |
|
378 // Store the destination Id |
|
379 aSelection.iId = iItems[listIndex]; |
|
380 retVal = ETrue; |
|
381 break; |
|
382 } |
|
383 case EDCAlwaysAsk: |
|
384 { |
|
385 // nothing more to do |
|
386 retVal = ETrue; |
|
387 break; |
|
388 } |
|
389 case EDCDefaultConnection: |
|
390 { |
|
391 // nothing more to do |
|
392 retVal = ETrue; |
|
393 break; |
|
394 } |
|
395 case EDCAskOnce: |
|
396 { |
|
397 // nothing more to do |
|
398 retVal = ETrue; |
|
399 break; |
|
400 } |
|
401 default: |
|
402 { |
|
403 break; |
|
404 } |
|
405 } |
|
406 } |
|
407 |
|
408 CleanupStack::PopAndDestroy( &uncatArray ); |
|
409 CleanupStack::PopAndDestroy( items ); |
|
410 |
|
411 return retVal; |
|
412 } |
|
413 |
|
414 |
|
415 //--------------------------------------------------------------------------- |
|
416 // CCmConnSettingsUiImpl::RunSettingsL() |
|
417 //--------------------------------------------------------------------------- |
|
418 // |
|
419 EXPORT_C TBool CCmConnSettingsUiImpl::RunApplicationSettingsL( |
|
420 TCmSettingSelection& aSelection, |
|
421 TUint aListItems, |
|
422 TBearerFilterArray& aFilterArray) |
|
423 { |
|
424 iItems.Close(); |
|
425 iAreDestinations = ETrue; |
|
426 if (!aListItems) |
|
427 { |
|
428 User::Leave(KErrArgument); |
|
429 } |
|
430 if ( !iCmManagerImpl->IsDefConnSupported() && |
|
431 !(aListItems & EShowAlwaysAsk) && |
|
432 !(aListItems & EShowConnectionMethods) && |
|
433 !(aListItems & EShowDestinations) |
|
434 ) |
|
435 { |
|
436 // default conn would be the only one but not supported |
|
437 User::Leave(KErrNotSupported); |
|
438 } |
|
439 |
|
440 if ( aListItems & EShowDefaultConnection ) |
|
441 { |
|
442 EnableDefConn( ETrue ); |
|
443 } |
|
444 else |
|
445 { |
|
446 EnableDefConn( EFalse ); |
|
447 } |
|
448 if (aListItems & EShowAlwaysAsk) |
|
449 { |
|
450 EnableAlwaysAsk( ETrue ); |
|
451 } |
|
452 else |
|
453 { |
|
454 EnableAlwaysAsk( EFalse ); |
|
455 } |
|
456 if ( (aListItems & EShowConnectionMethods) && (aListItems & EShowDestinations) ) |
|
457 { |
|
458 iOpenDestination = ETrue; |
|
459 iShowUncat = ETrue; |
|
460 } |
|
461 else |
|
462 { |
|
463 iOpenDestination = EFalse; |
|
464 } |
|
465 if ( (aListItems & EShowConnectionMethods) && !(aListItems & EShowDestinations) ) |
|
466 { |
|
467 iAreDestinations = EFalse; |
|
468 GetCMArrayL( ); |
|
469 } |
|
470 else if ( aListItems & EShowDestinations ) |
|
471 { |
|
472 if (iUsePassedDestinationArray) |
|
473 { |
|
474 // now fill up iItems |
|
475 for( TInt i=0; i<iPassedDestinations.Count(); i++) |
|
476 { |
|
477 iItems.Append(iPassedDestinations[i]); |
|
478 } |
|
479 } |
|
480 else |
|
481 { |
|
482 iCmManagerImpl->AllDestinationsL( iItems ); |
|
483 TInt i( 0 ); |
|
484 TInt count = iItems.Count(); |
|
485 for ( i=0; i < count; i++ ) |
|
486 { |
|
487 if ( iItems[i] > 0 && iItems[i] < 255 ) |
|
488 { |
|
489 CCmDestinationImpl* dest = |
|
490 iCmManagerImpl->DestinationL( iItems[i] ); |
|
491 CleanupStack::PushL( dest ); |
|
492 if ( dest->IsHidden() ) |
|
493 { |
|
494 iItems.Remove(i); |
|
495 i--; |
|
496 count = count-1; |
|
497 } |
|
498 CleanupStack::PopAndDestroy(); |
|
499 } |
|
500 } |
|
501 iItems.Compress(); |
|
502 } |
|
503 } |
|
504 |
|
505 TBool ret = EFalse; |
|
506 TCmDCSettingSelection userDefSelection; |
|
507 |
|
508 // convert selection |
|
509 switch ( aSelection.iResult ) |
|
510 { |
|
511 case EDestination: |
|
512 { |
|
513 userDefSelection.iResult = EDCDestination; |
|
514 userDefSelection.iId = aSelection.iId; |
|
515 break; |
|
516 } |
|
517 |
|
518 case EConnectionMethod: |
|
519 { |
|
520 userDefSelection.iResult = EDCConnectionMethod; |
|
521 userDefSelection.iId = aSelection.iId; |
|
522 break; |
|
523 } |
|
524 |
|
525 case EDefaultConnection: |
|
526 { |
|
527 userDefSelection.iResult = EDCDefaultConnection; |
|
528 userDefSelection.iId = 0; |
|
529 break; |
|
530 } |
|
531 |
|
532 case EAlwaysAsk: |
|
533 { |
|
534 userDefSelection.iResult = EDCAlwaysAsk; |
|
535 userDefSelection.iId = 0; |
|
536 break; |
|
537 } |
|
538 |
|
539 default: |
|
540 { |
|
541 // do not leave, perhaps there was no default selection |
|
542 } |
|
543 } |
|
544 |
|
545 |
|
546 |
|
547 if ( ShowConnSelectRadioPageL( userDefSelection, |
|
548 R_CMMANAGERUI_SETT_DESTINATION , aFilterArray)) |
|
549 { |
|
550 switch ( userDefSelection.iResult ) |
|
551 { |
|
552 case EDCDestination: |
|
553 { |
|
554 aSelection.iResult = EDestination; |
|
555 aSelection.iId = userDefSelection.iId; |
|
556 break; |
|
557 } |
|
558 case EDCConnectionMethod: |
|
559 { |
|
560 aSelection.iResult = EConnectionMethod; |
|
561 aSelection.iId = userDefSelection.iId; |
|
562 break; |
|
563 } |
|
564 case EDCDefaultConnection: |
|
565 { |
|
566 aSelection.iResult = EDefaultConnection; |
|
567 aSelection.iId = 0; |
|
568 break; |
|
569 } |
|
570 case EDCAlwaysAsk: |
|
571 { |
|
572 aSelection.iResult = EAlwaysAsk; |
|
573 aSelection.iId = 0; |
|
574 break; |
|
575 } |
|
576 default: //should not ever get here, unhandled branch |
|
577 { |
|
578 User::Leave( KErrGeneral ); |
|
579 break; |
|
580 } |
|
581 } |
|
582 ret = ETrue; |
|
583 } |
|
584 else |
|
585 { |
|
586 ret = EFalse; |
|
587 } |
|
588 return ret; |
|
589 } |
|
590 |
|
591 |
|
592 //--------------------------------------------------------------------------- |
|
593 // CCmConnSettingsUiImpl::RunDefaultConnecitonRBPageL() |
|
594 //--------------------------------------------------------------------------- |
|
595 // |
|
596 TBool CCmConnSettingsUiImpl::RunDefaultConnecitonRBPageL( |
|
597 TCmDCSettingSelection& aSelection ) |
|
598 { |
|
599 iHelpContext = KSET_HLP_DEFAULT_CONN; |
|
600 iItems.Close(); |
|
601 iOpenDestination = ETrue; |
|
602 iCmManagerImpl->AllDestinationsL( iItems ); |
|
603 EnableAlwaysAsk( EFalse ); |
|
604 EnableAskOnce( EFalse ); |
|
605 EnableUncat( EFalse ); |
|
606 TBearerFilterArray aFilterArray; |
|
607 iAreDestinations = ETrue; |
|
608 iShowEmptyDestinations = ETrue; |
|
609 return ShowConnSelectRadioPageL( aSelection , |
|
610 R_CMMANAGERUI_DEFAULT_CONNECTION_TITLE, aFilterArray ); |
|
611 } |
|
612 //--------------------------------------------------------------------------- |
|
613 // CCmConnSettingsUiImpl::GetCMArrayL() |
|
614 //--------------------------------------------------------------------------- |
|
615 // |
|
616 void CCmConnSettingsUiImpl::GetCMArrayL( ) |
|
617 { |
|
618 iCmManagerImpl->ConnectionMethodL( iItems, ETrue, EFalse,EFalse, ETrue ); |
|
619 TInt count = iItems.Count(); |
|
620 |
|
621 if ( !iShowVirtualCMs ) |
|
622 { |
|
623 // Don't show virtual CMs |
|
624 for ( TInt i = 0; i < count; i++ ) |
|
625 { |
|
626 if ( IsCmVirtualL( iItems[i] ) ) |
|
627 { |
|
628 iItems.Remove( i ); |
|
629 count--; |
|
630 i--; |
|
631 } |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 //--------------------------------------------------------------------------- |
|
637 // CCmConnSettingsUiImpl::BuildCMArrayL() |
|
638 //--------------------------------------------------------------------------- |
|
639 // |
|
640 void CCmConnSettingsUiImpl::BuildCMArrayL( CDesCArrayFlat* aItems, |
|
641 TBearerFilterArray& aFilterArray ) |
|
642 { |
|
643 // Add the New Connection Item |
|
644 for ( TInt i = 0; i < iItems.Count(); i++ ) |
|
645 { |
|
646 CCmPluginBase* cm = NULL; |
|
647 TInt err(KErrNone); |
|
648 TRAP( err, cm = iCmManagerImpl->GetConnectionMethodL(iItems[i])); |
|
649 if (err == KErrNoMemory) |
|
650 { |
|
651 User::Leave(KErrNoMemory); |
|
652 } |
|
653 else if (err != KErrNone) |
|
654 { |
|
655 continue; |
|
656 } |
|
657 CleanupStack::PushL( cm ); |
|
658 if (aFilterArray.Count()) |
|
659 { |
|
660 TUint cmBearerType = cm->GetIntAttributeL( ECmBearerType ); |
|
661 if ( aFilterArray.Find( cmBearerType ) == KErrNotFound ) |
|
662 { |
|
663 CleanupStack::PopAndDestroy( cm ); |
|
664 iItems.Remove(i); |
|
665 i--; |
|
666 continue; |
|
667 } |
|
668 } |
|
669 // CM Iap Id |
|
670 TUint32 cmId = cm->GetIntAttributeL( ECmId ); |
|
671 |
|
672 // Should virtual bearer types be shown? |
|
673 if ( iShowVirtualCMs || !IsCmVirtualL( cmId ) ) |
|
674 { |
|
675 // CM name |
|
676 HBufC* cmName = cm->GetStringAttributeL( ECmName ); |
|
677 CleanupStack::PushL( cmName ); |
|
678 // embedded destination has a special text format |
|
679 aItems->AppendL( *cmName ); |
|
680 CleanupStack::PopAndDestroy( cmName ); |
|
681 } |
|
682 CleanupStack::PopAndDestroy( cm ); |
|
683 } |
|
684 } |
|
685 |
|
686 //--------------------------------------------------------------------------- |
|
687 // CCmConnSettingsUiImpl::BuildDestinationArray() |
|
688 //--------------------------------------------------------------------------- |
|
689 // |
|
690 void CCmConnSettingsUiImpl::BuildDestinationArrayL( CDesCArrayFlat* aItems, |
|
691 TBearerFilterArray& aFilterArray ) |
|
692 { |
|
693 /* |
|
694 * The behavior of this function is as follow. |
|
695 * 1. If aFilterArray.Count() == 0 (This just means no filter provided by user) then the function will |
|
696 * show all of available destinations (if iShowVirtualCMs == ETrue; Otherwise, destination with only |
|
697 * virtualCMs will be filted out) (default). |
|
698 * 2. If aFilterArray.Count() != 0 then destination with only unavailable bearer-type IAPs will be |
|
699 * filted out. |
|
700 */ |
|
701 TInt count = iItems.Count(); |
|
702 // Add the New Connection Item |
|
703 for ( TInt i = 0; i < count; i++ ) |
|
704 { |
|
705 // Get the destinations from their IDs |
|
706 CCmDestinationImpl* dest = |
|
707 iCmManagerImpl->DestinationL( iItems[i] ); |
|
708 CleanupStack::PushL( dest ); |
|
709 |
|
710 TInt cmCount = dest->ConnectionMethodCount(); |
|
711 TInt validCmCount = cmCount; |
|
712 |
|
713 if ( !iUsePassedDestinationArray ) |
|
714 { |
|
715 // Check if empty destinations should be displayed |
|
716 if ( !iShowVirtualCMs || aFilterArray.Count()) |
|
717 { |
|
718 for ( TInt j = 0; j < cmCount; j++ ) |
|
719 { |
|
720 CCmPluginBase& cm = *dest->GetConnectionMethodL(j); |
|
721 // check if this destination only contains virtual CMs |
|
722 if (!iShowVirtualCMs)// See if the virtual CM (Default in case no filter provided by user) |
|
723 { |
|
724 // CM Iap Id |
|
725 TUint32 cmIapId = cm.GetIntAttributeL( ECmId ); |
|
726 // real CMs were found |
|
727 if ( IsCmVirtualL( cmIapId ) ) |
|
728 { |
|
729 validCmCount--; |
|
730 continue; |
|
731 } |
|
732 // We can not break the loop with else case here |
|
733 // for cm might be filted out by aFilterArray |
|
734 } |
|
735 |
|
736 if (aFilterArray.Count()) // See if the CM is filtered out |
|
737 { |
|
738 TUint cmBearerType = cm.GetIntAttributeL( ECmBearerType ); |
|
739 if ( aFilterArray.Find( cmBearerType ) == KErrNotFound ) |
|
740 { |
|
741 validCmCount--; |
|
742 } |
|
743 else |
|
744 { |
|
745 break;//there is at least one CM in this dest |
|
746 } |
|
747 } |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 // check if the destination should be omitted |
|
753 // check if empty destinations should be displayed |
|
754 |
|
755 // We can use a destination to make a connection only |
|
756 // if it contains something else than an empty embedded |
|
757 // destination. Otherwise, consider it empty. |
|
758 TBool canUseDestToConnect = dest->CanUseToConnectL(); |
|
759 |
|
760 if ( iDestinationToOmit != iItems[i] && |
|
761 ( ( validCmCount && canUseDestToConnect ) |
|
762 || iShowEmptyDestinations ) ) |
|
763 { |
|
764 // Check whether the MMS SNAP is in question. |
|
765 // It should not be shown on the UI in the destinations list |
|
766 TInt snapMetadata = 0; |
|
767 TRAPD( metaErr, snapMetadata = dest->MetadataL( CMManager::ESnapMetadataPurpose )); |
|
768 if ( metaErr == KErrNone && snapMetadata == CMManager::ESnapPurposeMMS ) |
|
769 { |
|
770 iItems.Remove(i); |
|
771 count--; |
|
772 i--; |
|
773 } |
|
774 else |
|
775 { |
|
776 HBufC* destName = dest->NameLC(); |
|
777 |
|
778 aItems->AppendL( *destName ); |
|
779 CleanupStack::PopAndDestroy( destName ); |
|
780 } |
|
781 } |
|
782 else |
|
783 { |
|
784 iItems.Remove(i); |
|
785 count--; |
|
786 i--; |
|
787 } |
|
788 |
|
789 CleanupStack::PopAndDestroy( dest ); |
|
790 } |
|
791 } |
|
792 |
|
793 //--------------------------------------------------------------------------- |
|
794 // CCmConnSettingsUiImpl::BuildUncatArrayL() |
|
795 //--------------------------------------------------------------------------- |
|
796 // |
|
797 void CCmConnSettingsUiImpl::BuildUncatArrayL( RPointerArray<CCmPluginBase>& aUncatArray, |
|
798 CDesCArrayFlat* aItems, |
|
799 TBearerFilterArray& aFilterArray ) |
|
800 { |
|
801 if ( iShowEasyWlan ) |
|
802 { |
|
803 // Get the uncategorised CMs including EasyWLAN |
|
804 iCmManagerImpl->AppendUncatCmListL( aUncatArray, ETrue, ETrue, ETrue ); |
|
805 } |
|
806 else |
|
807 { |
|
808 iCmManagerImpl->AppendUncatCmListL( aUncatArray ); |
|
809 } |
|
810 |
|
811 // Remove hidden Connection Methods |
|
812 for ( TInt i = 0; i < aUncatArray.Count(); i++ ) |
|
813 { |
|
814 if ( aUncatArray[i]->GetBoolAttributeL( ECmHidden ) ) |
|
815 { |
|
816 delete aUncatArray[i]; |
|
817 aUncatArray.Remove(i); |
|
818 i--; |
|
819 } |
|
820 } |
|
821 |
|
822 if (aFilterArray.Count()) |
|
823 { |
|
824 for ( TInt i = 0; i < aUncatArray.Count(); i++ ) |
|
825 { |
|
826 CCmPluginBase* cm = aUncatArray[i]; |
|
827 TUint cmBearerType = cm->GetIntAttributeL( ECmBearerType ); |
|
828 if ( aFilterArray.Find( cmBearerType ) == KErrNotFound ) |
|
829 { |
|
830 delete aUncatArray[i]; |
|
831 aUncatArray.Remove(i); |
|
832 i--; |
|
833 } |
|
834 } |
|
835 } |
|
836 TInt count = aUncatArray.Count(); |
|
837 |
|
838 if ( !iShowVirtualCMs ) |
|
839 { |
|
840 // Don't show virtual CMs |
|
841 for ( TInt i = 0; i < count; i++ ) |
|
842 { |
|
843 if ( IsCmVirtualL( aUncatArray[i]->GetIntAttributeL( ECmId ) ) ) |
|
844 { |
|
845 delete aUncatArray[i]; |
|
846 aUncatArray.Remove( i ); |
|
847 count--; |
|
848 i--; |
|
849 } |
|
850 } |
|
851 } |
|
852 // Show the 'Uncategorised' destination |
|
853 if ( count ) |
|
854 { |
|
855 HBufC* buf = StringLoader::LoadLC( R_CMMANAGERUI_DEST_UNCATEGORIZED ); |
|
856 aItems->AppendL( *buf ); |
|
857 CleanupStack::PopAndDestroy( buf ); |
|
858 iItems.AppendL( KDestItemUncategorized ); |
|
859 } |
|
860 } |
|
861 |
|
862 //--------------------------------------------------------------------------- |
|
863 // CCmConnSettingsUiImpl::UserSelectionDlgL() |
|
864 //--------------------------------------------------------------------------- |
|
865 // |
|
866 TBool CCmConnSettingsUiImpl::UserSelectionDlgL( |
|
867 TInt& aDestSelected, |
|
868 CDesCArrayFlat* aItems, |
|
869 TCmDCSettingSelection& aSelection, |
|
870 const TInt aTitleStringResource, |
|
871 TBool aOpenDestination) |
|
872 { |
|
873 // Should an item be highlighted? |
|
874 if ( aSelection.iResult == EDCDestination ) |
|
875 { |
|
876 for ( TInt i = 0; i < iItems.Count(); i++ ) |
|
877 { |
|
878 if ( iItems[i] == aSelection.iId ) |
|
879 { |
|
880 aDestSelected = i; |
|
881 } |
|
882 } |
|
883 } |
|
884 |
|
885 HBufC* buf = StringLoader::LoadLC( aTitleStringResource ); |
|
886 TInt dialogResourceId = R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL; |
|
887 if ( aOpenDestination ) // OPTIONS/CANCEL is available only if we can open |
|
888 //destinations |
|
889 { |
|
890 dialogResourceId = R_RADIO_BUTTON_SETTING_PAGE; |
|
891 } |
|
892 CCMConnSelectRBPage* page = |
|
893 new ( ELeave ) CCMConnSelectRBPage( dialogResourceId, |
|
894 aDestSelected, |
|
895 aItems, |
|
896 *iCmManagerImpl, |
|
897 aSelection.iResult, |
|
898 iItems, |
|
899 iAreDestinations, |
|
900 aOpenDestination , |
|
901 iHelpContext ); |
|
902 CleanupStack::PushL( page ); |
|
903 page->SetSettingTextL( *buf ); |
|
904 CleanupStack::Pop( page ); |
|
905 |
|
906 CleanupStack::PopAndDestroy( buf ); |
|
907 buf = NULL; |
|
908 |
|
909 return page->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ); |
|
910 } |
|
911 |
|
912 //--------------------------------------------------------------------------- |
|
913 // CCmConnSettingsUiImpl::UserSelectedUncatItemL() |
|
914 //--------------------------------------------------------------------------- |
|
915 // |
|
916 TBool CCmConnSettingsUiImpl::UserSelectedUncatItemL( |
|
917 RPointerArray<CCmPluginBase>& aUncatArray, |
|
918 TCmDCSettingSelection& aSelection, |
|
919 const TInt aTitleStringResource ) |
|
920 { |
|
921 TBool retVal( EFalse ); |
|
922 CDesCArrayFlat* items = |
|
923 new ( ELeave ) CDesCArrayFlat( KCmArrayBigGranularity ); |
|
924 CleanupStack::PushL( items ); |
|
925 |
|
926 TInt cmSelected( 0 ); |
|
927 |
|
928 TInt count = aUncatArray.Count(); |
|
929 for ( TInt i = 0; i < count; ++i ) |
|
930 { |
|
931 CCmPluginBase* cm = NULL; |
|
932 TRAPD( err, |
|
933 cm = iCmManagerImpl->GetConnectionMethodL( aUncatArray[i]->GetIntAttributeL( ECmId) ) |
|
934 ); |
|
935 |
|
936 if ( !err ) |
|
937 { |
|
938 CleanupStack::PushL( cm ); |
|
939 HBufC* cmName = cm->GetStringAttributeL( ECmName ); |
|
940 CleanupStack::PushL( cmName ); |
|
941 items->AppendL( *cmName ); |
|
942 |
|
943 // Virtual CMs have underlying CMs, highlight |
|
944 if ( cm->GetBoolAttributeL( ECmVirtual ) ) |
|
945 { |
|
946 TUint32 iapId (0); |
|
947 iapId = cm->GetIntAttributeL( ECmNextLayerIapId ); |
|
948 if ( iapId && iapId == aSelection.iId ) |
|
949 { |
|
950 cmSelected = i; |
|
951 } |
|
952 } |
|
953 CleanupStack::PopAndDestroy( 2, cm ); |
|
954 } |
|
955 else |
|
956 { |
|
957 //not handled iap, remove from list |
|
958 aUncatArray.Remove( i ); |
|
959 count--; |
|
960 i--; |
|
961 } |
|
962 } |
|
963 |
|
964 |
|
965 CAknRadioButtonSettingPage* rbPage = |
|
966 new ( ELeave ) CAknRadioButtonSettingPage( |
|
967 R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL, |
|
968 cmSelected, |
|
969 items ); |
|
970 CleanupStack::PushL( rbPage ); |
|
971 |
|
972 HBufC* buf = StringLoader::LoadLC( aTitleStringResource ); |
|
973 rbPage->SetSettingTextL( *buf ); |
|
974 CleanupStack::PopAndDestroy( buf ); |
|
975 |
|
976 if ( rbPage->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
977 { |
|
978 CCmPluginBase* cm = |
|
979 iCmManagerImpl->GetConnectionMethodL( aUncatArray[cmSelected]->GetIntAttributeL( ECmId) ); |
|
980 |
|
981 // ECmIapId can be surely queried here. It won't leave, but PushL to be |
|
982 // on the safe side |
|
983 CleanupStack::PushL( cm ); |
|
984 aSelection.iId = cm->GetIntAttributeL( ECmId ); |
|
985 CleanupStack::PopAndDestroy( cm ); |
|
986 |
|
987 aSelection.iResult = EDCConnectionMethod; |
|
988 |
|
989 retVal = ETrue; |
|
990 } |
|
991 CleanupStack::Pop( rbPage ); |
|
992 CleanupStack::PopAndDestroy( items ); |
|
993 |
|
994 return retVal; |
|
995 } |
|
996 |
|
997 |
|
998 //--------------------------------------------------------------------------- |
|
999 // CCmConnSettingsUiImpl::ShowConnectionMethodsL() |
|
1000 //--------------------------------------------------------------------------- |
|
1001 // |
|
1002 TBool CCmConnSettingsUiImpl::ShowConnectionMethodsL( |
|
1003 RPointerArray<CCmPluginBase>& aCmArray, TCmDCSettingSelection& aSelection, |
|
1004 const TInt aTitleStringResource, |
|
1005 TBearerFilterArray& aFilterArray ) |
|
1006 { |
|
1007 TInt retVal ( EFalse ); |
|
1008 |
|
1009 // List texts |
|
1010 CDesCArrayFlat* items = |
|
1011 new ( ELeave ) CDesCArrayFlat( KCmArrayMediumGranularity ); |
|
1012 CleanupStack::PushL( items ); |
|
1013 |
|
1014 // keeps track of the CMs in the list |
|
1015 |
|
1016 // idArray is used to put valid IAP ID. |
|
1017 // aFilterArray might filt some of IAPs (e.g., virtual IAPs) out. In this case, |
|
1018 // aCmArray can not be used to select IAP. So, idArray may be used for IAP selection |
|
1019 // for it only stores valid IAPs (i.e., not filted-out IAPs). |
|
1020 RArray<TUint32> idArray; |
|
1021 TInt cmSelected( 0 ); |
|
1022 TInt j( 0 ); |
|
1023 |
|
1024 // Collect item texts |
|
1025 TInt cmCount = aCmArray.Count(); |
|
1026 for ( TInt i = 0; i < cmCount; i++ ) |
|
1027 { |
|
1028 // CM info |
|
1029 if (aFilterArray.Count()) |
|
1030 { |
|
1031 TUint cmBearerType = aCmArray[i]->GetIntAttributeL( ECmBearerType ); |
|
1032 if ( aFilterArray.Find( cmBearerType ) == KErrNotFound ) |
|
1033 { |
|
1034 continue; |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 // CM Iap Id |
|
1039 TUint32 cmIapId = aCmArray[i]->GetIntAttributeL( ECmId ); |
|
1040 |
|
1041 // Should virtual bearer types be shown? |
|
1042 if ( iShowVirtualCMs || !IsCmVirtualL( cmIapId ) ) |
|
1043 { |
|
1044 // CM name |
|
1045 HBufC* name = aCmArray[i]->GetStringAttributeL( ECmName ); |
|
1046 CleanupStack::PushL( name ); |
|
1047 |
|
1048 items->AppendL( *name ); |
|
1049 idArray.Append( cmIapId ); |
|
1050 |
|
1051 // Virtual CMs have underlying CMs, highlight |
|
1052 if ( cmIapId == aSelection.iId ) |
|
1053 { |
|
1054 cmSelected = j; |
|
1055 j++; |
|
1056 } |
|
1057 |
|
1058 CleanupStack::PopAndDestroy( name ); |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 // create the dialog |
|
1063 CAknRadioButtonSettingPage* dlg = |
|
1064 new ( ELeave ) CAknRadioButtonSettingPage( |
|
1065 R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL, |
|
1066 cmSelected, |
|
1067 items ); |
|
1068 CleanupStack::PushL( dlg ); |
|
1069 |
|
1070 // Title |
|
1071 HBufC* title = StringLoader::LoadLC ( aTitleStringResource ); |
|
1072 dlg->SetSettingTextL( *title ); |
|
1073 |
|
1074 // Show the dialog |
|
1075 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
1076 { |
|
1077 aSelection.iId = idArray[cmSelected]; |
|
1078 aSelection.iResult = EDCConnectionMethod; |
|
1079 retVal = ETrue; |
|
1080 } |
|
1081 idArray.Close(); |
|
1082 |
|
1083 CleanupStack::PopAndDestroy( title ); |
|
1084 CleanupStack::Pop( dlg ); |
|
1085 CleanupStack::PopAndDestroy( items ); |
|
1086 |
|
1087 return retVal; |
|
1088 } |
|
1089 |
|
1090 |
|
1091 //--------------------------------------------------------------------------- |
|
1092 // CCmConnSettingsUiImpl::IsCmVirtualL |
|
1093 //--------------------------------------------------------------------------- |
|
1094 // |
|
1095 TBool CCmConnSettingsUiImpl::IsCmVirtualL( TUint32 aIapId ) |
|
1096 { |
|
1097 // check if bearer is virtual |
|
1098 TInt bearerType = iCmManagerImpl->GetConnectionMethodInfoIntL( |
|
1099 aIapId, ECmBearerType ); |
|
1100 return iCmManagerImpl->GetBearerInfoBoolL( bearerType, ECmVirtual ); |
|
1101 } |
|
1102 |
|
1103 |
|
1104 //--------------------------------------------------------------------------- |
|
1105 // CCmConnSettingsUiImpl::CreateDefaultConnectionNameL |
|
1106 //--------------------------------------------------------------------------- |
|
1107 // |
|
1108 HBufC* CCmConnSettingsUiImpl::CreateDefaultConnectionNameL( |
|
1109 TCmDefConnValue aSelection ) |
|
1110 { |
|
1111 HBufC* ret = NULL; |
|
1112 switch ( aSelection.iType ) |
|
1113 { |
|
1114 case ECmDefConnDestination: |
|
1115 { |
|
1116 CCmDestinationImpl* dest = |
|
1117 iCmManagerImpl->DestinationL( aSelection.iId ); |
|
1118 CleanupStack::PushL( dest ); |
|
1119 ret = dest->NameLC(); |
|
1120 CleanupStack::Pop( ret ); |
|
1121 CleanupStack::PopAndDestroy( dest ); |
|
1122 break; |
|
1123 } |
|
1124 case ECmDefConnConnectionMethod: |
|
1125 { |
|
1126 ret = iCmManagerImpl->GetConnectionMethodInfoStringL( |
|
1127 aSelection.iId, ECmName ); |
|
1128 break; |
|
1129 } |
|
1130 } |
|
1131 return ret; |
|
1132 } |
|
1133 |
|
1134 |
|
1135 |
|
1136 //--------------------------------------------------------------------------- |
|
1137 // CCmConnSettingsUiImpl::SetDestinationArrayToUseL |
|
1138 //--------------------------------------------------------------------------- |
|
1139 // |
|
1140 EXPORT_C void CCmConnSettingsUiImpl::SetDestinationArrayToUseL( |
|
1141 RArray<TUint32> aDestinationArray ) |
|
1142 { |
|
1143 iPassedDestinations.Close(); |
|
1144 for (TInt i=0; i<aDestinationArray.Count(); i++) |
|
1145 { |
|
1146 iPassedDestinations.AppendL(aDestinationArray[i]); |
|
1147 } |
|
1148 |
|
1149 iUsePassedDestinationArray = ETrue; |
|
1150 } |
|
1151 |
|
1152 |
|
1153 //--------------------------------------------------------------------------- |
|
1154 // CCmConnSettingsUiImpl::ClearDestinationArrayToUse |
|
1155 //--------------------------------------------------------------------------- |
|
1156 // |
|
1157 EXPORT_C void CCmConnSettingsUiImpl::ClearDestinationArrayToUse() |
|
1158 { |
|
1159 iPassedDestinations.Close(); |
|
1160 iUsePassedDestinationArray = EFalse; |
|
1161 } |
|
1162 |
|
1163 |
|