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: Source file for SUPL Settings 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 <locsuplsettingsui.rsg> |
|
25 #include <avkon.rsg> |
|
26 #include <hlplch.h> // Help |
|
27 #include <featmgr.h> // FeatureManager |
|
28 #include <eikmenup.h> // Menu pane |
|
29 #include <eikmenub.h> // Menu Bar |
|
30 #include <AknQueryDialog.h> |
|
31 |
|
32 // User Include |
|
33 #include "locsuplsettings.hrh" |
|
34 #include "locsuplsettingsview.h" |
|
35 #include "locsuplsettingscontainer.h" |
|
36 #include "locsettingsui.h" |
|
37 #include "locsupldebug.h" |
|
38 #include "locsuplserverview.h" |
|
39 #include "locsuplsessionview.h" |
|
40 #include "locsuplsettingsuiengine.h" |
|
41 |
|
42 // ========================= MEMBER FUNCTIONS ================================ |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CLocSUPLSettingsView::CLocSUPLSettingsView |
|
47 // Overloaded Constructor |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CLocSUPLSettingsView::CLocSUPLSettingsView( |
|
52 CLocSUPLSettingsUiEngine& aEngine, |
|
53 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
54 :iEventHandler( aEventHandler ), |
|
55 iEngine( aEngine ) |
|
56 { |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CLocSUPLSettingsView::~CLocSUPLSettingsView |
|
61 // Destructor |
|
62 // |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CLocSUPLSettingsView::~CLocSUPLSettingsView() |
|
66 { |
|
67 DEBUG( + CLocSUPLSettingsView::~CLocSUPLSettingsView ); |
|
68 if ( iContainer ) |
|
69 { |
|
70 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
71 } |
|
72 |
|
73 delete iContainer; |
|
74 iContainer = NULL; |
|
75 DEBUG( - CLocSUPLSettingsView::~CLocSUPLSettingsView ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CLocSUPLSettingsView* CLocSUPLSettingsView::NewL |
|
80 // Creates new Location Sys Ui plugin. |
|
81 // |
|
82 // @param aEngine Reference to the SUPL Settings |
|
83 // engine |
|
84 // @param aEventHandler Pointer to the Event Handler |
|
85 // @return CAknViewAppUi& Reference to the application view |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 CLocSUPLSettingsView* CLocSUPLSettingsView::NewL( |
|
89 CLocSUPLSettingsUiEngine& aEngine, |
|
90 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
91 { |
|
92 DEBUG( + CLocSUPLSettingsView::NewL ); |
|
93 CLocSUPLSettingsView* self = NewLC( aEngine, aEventHandler ); |
|
94 CleanupStack::Pop( self ); |
|
95 DEBUG( - CLocSUPLSettingsView::NewL ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CLocSUPLSettingsView* CLocSUPLSettingsView::NewLC |
|
101 // Creates new Location Sys Ui plugin. |
|
102 // |
|
103 // @param aEngine Reference to the SUPL Settings |
|
104 // engine |
|
105 // @param aEventHandler Pointer to the Event Handler |
|
106 // @return CAknViewAppUi& Reference to the application view |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CLocSUPLSettingsView* CLocSUPLSettingsView::NewLC( |
|
110 CLocSUPLSettingsUiEngine& aEngine, |
|
111 MLocSUPLSettingsEventHandler& aEventHandler ) |
|
112 { |
|
113 CLocSUPLSettingsView* self = |
|
114 new( ELeave ) CLocSUPLSettingsView( aEngine, |
|
115 aEventHandler ); |
|
116 CleanupStack::PushL(self); |
|
117 self->ConstructL(); |
|
118 return self; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // void CLocSUPLSettingsView::ConstructL |
|
123 // Second Phase Constructor |
|
124 // |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void CLocSUPLSettingsView::ConstructL() |
|
128 { |
|
129 DEBUG( + CLocSUPLSettingsView::ConstructL ); |
|
130 // Call AknView's BaseConstrutL |
|
131 BaseConstructL( R_SUPLSETTINGS_VIEW ); |
|
132 DEBUG( - CLocSUPLSettingsView::ConstructL ); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CLocSUPLSettingsView::HandleScreenSizeChange |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CLocSUPLSettingsView::HandleScreenSizeChange() |
|
140 { |
|
141 DEBUG( + CLocSUPLSettingsView::HandleScreenSizeChange ); |
|
142 if( iContainer ) |
|
143 { |
|
144 iContainer->SetRect( ClientRect()); |
|
145 } |
|
146 DEBUG( - CLocSUPLSettingsView::HandleScreenSizeChange ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CLocSUPLSettingsView::UpdateView |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CLocSUPLSettingsView::UpdateView() |
|
154 { |
|
155 DEBUG( + CLocSUPLSettingsView::UpdateView ); |
|
156 if( iContainer ) |
|
157 { |
|
158 iContainer->UpdateScreen(); |
|
159 } |
|
160 TRAP_IGNORE( ChangeMSKL() ); |
|
161 DEBUG( - CLocSUPLSettingsView::UpdateView ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CLocSUPLSettingsView::StartedFromAppServer |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CLocSUPLSettingsView::StartedFromAppServer() |
|
169 { |
|
170 DEBUG( + CLocSUPLSettingsView::StartedFromAppServer ); |
|
171 iStartedFromServer = ETrue; |
|
172 DEBUG( - CLocSUPLSettingsView::StartedFromAppServer ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CLocSUPLSettingsView::SwitchedFromServerView |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CLocSUPLSettingsView::Reset() |
|
180 { |
|
181 DEBUG( + CLocSUPLSettingsView::Reset ); |
|
182 iViewLaunched = 0; |
|
183 StopDisplayingMenuBar(); |
|
184 DEBUG( - CLocSUPLSettingsView::Reset ); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // TInt CLocSUPLSettingsView::SelectedItemIndex |
|
189 // Returns the Selected element. The list box model defines the enumeration that |
|
190 // would determine the current element that has been selected |
|
191 // |
|
192 // @return TInt Index of the item selected |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CLocSUPLSettingsView::SelectedItemIndex() |
|
196 { |
|
197 DEBUG( CLocSUPLSettingsView::SelectedItemIndex ); |
|
198 if( iContainer ) |
|
199 { |
|
200 DEBUG1( CLocSUPLSettingsView::SelectedItemIndex =%d, iContainer->SelectedItemIndex() ); |
|
201 return iContainer->SelectedItemIndex(); |
|
202 } |
|
203 else |
|
204 { |
|
205 return KErrNotFound; |
|
206 } |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // void CLocSUPLSettingsView::DoActivateL |
|
211 // |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CLocSUPLSettingsView::DoActivateL( const TVwsViewId& /* PrevViewId*/, |
|
215 TUid /* aCustomMessageId*/, |
|
216 const TDesC8& /* aCustomMessage */) |
|
217 { |
|
218 DEBUG( + CLocSUPLSettingsView::DoActivateL ); |
|
219 // Destroy the existing container |
|
220 if( iContainer ) |
|
221 { |
|
222 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
223 delete iContainer; |
|
224 iContainer=NULL; |
|
225 } |
|
226 |
|
227 // Create new Container |
|
228 iContainer = CLocSUPLSettingsContainer::NewL( ClientRect(), |
|
229 iEngine, |
|
230 *this ); |
|
231 iContainer->SetMopParent( this ); |
|
232 AppUi()->AddToViewStackL( *this, iContainer ); |
|
233 |
|
234 if ( iStartedFromServer ) |
|
235 { |
|
236 MenuBar()->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper ); |
|
237 } |
|
238 |
|
239 if( iViewLaunched ) |
|
240 { |
|
241 iContainer->FocusToItemL( iViewLaunched ); |
|
242 iViewLaunched = 0; |
|
243 } |
|
244 iContainer->DrawNow(); |
|
245 ChangeMSKL(); |
|
246 DEBUG( - CLocSUPLSettingsView::DoActivateL ); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // void CLocationSystemUiView::DoDeactivate |
|
251 // |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void CLocSUPLSettingsView::DoDeactivate() |
|
255 { |
|
256 DEBUG( + CLocSUPLSettingsView::DoDeactivate ); |
|
257 // Destroy Container |
|
258 if ( iContainer ) |
|
259 { |
|
260 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
261 delete iContainer; |
|
262 iContainer = NULL; |
|
263 } |
|
264 DEBUG( - CLocSUPLSettingsView::DoDeactivate ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // TUid CLocSUPLSettingsView::Id |
|
269 // Returns the View Id. Should be chosen to reflect the Implementation UID |
|
270 // of the Plugin |
|
271 // |
|
272 // @return TUid The View Id |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 TUid CLocSUPLSettingsView::Id() const |
|
276 { |
|
277 return KLocSUPLSettingsUiViewId; |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // void CLocSUPLSettingsView::HandleCommandL |
|
282 // |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 void CLocSUPLSettingsView::HandleCommandL(TInt aCommand) |
|
286 { |
|
287 DEBUG( + CLocSUPLSettingsView::HandleCommandL ); |
|
288 switch ( aCommand ) |
|
289 { |
|
290 case ELocSuplOpenChange: |
|
291 { |
|
292 ChangeMSKL(); |
|
293 break; |
|
294 } |
|
295 // Handle all the internal view specific commands here |
|
296 case ELocSuplChange: |
|
297 case ELocSuplMSKChange: |
|
298 { |
|
299 // Launch the SUPL Settings usage configurator. |
|
300 // The error code is ignored since the necessary UI |
|
301 // notification would be convveyed by the Engine |
|
302 TRAP_IGNORE( iEngine.LaunchSuplUsageConfiguratorL() ); |
|
303 break; |
|
304 } |
|
305 case ELocSuplOpen: |
|
306 case ELocSuplMSKOpen: |
|
307 { |
|
308 TInt index = SelectedItemIndex(); |
|
309 switch( index ) |
|
310 { |
|
311 case 1: |
|
312 { |
|
313 // Launch the Supl Server List. |
|
314 // The error code is ignored since the necessary UI |
|
315 // notification would be convveyed by the Engine |
|
316 iViewLaunched = 1; |
|
317 TRAP_IGNORE( AppUi()->ActivateLocalViewL ( KLocSUPLServerUiViewId ) ); |
|
318 break; |
|
319 } |
|
320 case 2: |
|
321 { |
|
322 TInt sessionCount = iContainer->ActiveSessionCount(); |
|
323 if( sessionCount ) |
|
324 { |
|
325 iViewLaunched = 2; |
|
326 // Launch the Supl sessions view. |
|
327 TRAP_IGNORE( AppUi()->ActivateLocalViewL ( KLocSUPLSessionUiViewId ) ); |
|
328 } |
|
329 break; |
|
330 } |
|
331 default: |
|
332 break; |
|
333 } |
|
334 break; |
|
335 } |
|
336 case ELocSuplClearSession: |
|
337 case ELocSuplClearSessions: |
|
338 { |
|
339 if( iContainer->ActiveSessionCount() && DeletionConfirmationQueryL() ) |
|
340 { |
|
341 TRAP_IGNORE( iEngine.RemoveAllTriggerSessionsL( ) ); |
|
342 ChangeMSKL(); |
|
343 } |
|
344 break; |
|
345 } |
|
346 case ELocSuplMSKNo: |
|
347 { |
|
348 break; |
|
349 } |
|
350 case EAknCmdHelp: |
|
351 { |
|
352 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), |
|
353 AppUi()->AppHelpContextL()); |
|
354 break; |
|
355 } |
|
356 case EAknCmdExit: |
|
357 case EEikCmdExit: |
|
358 { |
|
359 // The Exit command has to be transferred back to the application |
|
360 iEventHandler.HandleCommandL( EEikCmdExit ); |
|
361 break; |
|
362 } |
|
363 case EAknSoftkeyBack: |
|
364 { |
|
365 // Back command is left to the Settings UI which is the command handler |
|
366 // in this case to handle |
|
367 iEventHandler.HandleCommandL( EAknSoftkeyBack ); |
|
368 break; |
|
369 } |
|
370 default: |
|
371 { |
|
372 // View Switiching, View closure and other external |
|
373 // view related and AppUi related commands |
|
374 iEventHandler.HandleCommandL( aCommand ); |
|
375 break; |
|
376 } |
|
377 } |
|
378 DEBUG( - CLocSUPLSettingsView::HandleCommandL ); |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CLocSUPLSettingsView::ChangeMSKL |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CLocSUPLSettingsView::ChangeMSKL() |
|
386 { |
|
387 DEBUG( + CLocSUPLSettingsView::ChangeMSKL ); |
|
388 // Listbox takes all event even if it doesn't use them |
|
389 if( !Cba() || !iContainer ) |
|
390 { |
|
391 return; |
|
392 } |
|
393 |
|
394 TInt index = SelectedItemIndex(); |
|
395 TInt sessionCount = iContainer->ActiveSessionCount(); |
|
396 switch( index ) |
|
397 { |
|
398 case 0: |
|
399 { |
|
400 TRAP_IGNORE( |
|
401 Cba()->SetCommandSetL ( R_SUPLSETTINGS_OPTIONS_CHANGE_BACK ) ); |
|
402 break; |
|
403 } |
|
404 case 1: |
|
405 { |
|
406 TRAP_IGNORE( |
|
407 Cba()->SetCommandSetL ( R_SUPLSETTINGS_OPTIONS_OPEN_BACK ) ); |
|
408 break; |
|
409 } |
|
410 default: |
|
411 { |
|
412 if( sessionCount ) |
|
413 { |
|
414 TRAP_IGNORE( |
|
415 Cba()->SetCommandSetL ( R_SUPLSETTINGS_OPTIONS_OPEN_BACK ) ); |
|
416 } |
|
417 else |
|
418 { |
|
419 TRAP_IGNORE( |
|
420 Cba()->SetCommandSetL ( R_SUPLSETTINGS_OPTIONS_NOMSK_BACK ) ); |
|
421 } |
|
422 break; |
|
423 } |
|
424 } |
|
425 Cba()->DrawDeferred(); |
|
426 DEBUG( - CLocSUPLSettingsView::ChangeMSKL ); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CLocSUPLSettingsView::DynInitMenuPaneL |
|
431 // ----------------------------------------------------------------------------- |
|
432 void CLocSUPLSettingsView::DynInitMenuPaneL( TInt aResourceId, |
|
433 CEikMenuPane* aMenuPane ) |
|
434 { |
|
435 DEBUG( + CLocSUPLSettingsView::DynInitMenuPaneL ); |
|
436 if ( aResourceId == R_SUPLSETTINGS_MENU ) |
|
437 { |
|
438 User::LeaveIfNull( aMenuPane ); |
|
439 //Handle Help Fature |
|
440 HandleHelpFeature( *aMenuPane ); |
|
441 |
|
442 //Disable Open/Change/Clear sessions options |
|
443 switch( SelectedItemIndex() ) |
|
444 { |
|
445 case 0: |
|
446 { |
|
447 //aMenuPane->SetItemDimmed( ELocSuplChange, EFalse ); |
|
448 //aMenuPane->SetItemDimmed( ELocSuplOpen, ETrue ); |
|
449 aMenuPane->SetItemDimmed( ELocSuplClearSession, ETrue ); |
|
450 aMenuPane->SetItemDimmed( ELocSuplClearSessions, ETrue ); |
|
451 break; |
|
452 } |
|
453 case 1: |
|
454 { |
|
455 //aMenuPane->SetItemDimmed( ELocSuplChange, ETrue ); |
|
456 //aMenuPane->SetItemDimmed( ELocSuplOpen, EFalse ); |
|
457 aMenuPane->SetItemDimmed( ELocSuplClearSession, ETrue ); |
|
458 aMenuPane->SetItemDimmed( ELocSuplClearSessions, ETrue ); |
|
459 break; |
|
460 } |
|
461 case 2: |
|
462 { |
|
463 aMenuPane->SetItemDimmed( ELocSuplChange, ETrue ); |
|
464 TInt sessionCount = iContainer->ActiveSessionCount(); |
|
465 |
|
466 switch( sessionCount ) |
|
467 { |
|
468 case 0: |
|
469 { |
|
470 //aMenuPane->SetItemDimmed( ELocSuplOpen, ETrue ); |
|
471 aMenuPane->SetItemDimmed( ELocSuplClearSession, ETrue ); |
|
472 aMenuPane->SetItemDimmed( ELocSuplClearSessions, ETrue ); |
|
473 break; |
|
474 } |
|
475 case 1: |
|
476 { |
|
477 //aMenuPane->SetItemDimmed( ELocSuplOpen, EFalse ); |
|
478 aMenuPane->SetItemDimmed( ELocSuplClearSession, EFalse ); |
|
479 aMenuPane->SetItemSpecific(ELocSuplClearSession, ETrue); |
|
480 aMenuPane->SetItemDimmed( ELocSuplClearSessions, ETrue ); |
|
481 break; |
|
482 } |
|
483 default: |
|
484 { |
|
485 //aMenuPane->SetItemDimmed( ELocSuplOpen, EFalse ); |
|
486 aMenuPane->SetItemDimmed( ELocSuplClearSession, ETrue ); |
|
487 aMenuPane->SetItemDimmed( ELocSuplClearSessions, EFalse ); |
|
488 aMenuPane->SetItemSpecific(ELocSuplClearSessions, ETrue); |
|
489 break; |
|
490 } |
|
491 } |
|
492 break; |
|
493 } |
|
494 default: |
|
495 break; |
|
496 } |
|
497 //Context sensitive menu items |
|
498 } |
|
499 DEBUG( - CLocSUPLSettingsView::DynInitMenuPaneL ); |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CLocSUPLSettingsView::HandleHelpFeature |
|
504 // ----------------------------------------------------------------------------- |
|
505 void CLocSUPLSettingsView::HandleHelpFeature( CEikMenuPane& aMenuPane ) const |
|
506 { |
|
507 DEBUG( + CLocSUPLSettingsView::HandleHelpFeature ); |
|
508 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
509 { |
|
510 aMenuPane.SetItemDimmed( EAknCmdHelp, EFalse ); |
|
511 } |
|
512 else |
|
513 { |
|
514 aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue ); |
|
515 } |
|
516 DEBUG( - CLocSUPLSettingsView::HandleHelpFeature ); |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CLocSUPLSettingsView::DeletionConfirmationQueryL |
|
521 // ---------------------------------------------------------------------------- |
|
522 // |
|
523 TInt CLocSUPLSettingsView::DeletionConfirmationQueryL( ) |
|
524 { |
|
525 HBufC* noteText = NULL; |
|
526 noteText = StringLoader::LoadLC( R_LOC_SUPL_QUERY_TERMINATE_ALL, iEikonEnv ); |
|
527 CAknQueryDialog* query = new( ELeave ) CAknQueryDialog( *noteText ); |
|
528 TInt ret = query->ExecuteLD( R_LOC_SUPL_DELETE_QUERY ); |
|
529 CleanupStack::PopAndDestroy( noteText ); |
|
530 return ret; |
|
531 } |
|
532 |
|
533 #if 0 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // CLocSUPLSettingsView::IsActive |
|
536 // ----------------------------------------------------------------------------- |
|
537 TBool CLocSUPLSettingsView::IsActive() |
|
538 { |
|
539 if( iContainer ) |
|
540 { |
|
541 return ETrue; |
|
542 } |
|
543 else |
|
544 { |
|
545 return EFalse; |
|
546 } |
|
547 } |
|
548 |
|
549 #endif |
|
550 |
|
551 // End of file |
|