1 /* |
|
2 * Copyright (c) 2008 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: Source file for SUPL server UI view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Include |
|
20 #include <barsread.h> // For TResourceReader |
|
21 #include <bautils.h> |
|
22 #include <StringLoader.h> |
|
23 #include <aknViewAppUi.h> |
|
24 #include <avkon.rsg> |
|
25 #include <hlplch.h> // Help |
|
26 #include <featmgr.h> // FeatureManager |
|
27 #include <eikmenup.h> // Menu pane |
|
28 #include <eikmenub.h> // Menu Bar |
|
29 #include <AknUtils.h> |
|
30 #include <AknQueryDialog.h> |
|
31 |
|
32 #include <locsuplsettingsui.rsg> |
|
33 |
|
34 // User Include |
|
35 #include "locsuplsettings.hrh" |
|
36 #include "locsuplserverview.h" |
|
37 #include "locsuplservercontainer.h" |
|
38 #include "locsettingsui.h" |
|
39 #include "locsuplsettingsuiengine.h" |
|
40 #include "locsupldebug.h" |
|
41 #include "locsuplsettingsview.h" |
|
42 |
|
43 |
|
44 // ========================= MEMBER FUNCTIONS ================================ |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CLocSUPLServerView::CLocSUPLServerView |
|
49 // Overloaded Constructor |
|
50 // |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CLocSUPLServerView::CLocSUPLServerView( |
|
54 CLocSUPLSettingsUiEngine& aEngine, |
|
55 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
56 :iEventHandler( aEventHandler ), |
|
57 iEngine( aEngine ) |
|
58 { |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CLocSUPLServerView::~CLocSUPLServerView |
|
63 // Destructor |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CLocSUPLServerView::~CLocSUPLServerView() |
|
68 { |
|
69 DEBUG( + CLocSUPLServerView::~CLocSUPLServerView ); |
|
70 |
|
71 // deleting the new contaier used to while prioritizing the servers |
|
72 if ( iNewContainer ) |
|
73 { |
|
74 AppUi()->RemoveFromViewStack( *this, iNewContainer ); |
|
75 delete iNewContainer; |
|
76 iNewContainer = NULL; |
|
77 } |
|
78 |
|
79 if ( iContainer ) |
|
80 { |
|
81 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
82 } |
|
83 delete iContainer; |
|
84 iContainer = NULL; |
|
85 DEBUG( - CLocSUPLServerView::~CLocSUPLServerView ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CLocSUPLServerView* CLocSUPLServerView::NewL |
|
90 // Creates new Location Sys Ui plugin. |
|
91 // |
|
92 // @param aEngine Reference to the SUPL Settings |
|
93 // engine |
|
94 // @param aEventHandler Pointer to the Event Handler |
|
95 // @return CAknViewAppUi& Reference to the application view |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CLocSUPLServerView* CLocSUPLServerView::NewL( |
|
99 CLocSUPLSettingsUiEngine& aEngine, |
|
100 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
101 { |
|
102 DEBUG( + CLocSUPLServerView::NewL ); |
|
103 CLocSUPLServerView* self = NewLC( aEngine, aEventHandler ); |
|
104 CleanupStack::Pop( self ); |
|
105 DEBUG( - CLocSUPLServerView::NewL ); |
|
106 return self; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CLocSUPLServerView* CLocSUPLServerView::NewLC |
|
111 // Creates new Location Sys Ui plugin. |
|
112 // |
|
113 // @param aEngine Reference to the SUPL Settings |
|
114 // engine |
|
115 // @param aEventHandler Pointer to the Event Handler |
|
116 // @return CAknViewAppUi& Reference to the application view |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CLocSUPLServerView* CLocSUPLServerView::NewLC( |
|
120 CLocSUPLSettingsUiEngine& aEngine, |
|
121 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
122 { |
|
123 CLocSUPLServerView* self = |
|
124 new( ELeave ) CLocSUPLServerView( aEngine, |
|
125 aEventHandler ); |
|
126 CleanupStack::PushL(self); |
|
127 self->ConstructL(); |
|
128 return self; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // void CLocSUPLServerView::ConstructL |
|
133 // Second Phase Constructor |
|
134 // |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CLocSUPLServerView::ConstructL() |
|
138 { |
|
139 // Call AknView's BaseConstrutL |
|
140 BaseConstructL( R_SUPLSETTINGS_SERVER_VIEW ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CLocSUPLServerView::HandleScreenSizeChange |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CLocSUPLServerView::HandleScreenSizeChange() |
|
148 { |
|
149 if( iContainer ) |
|
150 { |
|
151 iContainer->SetRect( ClientRect()); |
|
152 } |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CLocSUPLServerView::UpdateView |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CLocSUPLServerView::UpdateView() |
|
160 { |
|
161 DEBUG( + CLocSUPLServerView::UpdateView ); |
|
162 if( iContainer ) |
|
163 { |
|
164 TRAP_IGNORE( iContainer->UpdateScreenL() ); |
|
165 } |
|
166 TRAP_IGNORE( ChangeMSKL() ); |
|
167 DEBUG( - CLocSUPLServerView::UpdateView ); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // TInt CLocSUPLServerView::SelectedItemIndex |
|
172 // Returns the Selected element. The list box model defines the enumeration that |
|
173 // would determine the current element that has been selected |
|
174 // |
|
175 // @return TInt Index of the item selected |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CLocSUPLServerView::SelectedItemIndex() |
|
179 { |
|
180 if (iNewContainer) |
|
181 { |
|
182 return iNewContainer->SelectedItemIndex(); |
|
183 } |
|
184 else if( iContainer ) |
|
185 { |
|
186 return iContainer->SelectedItemIndex(); |
|
187 } |
|
188 else |
|
189 { |
|
190 return KErrNotFound; |
|
191 } |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // void CLocSUPLServerView::DoActivateL |
|
196 // |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CLocSUPLServerView::DoActivateL( const TVwsViewId& /* PrevViewId*/, |
|
200 TUid /* aCustomMessageId*/, |
|
201 const TDesC8& /* aCustomMessage */) |
|
202 { |
|
203 DEBUG( + CLocSUPLServerView::DoActivateL ); |
|
204 // Destroy the existing container |
|
205 if( iContainer ) |
|
206 { |
|
207 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
208 delete iContainer; |
|
209 iContainer=NULL; |
|
210 } |
|
211 |
|
212 // Create new Container |
|
213 iContainer = CLocSUPLServerContainer::NewL( ClientRect(), |
|
214 iEngine, |
|
215 this ); |
|
216 iContainer->SetMopParent( this ); |
|
217 AppUi()->AddToViewStackL( *this, iContainer ); |
|
218 MenuBar()->SetContextMenuTitleResourceId( R_SUPLSETTINGS_SERVER_CONTEXTMENUBAR ); |
|
219 ChangeMSKL(); |
|
220 DEBUG( - CLocSUPLServerView::DoActivateL ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // void CLocationSystemUiView::DoDeactivate |
|
225 // |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CLocSUPLServerView::DoDeactivate() |
|
229 { |
|
230 DEBUG( + CLocSUPLServerView::DoDeactivate ); |
|
231 // Destroy Container |
|
232 if ( iContainer ) |
|
233 { |
|
234 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
235 delete iContainer; |
|
236 iContainer = NULL; |
|
237 } |
|
238 DEBUG( - CLocSUPLServerView::DoDeactivate ); |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // TUid CLocSUPLServerView::Id |
|
243 // Returns the View Id. Should be chosen to reflect the Implementation UID |
|
244 // of the Plugin |
|
245 // |
|
246 // @return TUid The View Id |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 TUid CLocSUPLServerView::Id() const |
|
250 { |
|
251 return KLocSUPLServerUiViewId; |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // void CLocSUPLServerView::HandleCommandL |
|
256 // |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CLocSUPLServerView::HandleCommandL( TInt aCommand ) |
|
260 { |
|
261 DEBUG( + CLocSUPLServerView::HandleCommandL ); |
|
262 switch ( aCommand ) |
|
263 { |
|
264 // Handle all the internal view specific commands here |
|
265 case ELocSuplServerOpen: |
|
266 case ELocSuplServerMSKOpen: |
|
267 { |
|
268 iEngine.EditServerL( EFalse, iContainer->CurrentSlpId() ); |
|
269 break; |
|
270 } |
|
271 case ELocSuplServerEnable: |
|
272 case ELocSuplServerMSKEnable: |
|
273 { |
|
274 EnableServerL(); |
|
275 break; |
|
276 } |
|
277 case ELocSuplServerDisable: |
|
278 case ELocSuplServerMSKDisable: |
|
279 { |
|
280 DisableServerL(); |
|
281 break; |
|
282 } |
|
283 case ELocSuplServerNew: |
|
284 { |
|
285 iEngine.EditServerL( ETrue, NULL ); |
|
286 break; |
|
287 } |
|
288 case ELocSuplServerDelete: |
|
289 { |
|
290 iContainer->SetSelectedIndex(); |
|
291 DeleteServerL(); |
|
292 break; |
|
293 } |
|
294 case ELocSuplServerPrioritize: |
|
295 { |
|
296 /** iNewContainer is constructed while prioritizing the servers. |
|
297 * Since the focus cannot be disabled once it is enabled dynamically, thus |
|
298 * prioritizing happens in the new container and the original container is updated. |
|
299 * The iNewContainer is deleted once prioritizing is over. (TC Id: ou1cimx1#219289) |
|
300 **/ |
|
301 if(iNewContainer) |
|
302 { |
|
303 delete iNewContainer; |
|
304 iNewContainer = NULL; |
|
305 } |
|
306 iStartedPrioritize = ETrue; |
|
307 iSelectedIndex = SelectedItemIndex(); |
|
308 |
|
309 iNewContainer = CLocSUPLServerContainer::NewL(ClientRect(), iEngine, this); |
|
310 iNewContainer->SetMopParent( this ); |
|
311 AppUi()->AddToViewStackL( *this, iNewContainer ); |
|
312 MenuBar()->SetContextMenuTitleResourceId( R_SUPLSETTINGS_SERVER_CONTEXTMENUBAR ); |
|
313 iSelectedSlpId = iContainer->CurrentSlpId(); |
|
314 |
|
315 ChangeMSKL(); |
|
316 HandleCommandL( EAknCmdMark ); |
|
317 break; |
|
318 } |
|
319 case EAknSoftkeyOk: |
|
320 { |
|
321 TInt currentIndex = SelectedItemIndex(); |
|
322 if ( currentIndex == iSelectedIndex ) |
|
323 { |
|
324 HandleCommandL( EAknUnmarkAll ); |
|
325 UpdateView(); |
|
326 // deleting the new contaier used to while prioritizing the servers |
|
327 if ( iNewContainer ) |
|
328 { |
|
329 AppUi()->RemoveFromViewStack( *this, iNewContainer ); |
|
330 delete iNewContainer; |
|
331 iNewContainer = NULL; |
|
332 } |
|
333 } |
|
334 else |
|
335 { |
|
336 TBool isIncrease; |
|
337 TInt val; |
|
338 if( currentIndex > iSelectedIndex ) |
|
339 { |
|
340 isIncrease = EFalse; |
|
341 val = currentIndex - iSelectedIndex; |
|
342 } |
|
343 else |
|
344 { |
|
345 isIncrease = ETrue; |
|
346 val = iSelectedIndex - currentIndex; |
|
347 } |
|
348 iEngine.ChangePriorityL( |
|
349 iSelectedSlpId, |
|
350 val, |
|
351 isIncrease ); |
|
352 // deleting the new contaier used to while prioritizing the servers |
|
353 if ( iNewContainer ) |
|
354 { |
|
355 AppUi()->RemoveFromViewStack( *this, iNewContainer ); |
|
356 delete iNewContainer; |
|
357 iNewContainer = NULL; |
|
358 } |
|
359 } |
|
360 break; |
|
361 } |
|
362 case EAknSoftkeyCancel: |
|
363 { |
|
364 ChangeMSKL(); |
|
365 HandleCommandL( EAknUnmarkAll ); |
|
366 // deleting the new contaier used to while prioritizing the servers |
|
367 if ( iNewContainer ) |
|
368 { |
|
369 AppUi()->RemoveFromViewStack( *this, iNewContainer ); |
|
370 delete iNewContainer; |
|
371 iNewContainer = NULL; |
|
372 } |
|
373 break; |
|
374 } |
|
375 case EAknCmdMark: |
|
376 case EAknCmdUnmark: |
|
377 case EAknMarkAll: |
|
378 case EAknUnmarkAll: |
|
379 { |
|
380 // if new container is contructed to prioritize the servers, then mark the item in the new container |
|
381 if(iNewContainer) |
|
382 { |
|
383 //Setting the current item in the new container as same as in the original container. |
|
384 iNewContainer->ListBoxL().SetCurrentItemIndexAndDraw(iContainer->SelectedItemIndex()); |
|
385 AknSelectionService::HandleMarkableListProcessCommandL( |
|
386 aCommand, &( iNewContainer->ListBoxL() ) ); |
|
387 } |
|
388 else |
|
389 { |
|
390 AknSelectionService::HandleMarkableListProcessCommandL( |
|
391 aCommand, &( iContainer->ListBoxL() ) ); |
|
392 } |
|
393 break; |
|
394 } |
|
395 case EAknCmdHelp: |
|
396 { |
|
397 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), |
|
398 AppUi()->AppHelpContextL() ); |
|
399 break; |
|
400 } |
|
401 case EAknCmdExit: |
|
402 case EEikCmdExit: |
|
403 { |
|
404 // The Exit command has to be transferred back to the application |
|
405 iEventHandler.HandleCommandL( EEikCmdExit ); |
|
406 break; |
|
407 } |
|
408 case EAknSoftkeyBack: |
|
409 { |
|
410 // Launch the Settings View |
|
411 TRAP_IGNORE( AppUi()->ActivateLocalViewL ( KLocSUPLSettingsUiViewId ) ); |
|
412 break; |
|
413 } |
|
414 case ELocSuplServerMSKNoCmd: |
|
415 { |
|
416 // No operation will happen |
|
417 break; |
|
418 } |
|
419 default: |
|
420 { |
|
421 // View Switiching, View closure and other external |
|
422 // view related and AppUi related commands |
|
423 iEventHandler.HandleCommandL( aCommand ); |
|
424 break; |
|
425 } |
|
426 } |
|
427 DEBUG( - CLocSUPLServerView::HandleCommandL ); |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CLocSUPLServerView::DynInitMenuPaneL |
|
432 // ----------------------------------------------------------------------------- |
|
433 void CLocSUPLServerView::DynInitMenuPaneL( TInt aResourceId, |
|
434 CEikMenuPane* aMenuPane ) |
|
435 { |
|
436 DEBUG( + CLocSUPLServerView::DynInitMenuPaneL ); |
|
437 AknSelectionService::HandleMarkableListDynInitMenuPane( |
|
438 aResourceId, |
|
439 aMenuPane, |
|
440 &( iContainer->ListBoxL() ) ); |
|
441 switch( aResourceId ) |
|
442 { |
|
443 case R_SUPLSETTINGS_SERVER_MAIN_MENU: |
|
444 { |
|
445 User::LeaveIfNull( aMenuPane ); |
|
446 //Handle Help Fature |
|
447 HandleHelpFeature( *aMenuPane ); |
|
448 break; |
|
449 } |
|
450 case R_SUPLSETTINGS_SERVER_MENU: |
|
451 { |
|
452 User::LeaveIfNull( aMenuPane ); |
|
453 if( iContainer->ServerCount() <= 0 ) |
|
454 { |
|
455 aMenuPane->SetItemDimmed( |
|
456 ELocSuplServerOpen, ETrue ); |
|
457 aMenuPane->SetItemDimmed( |
|
458 ELocSuplServerEnable, ETrue ); |
|
459 aMenuPane->SetItemDimmed( |
|
460 ELocSuplServerDisable, ETrue ); |
|
461 aMenuPane->SetItemDimmed( |
|
462 ELocSuplServerDelete, ETrue ); |
|
463 aMenuPane->SetItemDimmed( |
|
464 ELocSuplServerPrioritize, ETrue ); |
|
465 } |
|
466 else |
|
467 { |
|
468 if ( iContainer->SelectedCount() > 1 ) |
|
469 { |
|
470 aMenuPane->SetItemDimmed( |
|
471 ELocSuplServerOpen, ETrue ); |
|
472 aMenuPane->SetItemDimmed( |
|
473 ELocSuplServerPrioritize, ETrue ); |
|
474 |
|
475 TInt disableCount = SelectedDisabledServerCountL(); |
|
476 if( disableCount == iContainer->SelectedCount() ) |
|
477 { |
|
478 aMenuPane->SetItemDimmed( |
|
479 ELocSuplServerDisable, ETrue ); |
|
480 } |
|
481 else if (disableCount == 0 ) |
|
482 { |
|
483 aMenuPane->SetItemDimmed( |
|
484 ELocSuplServerEnable, ETrue ); |
|
485 } |
|
486 } |
|
487 else |
|
488 { |
|
489 TBool enabledFlag; |
|
490 iEngine.GetServerEnabledFlagL( |
|
491 iContainer->CurrentSlpId(), enabledFlag ); |
|
492 |
|
493 if( enabledFlag ) |
|
494 aMenuPane->SetItemDimmed( |
|
495 ELocSuplServerEnable, ETrue ); |
|
496 else |
|
497 aMenuPane->SetItemDimmed( |
|
498 ELocSuplServerDisable, ETrue ); |
|
499 } |
|
500 |
|
501 if( iContainer->ServerCount() == 1 ) |
|
502 aMenuPane->SetItemDimmed( |
|
503 ELocSuplServerPrioritize, ETrue ); |
|
504 } |
|
505 break; |
|
506 } |
|
507 case R_SUPLSETTINGS_SERVER_CONTEXTMENU: |
|
508 { |
|
509 if( iContainer->ServerCount() <= 0 ) |
|
510 { |
|
511 aMenuPane->SetItemDimmed( |
|
512 ELocSuplServerMSKEnable, ETrue ); |
|
513 aMenuPane->SetItemDimmed( |
|
514 ELocSuplServerMSKDisable, ETrue ); |
|
515 aMenuPane->SetItemDimmed( |
|
516 ELocSuplServerDelete, ETrue ); |
|
517 } |
|
518 else |
|
519 { |
|
520 aMenuPane->SetItemDimmed(ELocSuplServerNew, ETrue); |
|
521 if ( iContainer->SelectedCount() > 0 ) |
|
522 { |
|
523 TInt disableCount = SelectedDisabledServerCountL(); |
|
524 if( disableCount == iContainer->SelectedCount() ) |
|
525 { |
|
526 aMenuPane->SetItemDimmed( |
|
527 ELocSuplServerMSKDisable, ETrue ); |
|
528 } |
|
529 else if (disableCount == 0 ) |
|
530 { |
|
531 aMenuPane->SetItemDimmed( |
|
532 ELocSuplServerMSKEnable, ETrue ); |
|
533 } |
|
534 } |
|
535 else |
|
536 { |
|
537 TBool enabledFlag; |
|
538 iEngine.GetServerEnabledFlagL( iContainer->CurrentSlpId(), enabledFlag ); |
|
539 if( enabledFlag ) |
|
540 aMenuPane->SetItemDimmed( |
|
541 ELocSuplServerMSKEnable, ETrue ); |
|
542 else |
|
543 aMenuPane->SetItemDimmed( |
|
544 ELocSuplServerMSKDisable, ETrue ); |
|
545 } |
|
546 } |
|
547 break; |
|
548 } |
|
549 default: |
|
550 { |
|
551 break; |
|
552 } |
|
553 } |
|
554 DEBUG( - CLocSUPLServerView::DynInitMenuPaneL ); |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CLocSUPLServerView::HandleHelpFeature |
|
559 // ----------------------------------------------------------------------------- |
|
560 void CLocSUPLServerView::HandleHelpFeature( CEikMenuPane& aMenuPane ) const |
|
561 { |
|
562 DEBUG( + CLocSUPLServerView::HandleHelpFeature ); |
|
563 if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
564 { |
|
565 aMenuPane.SetItemDimmed( EAknCmdHelp, EFalse ); |
|
566 } |
|
567 else |
|
568 { |
|
569 aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue ); |
|
570 } |
|
571 DEBUG( - CLocSUPLServerView::HandleHelpFeature ); |
|
572 } |
|
573 |
|
574 // ----------------------------------------------------------------------------- |
|
575 // CLocSUPLServerView::DeletionConfirmationQueryL |
|
576 // ---------------------------------------------------------------------------- |
|
577 // |
|
578 TInt CLocSUPLServerView::DeletionConfirmationQueryL( const TInt aAmount ) |
|
579 { |
|
580 HBufC* noteText = NULL; |
|
581 if ( aAmount > 1 ) |
|
582 { |
|
583 noteText = StringLoader::LoadL( R_LOC_DETAIL_CONF_DELETE_SERVERS, aAmount, iEikonEnv ); |
|
584 } |
|
585 else |
|
586 { |
|
587 noteText = StringLoader::LoadL( R_LOC_DETAIL_CONF_DELETE_SERVER, iEikonEnv ); |
|
588 } |
|
589 CAknQueryDialog* query = new( ELeave ) CAknQueryDialog( *noteText ); |
|
590 TInt ret = query->ExecuteLD( R_LOC_SUPL_DELETE_QUERY ); |
|
591 delete noteText; //noteText |
|
592 noteText = NULL; |
|
593 return ret; |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CLocSUPLServerView::DeleteServerL |
|
598 // ---------------------------------------------------------------------------- |
|
599 // |
|
600 void CLocSUPLServerView::DeleteServerL() |
|
601 { |
|
602 DEBUG( + CLocSUPLServerView::DeleteServerL ); |
|
603 TInt selCount = iContainer->SelectedCount(); |
|
604 TInt severCount = iContainer->ServerCount(); |
|
605 if( DeletionConfirmationQueryL( selCount ) ) |
|
606 { |
|
607 if ( selCount < 1 && severCount > 0 ) |
|
608 { |
|
609 TRAP_IGNORE( iEngine.RemoveServerL( iContainer->CurrentSlpId() ) ); |
|
610 } |
|
611 else |
|
612 { |
|
613 const CArrayFix<TInt>* markedIndexes = NULL; |
|
614 markedIndexes = iContainer->ListBoxL().SelectionIndexes(); |
|
615 |
|
616 RArray<TInt64> markedItemIds; |
|
617 GetSelectedItemIdsL( markedItemIds, *markedIndexes ); |
|
618 |
|
619 for( TInt ctr = 0; ctr < selCount; ctr++ ) |
|
620 { |
|
621 TRAP_IGNORE( iEngine.RemoveServerL( markedItemIds[ ctr ] ) ); |
|
622 } |
|
623 markedItemIds.Close(); |
|
624 } |
|
625 } |
|
626 DEBUG( - CLocSUPLServerView::DeleteServerL ); |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CLocSUPLServerView::DisableServerL |
|
631 // ---------------------------------------------------------------------------- |
|
632 // |
|
633 void CLocSUPLServerView::DisableServerL() |
|
634 { |
|
635 DEBUG( + CLocSUPLServerView::DisableServerL ); |
|
636 TInt selCount = iContainer->SelectedCount(); |
|
637 TInt severCount = iContainer->ServerCount(); |
|
638 |
|
639 if ( selCount < 1 && severCount > 0 ) |
|
640 { |
|
641 iEngine.SetServerEnabledFlagL( iContainer->CurrentSlpId(), EFalse ); |
|
642 } |
|
643 else |
|
644 { |
|
645 const CArrayFix<TInt>* markedIndexes = NULL; |
|
646 markedIndexes = iContainer->ListBoxL().SelectionIndexes(); |
|
647 |
|
648 RArray<TInt64> markedItemIds; |
|
649 GetSelectedItemIdsL( markedItemIds, *markedIndexes ); |
|
650 |
|
651 for( TInt ctr = 0; ctr < selCount; ctr++ ) |
|
652 { |
|
653 iEngine.SetServerEnabledFlagL( markedItemIds[ ctr ], EFalse ); |
|
654 } |
|
655 markedItemIds.Close(); |
|
656 } |
|
657 DEBUG( - CLocSUPLServerView::DisableServerL ); |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CLocSUPLServerView::EnableServerL |
|
662 // ---------------------------------------------------------------------------- |
|
663 // |
|
664 void CLocSUPLServerView::EnableServerL() |
|
665 { |
|
666 DEBUG( + CLocSUPLServerView::EnableServerL ); |
|
667 TInt selCount = iContainer->SelectedCount(); |
|
668 TInt severCount = iContainer->ServerCount(); |
|
669 |
|
670 if ( selCount < 1 && severCount > 0 ) |
|
671 { |
|
672 iEngine.SetServerEnabledFlagL( iContainer->CurrentSlpId(), ETrue ); |
|
673 } |
|
674 else |
|
675 { |
|
676 const CArrayFix<TInt>* markedIndexes = NULL; |
|
677 markedIndexes = iContainer->ListBoxL().SelectionIndexes(); |
|
678 |
|
679 RArray<TInt64> markedItemIds; |
|
680 GetSelectedItemIdsL( markedItemIds, *markedIndexes ); |
|
681 |
|
682 for( TInt ctr = 0; ctr < selCount; ctr++ ) |
|
683 { |
|
684 iEngine.SetServerEnabledFlagL( markedItemIds[ ctr ], ETrue ); |
|
685 } |
|
686 markedItemIds.Close(); |
|
687 } |
|
688 DEBUG( - CLocSUPLServerView::EnableServerL ); |
|
689 } |
|
690 |
|
691 // ----------------------------------------------------------------------------- |
|
692 // CLocSUPLServerView::ChangeMSKL |
|
693 // ----------------------------------------------------------------------------- |
|
694 // |
|
695 void CLocSUPLServerView::ChangeMSKL() |
|
696 { |
|
697 DEBUG( + CLocSUPLServerView::ChangeMSKL ); |
|
698 // Listbox takes all event even if it doesn't use them |
|
699 if( !Cba() ) |
|
700 { |
|
701 return; |
|
702 } |
|
703 if( iEngine.SlpCount() <= 0 ) |
|
704 { |
|
705 TRAP_IGNORE( |
|
706 Cba()->SetCommandSetL ( R_SUPLSETTINGS_SERVER_OPTIONS_BACK ) ); |
|
707 } |
|
708 else if( iStartedPrioritize ) |
|
709 { |
|
710 //ou1cimx1#352684. to disable first item flicker |
|
711 iNewContainer->ListBoxL().SetCurrentItemIndex(iSelectedIndex); |
|
712 iNewContainer->ListBoxL().DisableSingleClick(ETrue); |
|
713 iStartedPrioritize = EFalse; |
|
714 TRAP_IGNORE( |
|
715 Cba()->SetCommandSetL ( R_SUPLSETTINGS_SERVER_OK_CANCEL ) ); |
|
716 } |
|
717 else |
|
718 { |
|
719 TRAP_IGNORE( |
|
720 Cba()->SetCommandSetL ( R_SUPLSETTINGS_OPTIONS_CONTEXTOPTIONS_BACK ) ); |
|
721 } |
|
722 |
|
723 Cba()->DrawDeferred(); |
|
724 DEBUG( - CLocSUPLServerView::ChangeMSKL ); |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CLocSUPLServerView::GetSelectedItemIdsL |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 void CLocSUPLServerView::GetSelectedItemIdsL( |
|
732 RArray<TInt64>& aSelectedItems, |
|
733 const CArrayFix<TInt>& aSelectedIndexes ) const |
|
734 { |
|
735 aSelectedItems.Reset(); |
|
736 TInt itemCount = iContainer->ServerCount(); |
|
737 TInt selectionCount = aSelectedIndexes.Count(); |
|
738 for ( TInt i( 0 ); i < selectionCount; ++i ) |
|
739 { |
|
740 TInt index = aSelectedIndexes[i]; |
|
741 User::LeaveIfError( aSelectedItems.Append( iContainer->SlpIds()[index] ) ); |
|
742 } |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CLocSUPLServerView::SelectedDisabledServerCountL |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 TInt CLocSUPLServerView::SelectedDisabledServerCountL() |
|
750 { |
|
751 const CArrayFix<TInt>* markedIndexes = NULL; |
|
752 markedIndexes = iContainer->ListBoxL().SelectionIndexes(); |
|
753 |
|
754 RArray<TInt64> markedItemIds; |
|
755 GetSelectedItemIdsL( markedItemIds, *markedIndexes ); |
|
756 |
|
757 TInt disabledServerCount( 0 ); |
|
758 for( TInt i( 0 ); i < markedItemIds.Count(); ++i ) |
|
759 { |
|
760 TBool enabledFlag; |
|
761 iEngine.GetServerEnabledFlagL( markedItemIds[i], enabledFlag ); |
|
762 if( !enabledFlag ) |
|
763 disabledServerCount++; |
|
764 } |
|
765 return disabledServerCount; |
|
766 } |
|
767 |
|
768 // End of file |
|