|
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: Popup for selecting the underlying connection method or |
|
15 * destination for a VPN connection method |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // includes |
|
21 #include <badesca.h> // arrays |
|
22 #include <gulicon.h> // icons |
|
23 #include <StringLoader.h> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <featmgr.h> |
|
26 #include <cmpluginvpn.mbg> |
|
27 #include <cmpluginvpnui.rsg> |
|
28 #include <cmmanager.rsg> |
|
29 #include <cmmanager.mbg> |
|
30 #include <eikenv.h> |
|
31 #include <aknlists.h> |
|
32 #include <eikfrlb.h> // CEikFormattedCellListBox |
|
33 #include <aknradiobuttonsettingpage.h> |
|
34 #include <cmpluginbaseeng.h> |
|
35 #include <cmpluginbase.h> |
|
36 |
|
37 #include <hlplch.h> |
|
38 #include <csxhelp/cp.hlp.hrh> |
|
39 |
|
40 #include "cmlogger.h" |
|
41 #include "cmdestinationimpl.h" |
|
42 #include "cmmanagerimpl.h" |
|
43 #include "cmpvpnnextlayerselectdlg.h" |
|
44 #include "cmvpncommonconstants.h" |
|
45 #include <cmcommonconstants.h> |
|
46 #include <cmpluginvpndef.h> |
|
47 |
|
48 using namespace CMManager; |
|
49 // -------------------------------------------------------------------------- |
|
50 // CmPluginVpnNextLayerSelectDlg::NewL |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CmPluginVpnNextLayerSelectDlg* CmPluginVpnNextLayerSelectDlg::NewL( |
|
54 CCmPluginBaseEng& aCmPluginBaseEng, |
|
55 RArray<TUint32>& aBindableMethods, |
|
56 TBool& aSnapSelected, |
|
57 TUint32& aNextLayerId ) |
|
58 { |
|
59 CmPluginVpnNextLayerSelectDlg* self = |
|
60 new ( ELeave ) CmPluginVpnNextLayerSelectDlg( aCmPluginBaseEng, |
|
61 aBindableMethods, |
|
62 aSnapSelected, |
|
63 aNextLayerId ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CmPluginVpnNextLayerSelectDlg::CmPluginVpnNextLayerSelectDlg |
|
72 // -------------------------------------------------------------------------- |
|
73 // |
|
74 CmPluginVpnNextLayerSelectDlg::CmPluginVpnNextLayerSelectDlg( |
|
75 CCmPluginBaseEng& aCmPluginBaseEng, |
|
76 RArray<TUint32>& aBindableMethods, |
|
77 TBool& aSnapSelected, |
|
78 TUint32& aNextLayerId ) |
|
79 : iMyEikonEnv( *CEikonEnv::Static() ) |
|
80 , iCmPluginBaseEng( aCmPluginBaseEng ) |
|
81 , iSnapSelected( aSnapSelected ) |
|
82 , iNextLayerId( aNextLayerId ) |
|
83 , iResourceReader( *CCoeEnv::Static() ) |
|
84 , iDestinations( aBindableMethods ) |
|
85 , iEasyWlanId(0) |
|
86 , iCmManager( iCmPluginBaseEng.CmMgr() ) |
|
87 , iUncatItems( EFalse ) |
|
88 { |
|
89 ; |
|
90 } |
|
91 |
|
92 |
|
93 // -------------------------------------------------------------------------- |
|
94 // CmPluginVpnNextLayerSelectDlg::~CmPluginVpnPolicySelectionDlg |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 CmPluginVpnNextLayerSelectDlg::~CmPluginVpnNextLayerSelectDlg() |
|
98 { |
|
99 iResourceReader.Close(); |
|
100 |
|
101 if ( iMenuBar ) |
|
102 { |
|
103 HideMenu(); |
|
104 CEikonEnv::Static()->EikAppUi()->RemoveFromStack( iMenuBar ); |
|
105 delete iMenuBar; |
|
106 iMenuBar = NULL; |
|
107 } |
|
108 |
|
109 delete iMyListBox; iMyListBox = NULL; |
|
110 } |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // CmPluginVpnNextLayerSelectDlg::ConstructL |
|
114 // -------------------------------------------------------------------------- |
|
115 // |
|
116 void CmPluginVpnNextLayerSelectDlg::ConstructL() |
|
117 { |
|
118 LoadResourceL( KPluginVPNResDirAndFileName ); |
|
119 InitialiseL(); |
|
120 SetTextsAndIconsL(); |
|
121 } |
|
122 |
|
123 // -------------------------------------------------------------------------- |
|
124 // CmPluginVpnNextLayerSelectDlg::InitialiseL |
|
125 // -------------------------------------------------------------------------- |
|
126 // |
|
127 void CmPluginVpnNextLayerSelectDlg::InitialiseL() |
|
128 { |
|
129 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::InitialiseL" ); |
|
130 |
|
131 // get the EasyWlan id if it's supported |
|
132 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ) |
|
133 { |
|
134 iEasyWlanId = iCmManager.EasyWlanIdL(); |
|
135 } |
|
136 |
|
137 // Listbox |
|
138 iMyListBox = new ( ELeave ) CAknDoubleLargeGraphicPopupMenuStyleListBox; |
|
139 |
|
140 CAknPopupList::ConstructL( |
|
141 iMyListBox, |
|
142 R_SOFTKEYS_OPTIONS_CANCEL__SELECT, |
|
143 AknPopupLayouts::EMenuDoubleLargeGraphicWindow ); |
|
144 |
|
145 TInt flags = 0; |
|
146 iMyListBox->ConstructL( this, flags ); |
|
147 iMyListBox->CreateScrollBarFrameL( ETrue ); |
|
148 iMyListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
149 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
150 |
|
151 // Menu |
|
152 CEikMenuBar* newMenuBar = new ( ELeave ) CEikMenuBar(); |
|
153 CleanupStack::PushL( newMenuBar ); |
|
154 newMenuBar->ConstructL( this, NULL, R_VPN_REAL_CM_SELECTION_MENUBAR ); |
|
155 iMyEikonEnv.EikAppUi()->AddToStackL( newMenuBar, |
|
156 ECoeStackPriorityMenu, |
|
157 ECoeStackFlagRefusesFocus ); |
|
158 iMenuBar = newMenuBar; |
|
159 CleanupStack::Pop( newMenuBar ); // ownership taken by 'this' |
|
160 } |
|
161 |
|
162 // -------------------------------------------------------------------------- |
|
163 // CmPluginVpnNextLayerSelectDlg::SetTextsAndIconsL |
|
164 // -------------------------------------------------------------------------- |
|
165 // |
|
166 void CmPluginVpnNextLayerSelectDlg::SetTextsAndIconsL() |
|
167 { |
|
168 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::SetTextsAndIconsL" ); |
|
169 // Title |
|
170 SetTitleL( *StringLoader::LoadLC( |
|
171 R_QTN_NETW_CONSET_PRMPT_VPN_REAL_CONNECTION ) ); |
|
172 CleanupStack::PopAndDestroy(); // header |
|
173 |
|
174 // Item text array |
|
175 CDesCArray* itemArray = |
|
176 new ( ELeave ) CDesCArrayFlat( KCmArrayMediumGranularity ); |
|
177 CleanupStack::PushL( itemArray ); |
|
178 iMyListBox->Model()->SetItemTextArray( itemArray ); // ownership taken |
|
179 iMyListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
180 CleanupStack::Pop( itemArray ); // as ownership is taken |
|
181 |
|
182 // Icon array |
|
183 CArrayPtr<CGulIcon>* icons = |
|
184 new ( ELeave ) CArrayPtrFlat<CGulIcon>( KCmArrayMediumGranularity ); |
|
185 CleanupStack::PushL( icons ); |
|
186 iMyListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
187 // ownership taken by SetIconArrayL! |
|
188 CleanupStack::Pop( icons ); // as ownership is taken |
|
189 |
|
190 // Step through the Destinations - do not show: |
|
191 // Parent Destinations or Destinations with no non-virtual CMs |
|
192 // Show Uncategorised if valid and EasyWlan if supported |
|
193 TInt destCount = iDestinations.Count(); |
|
194 for ( TInt i = 0; i < destCount; i++ ) |
|
195 { |
|
196 switch ( iDestinations[i] ) |
|
197 { |
|
198 case KDestItemUncategorized: |
|
199 { |
|
200 // Append 'Uncategorised' if necessary |
|
201 AppendUncatDestinationL( *itemArray, *icons ); |
|
202 break; |
|
203 } |
|
204 case KDestItemEasyWlan: |
|
205 { |
|
206 // Append 'EasyWlan' if supported |
|
207 TRAPD( err, AppendEasyWlanL( *itemArray, *icons ) ); |
|
208 if ( err != KErrNotSupported ) |
|
209 { |
|
210 User::LeaveIfError( err ); |
|
211 } |
|
212 break; |
|
213 } |
|
214 // normal destination |
|
215 default: |
|
216 { |
|
217 CCmDestinationImpl* dest = |
|
218 iCmManager.DestinationL( iDestinations[i] ); |
|
219 CleanupStack::PushL( dest ); |
|
220 TInt numCms = dest->ConnectionMethodCount(); |
|
221 AppendDestinationTextsL( *dest,numCms, *itemArray, *icons ); |
|
222 CleanupStack::PopAndDestroy( dest ); |
|
223 break; |
|
224 } |
|
225 } |
|
226 } |
|
227 } |
|
228 |
|
229 |
|
230 // -------------------------------------------------------------------------- |
|
231 // CmPluginVpnNextLayerSelectDlg::AppendDestinationsTextsL |
|
232 // -------------------------------------------------------------------------- |
|
233 // |
|
234 void CmPluginVpnNextLayerSelectDlg::AppendDestinationTextsL( |
|
235 CCmDestinationImpl& aDestination, |
|
236 TInt aNumCms, |
|
237 CDesCArray& aItems, |
|
238 CArrayPtr<CGulIcon>& aIcons ) |
|
239 { |
|
240 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::AppendDestinationL" ); |
|
241 // icon |
|
242 CGulIcon* icon = ( CGulIcon* ) aDestination.IconL(); |
|
243 CleanupStack::PushL( icon ); |
|
244 aIcons.AppendL( icon ); |
|
245 TInt iconIndex = aIcons.Count() - 1; |
|
246 CleanupStack::Pop( icon ); // icon array took over ownership |
|
247 |
|
248 // compile the list item |
|
249 HBufC* firstLine = aDestination.NameLC(); |
|
250 HBufC* secondLine; |
|
251 |
|
252 if ( aNumCms == 1 ) |
|
253 { |
|
254 secondLine = StringLoader::LoadLC( |
|
255 R_CMMANAGERUI_CONN_METHODS_AMOUNT_ONE ); |
|
256 } |
|
257 else |
|
258 { |
|
259 secondLine = StringLoader::LoadLC( |
|
260 R_CMMANAGERUI_CONN_METHODS_AMOUNT_MANY, |
|
261 aNumCms ); |
|
262 } |
|
263 |
|
264 HBufC* item = FormatListItemTextsLC( *firstLine, |
|
265 *secondLine, |
|
266 iconIndex ); |
|
267 aItems.AppendL( *item ); |
|
268 |
|
269 CleanupStack::PopAndDestroy( item ); |
|
270 CleanupStack::PopAndDestroy( secondLine ); |
|
271 CleanupStack::PopAndDestroy( firstLine ); |
|
272 } |
|
273 |
|
274 // -------------------------------------------------------------------------- |
|
275 // CmPluginVpnNextLayerSelectDlg::AppendUncatDestinationL |
|
276 // -------------------------------------------------------------------------- |
|
277 // |
|
278 void CmPluginVpnNextLayerSelectDlg::AppendUncatDestinationL( |
|
279 CDesCArray& aItems, |
|
280 CArrayPtr<CGulIcon>& aIcons ) |
|
281 { |
|
282 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::AppendUncatDestinationL" ); |
|
283 |
|
284 TParse mbmFile; |
|
285 User::LeaveIfError( mbmFile.Set( KManagerIconFilename, |
|
286 &KDC_APP_BITMAP_DIR, |
|
287 NULL ) ); |
|
288 |
|
289 // icon |
|
290 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
291 AknsUtils::SkinInstance(), |
|
292 KAknsIIDQgnPropSetConnDestUncategorized, |
|
293 mbmFile.FullName(), |
|
294 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized, |
|
295 EMbmCmmanagerQgn_prop_set_conn_dest_uncategorized_mask ); |
|
296 CleanupStack::PushL( icon ); |
|
297 aIcons.AppendL( icon ); |
|
298 CleanupStack::Pop( icon ); // icon array took over ownership |
|
299 TInt iconIndex = aIcons.Count() - 1; |
|
300 |
|
301 // remove virtual CMs |
|
302 RArray<TUint32> uncatCms ( KCmArraySmallGranularity ); |
|
303 iCmManager.ConnectionMethodL( uncatCms ); |
|
304 CleanupClosePushL( uncatCms ); |
|
305 |
|
306 for ( TInt i = 0; i < uncatCms.Count(); i++ ) |
|
307 { |
|
308 TInt bearerType = iCmManager.GetConnectionMethodInfoIntL( |
|
309 uncatCms[i], ECmBearerType ); |
|
310 |
|
311 if ( iCmManager.GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
312 { |
|
313 uncatCms.Remove(i); |
|
314 i--; |
|
315 } |
|
316 } |
|
317 |
|
318 // second line text |
|
319 HBufC* secondLine; |
|
320 if ( uncatCms.Count() == 1 ) |
|
321 { |
|
322 secondLine = StringLoader::LoadLC( |
|
323 R_CMMANAGERUI_CONN_METHODS_AMOUNT_ONE ); |
|
324 } |
|
325 else |
|
326 { |
|
327 secondLine = StringLoader::LoadLC( |
|
328 R_CMMANAGERUI_CONN_METHODS_AMOUNT_MANY, |
|
329 uncatCms.Count() ); |
|
330 } |
|
331 |
|
332 // compile the texts |
|
333 HBufC* item = FormatListItemTextsLC( R_CMMANAGERUI_DEST_UNCATEGORIZED, |
|
334 *secondLine, |
|
335 iconIndex ); |
|
336 aItems.AppendL( *item ); |
|
337 |
|
338 CleanupStack::PopAndDestroy( item ); |
|
339 CleanupStack::PopAndDestroy( secondLine ); |
|
340 CleanupStack::PopAndDestroy( &uncatCms ); |
|
341 } |
|
342 |
|
343 // -------------------------------------------------------------------------- |
|
344 // CmPluginVpnNextLayerSelectDlg::AppendEasyWlanL |
|
345 // -------------------------------------------------------------------------- |
|
346 // |
|
347 void CmPluginVpnNextLayerSelectDlg::AppendEasyWlanL( |
|
348 CDesCArray& aItems, |
|
349 CArrayPtr<CGulIcon>& aIcons ) |
|
350 { |
|
351 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::AppendEasyWlanL" ); |
|
352 |
|
353 // icon |
|
354 CCmPluginBase* cm = iCmManager.GetConnectionMethodL( iEasyWlanId ); |
|
355 CleanupStack::PushL( cm ); |
|
356 CGulIcon* icon = ( CGulIcon* ) cm->GetIntAttributeL( ECmBearerIcon ); |
|
357 CleanupStack::PushL( icon ); |
|
358 aIcons.AppendL( icon ); // ownership passed to array |
|
359 TInt iconIndex = aIcons.Count() - 1; |
|
360 CleanupStack::Pop( icon ); |
|
361 CleanupStack::PopAndDestroy( cm ); |
|
362 |
|
363 // compile the texts |
|
364 HBufC* easyWlan = FormatListItemTextsLC( |
|
365 R_QTN_NETW_CONSET_VPN_EASY_WLAN, |
|
366 R_QTN_NETW_CONSET_VPN_EASY_WLAN_PROMPT, |
|
367 iconIndex ); |
|
368 aItems.AppendL( *easyWlan ); |
|
369 |
|
370 CleanupStack::PopAndDestroy( easyWlan ); |
|
371 } |
|
372 |
|
373 // -------------------------------------------------------------------------- |
|
374 // CmPluginVpnNextLayerSelectDlg::DynInitMenuPaneL |
|
375 // -------------------------------------------------------------------------- |
|
376 // |
|
377 void CmPluginVpnNextLayerSelectDlg::DynInitMenuPaneL( |
|
378 TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
379 { |
|
380 if ( aResourceId == R_VPN_REAL_CM_SELECTION_MENU ) |
|
381 { |
|
382 if (!iCmManager.IsHelpOn()) |
|
383 { |
|
384 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
385 } |
|
386 TUint32 highlighted = iDestinations[ iListBox->CurrentItemIndex() ]; |
|
387 |
|
388 switch ( highlighted ) |
|
389 { |
|
390 case KDestItemUncategorized: |
|
391 { |
|
392 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestSelect, ETrue ); |
|
393 break; |
|
394 } |
|
395 case KDestItemEasyWlan: |
|
396 { |
|
397 aMenuPane->SetItemDimmed( ECmManagerUiCmdCMSelect, ETrue ); |
|
398 break; |
|
399 } |
|
400 default: |
|
401 { |
|
402 break; |
|
403 } |
|
404 } |
|
405 } |
|
406 } |
|
407 |
|
408 // -------------------------------------------------------------------------- |
|
409 // CmPluginVpnNextLayerSelectDlg::ProcessCommandL |
|
410 // -------------------------------------------------------------------------- |
|
411 // |
|
412 void CmPluginVpnNextLayerSelectDlg::ProcessCommandL( TInt aCommandId ) |
|
413 { |
|
414 if ( MenuShowing() ) |
|
415 { |
|
416 HideMenu(); |
|
417 } |
|
418 switch ( aCommandId ) |
|
419 { |
|
420 case EAknSoftkeyOptions: |
|
421 { |
|
422 DisplayMenuL(); |
|
423 break; |
|
424 } |
|
425 case ECmManagerUiCmdDestSelect: |
|
426 { |
|
427 TUint32 destId = iDestinations[ iListBox->CurrentItemIndex() ]; |
|
428 |
|
429 if ( destId != KDestItemUncategorized ) |
|
430 { |
|
431 TUint32 attribute = ECmNextLayerSNAPId; |
|
432 |
|
433 // EasyWlan was selected |
|
434 if ( destId == KDestItemEasyWlan ) |
|
435 { |
|
436 attribute = ECmNextLayerIapId; |
|
437 destId = iEasyWlanId; |
|
438 } |
|
439 iCmPluginBaseEng.SetIntAttributeL( attribute, destId ); |
|
440 AttemptExitL( ETrue ); |
|
441 break; |
|
442 } |
|
443 // For uncategorised destinations, flow through to ECmManagerUiCmdCMSelect |
|
444 } |
|
445 case ECmManagerUiCmdCMSelect: |
|
446 { |
|
447 // select a connection method from the highlighted destination |
|
448 TUint32 destId = iDestinations[ iListBox->CurrentItemIndex() ]; |
|
449 TUint32 cmId (0); |
|
450 if ( ShowCMSelectionDlgL( destId, cmId ) ) |
|
451 { |
|
452 iCmPluginBaseEng.SetIntAttributeL( ECmNextLayerIapId, cmId ); |
|
453 AttemptExitL( ETrue ); |
|
454 } |
|
455 else |
|
456 { |
|
457 CancelPopup(); |
|
458 } |
|
459 break; |
|
460 } |
|
461 case EAknCmdHelp: |
|
462 { |
|
463 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
464 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
465 } |
|
466 break; |
|
467 case EAknSoftkeyBack: |
|
468 { |
|
469 CancelPopup(); |
|
470 break; |
|
471 } |
|
472 default: |
|
473 { |
|
474 CAknPopupList::ProcessCommandL( aCommandId ); |
|
475 break; |
|
476 } |
|
477 } |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // CmPluginVpnNextLayerSelectDlg::OfferKeyEventL |
|
482 // --------------------------------------------------------------------------- |
|
483 // |
|
484 TKeyResponse CmPluginVpnNextLayerSelectDlg::OfferKeyEventL( |
|
485 const TKeyEvent& aKeyEvent, |
|
486 TEventCode aType ) |
|
487 { |
|
488 TKeyResponse retVal ( EKeyWasNotConsumed ); |
|
489 TUint highlighted = iDestinations[ iListBox->CurrentItemIndex() ]; |
|
490 |
|
491 switch ( aKeyEvent.iScanCode ) |
|
492 { |
|
493 case EStdKeyDownArrow: |
|
494 case EStdKeyUpArrow: |
|
495 { |
|
496 // If focus is on the 'uncategorised' destination, |
|
497 // change the soft key to 'Open' |
|
498 if ( highlighted == KDestItemUncategorized ) |
|
499 { |
|
500 ButtonGroupContainer()->SetCommandL( |
|
501 ECmManagerUiCmdDestSelect, |
|
502 *( StringLoader::LoadLC( R_QTN_MSK_OPEN ) ) |
|
503 ); |
|
504 ButtonGroupContainer()->DrawDeferred(); |
|
505 CleanupStack::PopAndDestroy(); |
|
506 } |
|
507 else |
|
508 { |
|
509 ButtonGroupContainer()->SetCommandL( |
|
510 ECmManagerUiCmdDestSelect, |
|
511 *( StringLoader::LoadLC( R_QTN_MSK_SELECT ) ) |
|
512 ); |
|
513 ButtonGroupContainer()->DrawDeferred(); |
|
514 CleanupStack::PopAndDestroy(); |
|
515 } |
|
516 break; |
|
517 } |
|
518 case EStdKeyNo: |
|
519 { |
|
520 CancelPopup(); |
|
521 return EKeyWasConsumed; |
|
522 } |
|
523 default: |
|
524 { |
|
525 // If focus is on the 'uncategorised' destination, |
|
526 // change the soft key to 'Open' |
|
527 if ( highlighted == KDestItemUncategorized ) |
|
528 { |
|
529 ButtonGroupContainer()->SetCommandL( |
|
530 ECmManagerUiCmdDestSelect, |
|
531 *( StringLoader::LoadLC( R_QTN_MSK_OPEN ) ) |
|
532 ); |
|
533 ButtonGroupContainer()->DrawDeferred(); |
|
534 CleanupStack::PopAndDestroy(); |
|
535 } |
|
536 |
|
537 if ( aKeyEvent.iCode == EKeyEscape ) |
|
538 { |
|
539 CancelPopup(); |
|
540 return EKeyWasConsumed; |
|
541 } |
|
542 } |
|
543 } |
|
544 retVal = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
545 |
|
546 return retVal; |
|
547 } |
|
548 |
|
549 // --------------------------------------------------------------------------- |
|
550 // CDestDlg::HandleListBoxEventL |
|
551 // --------------------------------------------------------------------------- |
|
552 void CmPluginVpnNextLayerSelectDlg::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
553 TListBoxEvent aEventType ) |
|
554 { |
|
555 switch ( aEventType ) |
|
556 { |
|
557 case EEventEnterKeyPressed: |
|
558 case EEventItemDoubleClicked: |
|
559 { |
|
560 ProcessCommandL(ECmManagerUiCmdDestSelect); |
|
561 break; |
|
562 } |
|
563 default: |
|
564 { |
|
565 break; |
|
566 }; |
|
567 }; |
|
568 } |
|
569 |
|
570 // -------------------------------------------------------------------------- |
|
571 // CmPluginVpnNextLayerSelectDlg::SetEmphasis |
|
572 // -------------------------------------------------------------------------- |
|
573 // |
|
574 void CmPluginVpnNextLayerSelectDlg::SetEmphasis( CCoeControl* aMenuControl, |
|
575 TBool aEmphasis ) |
|
576 { |
|
577 CEikAppUi* appUi = iMyEikonEnv.EikAppUi(); |
|
578 appUi->RemoveFromStack( aMenuControl ); |
|
579 |
|
580 TRAP_IGNORE( appUi->AddToStackL ( |
|
581 aMenuControl, |
|
582 aEmphasis ? ECoeStackPriorityDialog : |
|
583 ECoeStackPriorityMenu ) ); |
|
584 |
|
585 appUi->UpdateStackedControlFlags( |
|
586 aMenuControl, |
|
587 aEmphasis ? 0 : ECoeStackFlagRefusesFocus, |
|
588 ECoeStackFlagRefusesFocus ); |
|
589 appUi->HandleStackChanged(); |
|
590 } |
|
591 |
|
592 // -------------------------------------------------------------------------- |
|
593 // CmPluginVpnNextLayerSelectDlg::LoadResourceL |
|
594 // -------------------------------------------------------------------------- |
|
595 // |
|
596 void CmPluginVpnNextLayerSelectDlg::LoadResourceL( |
|
597 const TDesC& aResFileName ) |
|
598 { |
|
599 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::LoadResourceL" ); |
|
600 TInt err ( KErrNone ); |
|
601 |
|
602 // Add resource file. |
|
603 TParse* fp = new ( ELeave ) TParse(); |
|
604 err = fp->Set( aResFileName, |
|
605 &KDC_RESOURCE_FILES_DIR, |
|
606 NULL ); |
|
607 if ( err ) |
|
608 { |
|
609 User::Leave( err ); |
|
610 } |
|
611 |
|
612 TFileName resourceFileNameBuf = fp->FullName(); |
|
613 delete fp; |
|
614 |
|
615 iResourceReader.OpenL( resourceFileNameBuf ); |
|
616 } |
|
617 |
|
618 |
|
619 // -------------------------------------------------------------------------- |
|
620 // CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC |
|
621 // -------------------------------------------------------------------------- |
|
622 // |
|
623 HBufC* CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC( |
|
624 TInt aFirstLineResId, |
|
625 TInt aSecondLineResId, |
|
626 TInt aIconIndex ) |
|
627 { |
|
628 HBufC* firstLine = StringLoader::LoadLC( aFirstLineResId ); |
|
629 HBufC* secondLine = StringLoader::LoadLC( aSecondLineResId ); |
|
630 |
|
631 HBufC* retVal = FormatListItemTextsL( *firstLine, |
|
632 *secondLine, |
|
633 aIconIndex ); |
|
634 CleanupStack::PopAndDestroy( secondLine ); |
|
635 CleanupStack::PopAndDestroy( firstLine ); |
|
636 CleanupStack::PushL( retVal ); |
|
637 return retVal; |
|
638 } |
|
639 |
|
640 // -------------------------------------------------------------------------- |
|
641 // CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC |
|
642 // -------------------------------------------------------------------------- |
|
643 // |
|
644 HBufC* CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC( |
|
645 const TDesC& aFirstLine, |
|
646 const TDesC& aSecondLine, |
|
647 TInt aIconIndex ) |
|
648 { |
|
649 HBufC* retVal = FormatListItemTextsL( aFirstLine, |
|
650 aSecondLine, |
|
651 aIconIndex ); |
|
652 CleanupStack::PushL( retVal ); |
|
653 return retVal; |
|
654 } |
|
655 |
|
656 // -------------------------------------------------------------------------- |
|
657 // CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC |
|
658 // -------------------------------------------------------------------------- |
|
659 // |
|
660 HBufC* CmPluginVpnNextLayerSelectDlg::FormatListItemTextsLC( |
|
661 TInt aFirstLineResId, |
|
662 const TDesC& aSecondLine, |
|
663 TInt aIconIndex ) |
|
664 { |
|
665 // Load the first string |
|
666 HBufC* firstLine = StringLoader::LoadLC( aFirstLineResId ); |
|
667 |
|
668 HBufC* retVal = FormatListItemTextsL( *firstLine, |
|
669 aSecondLine, |
|
670 aIconIndex ); |
|
671 CleanupStack::PopAndDestroy( firstLine ); |
|
672 CleanupStack::PushL( retVal ); |
|
673 return retVal; |
|
674 } |
|
675 |
|
676 // -------------------------------------------------------------------------- |
|
677 // CmPluginVpnNextLayerSelectDlg::FormatListItemTextsL |
|
678 // -------------------------------------------------------------------------- |
|
679 // |
|
680 HBufC* CmPluginVpnNextLayerSelectDlg::FormatListItemTextsL( |
|
681 const TDesC& aFirstLine, |
|
682 const TDesC& aSecondLine, |
|
683 TInt aIconIndex ) |
|
684 { |
|
685 HBufC* retVal = HBufC::NewL( aFirstLine.Length() + |
|
686 aSecondLine.Length() + |
|
687 KNumberOfStaticCharsIn2LineFormattedString ); |
|
688 |
|
689 TPtr ptr ( retVal->Des() ); |
|
690 ptr.AppendNum( aIconIndex ); |
|
691 ptr.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
692 ptr.Append( aFirstLine ); |
|
693 ptr.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
694 ptr.Append( aSecondLine ); |
|
695 |
|
696 return retVal; |
|
697 } |
|
698 |
|
699 // -------------------------------------------------------------------------- |
|
700 // CmPluginVpnNextLayerSelectDlg::ShowCMSelectionDlgL |
|
701 // -------------------------------------------------------------------------- |
|
702 // |
|
703 TBool CmPluginVpnNextLayerSelectDlg::ShowCMSelectionDlgL( |
|
704 TUint32 aDestinationId, |
|
705 TUint32& aCmId ) |
|
706 { |
|
707 LOGGER_ENTERFN( "CmPluginVpnNextLayerSelectDlg::ShowCMSelectionDlgL" ); |
|
708 TBool retVal ( EFalse ); |
|
709 |
|
710 // Collect item texts |
|
711 CDesCArrayFlat* items = |
|
712 new ( ELeave ) CDesCArrayFlat( KCmArraySmallGranularity ); |
|
713 CleanupStack::PushL( items ); |
|
714 |
|
715 RPointerArray<CCmPluginBase> cmDataArray ( KCmArrayMediumGranularity ); |
|
716 iCmManager.CreateFlatCMListLC( aDestinationId , cmDataArray ); |
|
717 CleanupStack::Pop( &cmDataArray ); |
|
718 CCmManagerImpl::CleanupResetAndDestroyPushL(cmDataArray); |
|
719 iCmManager.FilterOutVirtualsL( cmDataArray ); |
|
720 |
|
721 |
|
722 // after it, get the names for each element |
|
723 // and finally make up the real items array. |
|
724 |
|
725 // Get the names of the connection methods |
|
726 // virtuals are already filtered out, |
|
727 TInt count = cmDataArray.Count(); |
|
728 for ( TInt i = 0; i < count; i++ ) |
|
729 { |
|
730 HBufC* cmName = |
|
731 iCmManager.GetConnectionMethodInfoStringL( cmDataArray[i]->GetIntAttributeL( ECmId ), |
|
732 ECmName ); |
|
733 CleanupStack::PushL( cmName ); |
|
734 |
|
735 // append the name to the string |
|
736 items->AppendL( *cmName ); |
|
737 |
|
738 CleanupStack::PopAndDestroy( cmName ); |
|
739 } |
|
740 |
|
741 // Display the radio button page |
|
742 TInt selected ( 0 ); |
|
743 TInt resId( R_VPN_REAL_CM_RADIO_BUTTON_SETTING_PAGE ); |
|
744 |
|
745 CAknRadioButtonSettingPage* dlg = |
|
746 new ( ELeave ) CAknRadioButtonSettingPage( |
|
747 resId, |
|
748 selected, |
|
749 items ); |
|
750 CleanupStack::PushL( dlg ); |
|
751 dlg->SetSettingTextL( |
|
752 *StringLoader::LoadLC( R_CMWIZARD_SELECT_CONN_METHOD ) ); |
|
753 CleanupStack::PopAndDestroy(); |
|
754 CleanupStack::Pop( dlg ); |
|
755 |
|
756 MakeVisible( EFalse ); |
|
757 |
|
758 TInt result = 0; |
|
759 TRAPD( err, result = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ); |
|
760 |
|
761 MakeVisible( ETrue ); |
|
762 User::LeaveIfError( err ); |
|
763 |
|
764 if ( result ) |
|
765 |
|
766 { |
|
767 // store result |
|
768 aCmId = cmDataArray[ selected ]->GetIntAttributeL( ECmId ); |
|
769 retVal = ETrue; |
|
770 } |
|
771 |
|
772 CleanupStack::PopAndDestroy( &cmDataArray ); |
|
773 CleanupStack::PopAndDestroy( items ); |
|
774 return retVal; |
|
775 } |
|
776 |
|
777 // -------------------------------------------------------------------------- |
|
778 // CmPluginVpnNextLayerSelectDlg::DisplayMenuL |
|
779 // -------------------------------------------------------------------------- |
|
780 // |
|
781 void CmPluginVpnNextLayerSelectDlg::DisplayMenuL() |
|
782 { |
|
783 iMenuBar->TryDisplayMenuBarL(); |
|
784 } |
|
785 |
|
786 // -------------------------------------------------------------------------- |
|
787 // CmPluginVpnNextLayerSelectDlg::HideMenu |
|
788 // -------------------------------------------------------------------------- |
|
789 // |
|
790 void CmPluginVpnNextLayerSelectDlg::HideMenu() |
|
791 { |
|
792 iMenuBar->StopDisplayingMenuBar(); |
|
793 } |
|
794 |
|
795 // -------------------------------------------------------------------------- |
|
796 // CmPluginVpnNextLayerSelectDlg::MenuShowing |
|
797 // -------------------------------------------------------------------------- |
|
798 // |
|
799 TBool CmPluginVpnNextLayerSelectDlg::MenuShowing() const |
|
800 { |
|
801 return iMenuBar->IsDisplayed(); |
|
802 } |
|
803 |
|
804 // -------------------------------------------------------------------------- |
|
805 // CmPluginVpnNextLayerSelectDlg::GetHelpContext |
|
806 // -------------------------------------------------------------------------- |
|
807 // |
|
808 void CmPluginVpnNextLayerSelectDlg::GetHelpContext( |
|
809 TCoeHelpContext& aContext ) const |
|
810 { |
|
811 aContext.iMajor = KHelpUidPlugin; |
|
812 aContext.iContext = KSET_HLP_VPN_DEST_ASSOC_VIEW; |
|
813 } |
|
814 |
|
815 // -------------------------------------------------------------------------- |
|
816 // CmPluginVpnNextLayerSelectDlg::MakeVisible |
|
817 // -------------------------------------------------------------------------- |
|
818 // |
|
819 void CmPluginVpnNextLayerSelectDlg::MakeVisible( TBool aVisible ) |
|
820 { |
|
821 CAknPopupList::MakeVisible( aVisible ); |
|
822 |
|
823 // Necessary implementation. |
|
824 CAknPopupList::FadeBehindPopup( IsVisible() ); |
|
825 } |
|
826 |
|
827 |
|
828 |
|
829 |