1 /* |
|
2 * Copyright (c) 2005-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 Location System UI view. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // System Include |
|
21 #include <barsread.h> // For TResourceReader |
|
22 #include <featmgr.h> // FeatureManager |
|
23 #include <bautils.h> |
|
24 #include <StringLoader.h> // String Loader |
|
25 #include <aknViewAppUi.h> // App Ui |
|
26 #include <hlplch.h> // Help |
|
27 #include <gulicon.h> // Gul Icon |
|
28 #include <eikmenup.h> // Menu pane |
|
29 #include <eikmenub.h> // Menu Bar |
|
30 #include <bldvariant.hrh> // KFeatureHelpId |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <locsysuiviewrsc.rsg> |
|
33 #include <locsysuiview.mbg> |
|
34 |
|
35 // User Include |
|
36 #include "locsysuiview.hrh" |
|
37 #include "locsysuiview.h" |
|
38 #include "locsysuicontainer.h" |
|
39 #include "locationsettings.h" |
|
40 #include "locsettingsuiengine.h" |
|
41 #include "locsettingsuiclient.h" |
|
42 #include "locpossettings.h" |
|
43 |
|
44 // Literal Definitions |
|
45 _LIT( KLocationSystemUiViewIconFileName, "\\resource\\apps\\locsysuiview.mif" ); |
|
46 |
|
47 // ========================= MEMBER FUNCTIONS ================================ |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CLocSysUiView::CLocSysUiView |
|
52 // Overloaded Constructor |
|
53 // |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CLocSysUiView::CLocSysUiView() |
|
57 :iResourceLoader( *CCoeEnv::Static()) |
|
58 { |
|
59 |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CLocSysUiView::~CLocSysUiView |
|
64 // Destructor |
|
65 // |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CLocSysUiView::~CLocSysUiView() |
|
69 { |
|
70 // Delete the View engine |
|
71 delete iEngine; |
|
72 |
|
73 // Close the Resource loader |
|
74 iResourceLoader.Close(); |
|
75 |
|
76 // Release all the resources associated with Feature Manager |
|
77 FeatureManager::UnInitializeLib(); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CLocSysUiView* CLocSysUiView::NewL |
|
82 // Creates new Location Sys Ui plugin. Internally calls NewLC |
|
83 // |
|
84 // @return CLocSysUiView* Reference to the application view |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C CLocSysUiView* CLocSysUiView::NewL() |
|
88 { |
|
89 CLocSysUiView* self = CLocSysUiView::NewLC(); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CLocSysUiView* CLocSysUiView::NewLC |
|
96 // Creates new Location Sys Ui plugin. Leaves the object on the Cleanup stack |
|
97 // |
|
98 // @return CLocSysUiView* Reference to the application view |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CLocSysUiView* CLocSysUiView::NewLC() |
|
102 { |
|
103 CLocSysUiView* self = new (ELeave) CLocSysUiView(); |
|
104 CleanupStack::PushL( self ); |
|
105 self->ConstructL(); |
|
106 return self; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // void CLocSysUiView::ConstructL |
|
111 // Second Phase Constructor |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CLocSysUiView::ConstructL() |
|
116 { |
|
117 // Initialize the Feature Manager library |
|
118 FeatureManager::InitializeLibL(); |
|
119 |
|
120 if ( FeatureManager::FeatureSupported( KFeatureIdFfLocationsysuiHidePositioningMenu ) ) |
|
121 { |
|
122 // To Do : changes for ou1cimx1#228781 Location: Positioning view does not open |
|
123 // Commenting the leaving part as the hide positioning feature flag is get enabled for all configuration by default |
|
124 // so till the flag issue resolved, the leaving part will be commented as this issue affected the BAT. |
|
125 // User::Leave( KErrNotSupported ); |
|
126 } |
|
127 |
|
128 // Open the Resource File |
|
129 OpenLocalizedResourceFileL( KLocSysUiViewResFileName, iResourceLoader ); |
|
130 |
|
131 // Call AknView's BaseConstrutL |
|
132 BaseConstructL( R_LOCSYSUIVIEW_APP_VIEW ); |
|
133 |
|
134 // Create the View Engine |
|
135 iEngine = CLocSettingsUiEngine::NewL( *AppUi()); |
|
136 |
|
137 // Load all the plug-ins. The creation of the engine does not load the |
|
138 // plugins and they have to be explicitly loaded. The return value need |
|
139 // not be stored here. Hence, the value is ignored |
|
140 iEngine->CreateAvailableSettingsUiL(); |
|
141 |
|
142 } |
|
143 |
|
144 EXPORT_C void CLocSysUiView::LaunchedfromPosSettingsApp() |
|
145 { |
|
146 isLaunchedFromPosSettingsApp = ETrue; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // void CLocSysUiView::HandleClientRectChange |
|
151 // |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void CLocSysUiView::HandleClientRectChange() |
|
155 { |
|
156 if ( iContainer ) |
|
157 { |
|
158 iContainer->SetRect( ClientRect()); |
|
159 } |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // void CLocSysUiView::ActivateView |
|
164 // |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CLocSysUiView::ActivateViewL() |
|
168 { |
|
169 // Activate the Current view in the default mode. |
|
170 AppUi()->ActivateLocalViewL(Id()); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // void CLocSysUiView::DeActivateView |
|
175 // |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CLocSysUiView::DeActivateView() |
|
179 { |
|
180 |
|
181 // Close all the sub-settings views if they are Open |
|
182 // Retrieve the Settings Description Array |
|
183 RPointerArray<CLocationSettings>& settingsArray = iEngine->SettingsUiArray(); |
|
184 |
|
185 for( TInt i = 0; i < settingsArray.Count(); i ++ ) |
|
186 { |
|
187 // Retrieve each settings UI |
|
188 CLocationSettings* settings = settingsArray[i]; |
|
189 |
|
190 // Close the Settings UI |
|
191 settings->Close(); |
|
192 } |
|
193 // Stop displaying the Menubar if its being displayed. |
|
194 StopDisplayingMenuBar(); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // void CLocSysUiView::SetObserver |
|
199 // |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CLocSysUiView::SetObserver( MLocationUIObserver* aObserver ) |
|
203 { |
|
204 iObserver = aObserver; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // void CLocSysUiView::DoActivateL |
|
209 // |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CLocSysUiView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
213 TUid /* aCustomMessageId*/, |
|
214 const TDesC8& /* aCustomMessage */ ) |
|
215 { |
|
216 if ( !iSettingsUiDismissalPending ) |
|
217 { |
|
218 // Assign the previous view Id |
|
219 iPrevViewId = aPrevViewId; |
|
220 |
|
221 // Set the Highlighted item to 0 |
|
222 iHighlightedIndex = 0; |
|
223 } |
|
224 else |
|
225 { |
|
226 iSettingsUiDismissalPending = EFalse; |
|
227 } |
|
228 |
|
229 // Destroy the existing container if it exists |
|
230 if ( iContainer ) |
|
231 { |
|
232 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
233 delete iContainer; |
|
234 iContainer=NULL; |
|
235 } |
|
236 |
|
237 // Retrieve the Settings Description Array |
|
238 RPointerArray<CLocationSettings>& settingsArray = iEngine->SettingsUiArray(); |
|
239 |
|
240 // Create new Container |
|
241 iContainer = CLocSysUiContainer::NewL( *this, settingsArray, ClientRect()); |
|
242 iContainer->SetMopParent( this ); |
|
243 AppUi()->AddToViewStackL( *this, iContainer ); |
|
244 iContainer->SetFocussedElement( iHighlightedIndex ); |
|
245 |
|
246 if ( isLaunchedFromPosSettingsApp && !iEikonEnv->StartedAsServerApp()) |
|
247 { |
|
248 Cba()->SetCommandSetL( R_LOCSYSUIVIEW_SOFTKEYS_OPTION_OPEN_EXIT ); |
|
249 } |
|
250 // Start the ECom notification for observing changes in the plug-in loading |
|
251 // and unloading for ECom plug-ins |
|
252 iEngine->StartSettingsEComNotificationL( this ); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // void CLocSysUiView::DoDeactivate |
|
257 // |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CLocSysUiView::DoDeactivate() |
|
261 { |
|
262 // Stop the ECom notifcation |
|
263 iEngine->StopSettingsEComNotification(); |
|
264 |
|
265 // Destroy Container |
|
266 if ( iContainer ) |
|
267 { |
|
268 iHighlightedIndex = iContainer->CurrentFocussedElement(); |
|
269 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
270 delete iContainer; |
|
271 iContainer = NULL; |
|
272 } |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // TUid CLocSysUiView::Id |
|
277 // Returns the View Id. Should be chosen to reflect the Implementation UID |
|
278 // of the Plugin |
|
279 // |
|
280 // @return TUid The View Id |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 TUid CLocSysUiView::Id() const |
|
284 { |
|
285 return KLocSysUiViewPluginUid; |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // void CLocSysUiView::HandleCommandL |
|
290 // |
|
291 // --------------------------------------------------------------------------- |
|
292 void CLocSysUiView::HandleCommandL( TInt aCommand ) |
|
293 { |
|
294 switch ( aCommand ) |
|
295 { |
|
296 case ELocSysUiCmdOpen: |
|
297 { |
|
298 // Launch the corresponding Settings UI |
|
299 TRAPD( error, |
|
300 iContainer->GetFocussedSettingsUiL(). |
|
301 LaunchLocationUIL( KDefaultParamValue, |
|
302 this )); |
|
303 if ( KErrNone == error ) |
|
304 { |
|
305 iSettingsUiDismissalPending = ETrue; |
|
306 } |
|
307 else if( KErrNoMemory == error ) |
|
308 { |
|
309 User::Leave( error ); |
|
310 } |
|
311 break; |
|
312 } |
|
313 case EAknCmdHelp: |
|
314 { |
|
315 // Launch Help file |
|
316 HlpLauncher::LaunchHelpApplicationL( |
|
317 CEikonEnv::Static()->WsSession(), |
|
318 AppUi()->AppHelpContextL()); |
|
319 break; |
|
320 } |
|
321 case EAknSoftkeyBack: |
|
322 { |
|
323 if( iPrevViewId.iViewUid.iUid ) |
|
324 { |
|
325 // Activate the Parent view |
|
326 AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid ); |
|
327 |
|
328 // If someone is listening for the notification of the termination |
|
329 // event hand it over to the observer |
|
330 if( iObserver ) |
|
331 { |
|
332 iObserver->LocationUIDismissed( KErrNone ); |
|
333 } |
|
334 } |
|
335 else |
|
336 { |
|
337 AppUi()->HandleCommandL( EAknSoftkeyExit ); |
|
338 } |
|
339 break; |
|
340 } |
|
341 default: |
|
342 { |
|
343 AppUi()->HandleCommandL( aCommand ); |
|
344 break; |
|
345 } |
|
346 } |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CLocSysUiView::DynInitMenuPaneL |
|
351 // ----------------------------------------------------------------------------- |
|
352 void CLocSysUiView::DynInitMenuPaneL( TInt aResourceId, |
|
353 CEikMenuPane* aMenuPane ) |
|
354 { |
|
355 if( R_LOCSYSUIVIEW_MENU_ITEM_HELP == aResourceId ) |
|
356 { |
|
357 User::LeaveIfNull( aMenuPane ); |
|
358 |
|
359 //Handle Help Fature |
|
360 HandleHelpFeature( *aMenuPane ); |
|
361 } |
|
362 } |
|
363 // --------------------------------------------------------------------------- |
|
364 // void CLocSysUiView::GetCaptionL |
|
365 // Method for getting caption of this plugin. This should be the |
|
366 // localized name of the settings view to be shown in parent view. |
|
367 |
|
368 // @param aCaption pointer to Caption variable |
|
369 // |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 void CLocSysUiView::GetCaptionL( TDes& aCaption ) const |
|
373 { |
|
374 HBufC* caption = StringLoader::LoadL( R_LOCSYSUIVIEW_CAPTION ); |
|
375 aCaption.Copy( *caption ); |
|
376 delete caption; |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // Inherited from CGSPluginInterface. |
|
381 // Creates a new icon of desired type. Ownership of the created icon |
|
382 // is transferred to the caller. |
|
383 // |
|
384 // Icon type UIDs (use these defined constants): |
|
385 // KGSIconTypeLbxItem - ListBox item icon. |
|
386 // KGSIconTypeTab - Tab icon. |
|
387 // |
|
388 // @param aIconType UID Icon type UID of the icon to be created. |
|
389 // @return CGulIcon* Pointer of the icon. NOTE: Ownership of this |
|
390 // icon is transferred to the caller. |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 CGulIcon* CLocSysUiView::CreateIconL( const TUid aIconType ) |
|
394 { |
|
395 CGulIcon* icon; |
|
396 |
|
397 if ( aIconType == KGSIconTypeLbxItem ) |
|
398 { |
|
399 icon = AknsUtils::CreateGulIconL( |
|
400 AknsUtils::SkinInstance(), |
|
401 KAknsIIDQgnPropSetGeneLoc, |
|
402 KLocationSystemUiViewIconFileName, |
|
403 EMbmLocsysuiviewQgn_prop_set_gene_loc, |
|
404 EMbmLocsysuiviewQgn_prop_set_gene_loc_mask ); |
|
405 } |
|
406 else |
|
407 { |
|
408 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
409 } |
|
410 |
|
411 return icon; |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // TInt CLocSysUiView::PluginProviderCategory() |
|
416 // Inherited from CGSPluginInterface |
|
417 // Method for reading the ID of the plugin provider category. |
|
418 // |
|
419 // @return Plugin provider category ID defined by |
|
420 // TGSPluginProviderCategory |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 TInt CLocSysUiView::PluginProviderCategory() const |
|
424 { |
|
425 return EGSPluginProviderOEM; |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // void CLocSysUiView::LocationUIDismissed |
|
430 // Inherited from MLocationUIObserver |
|
431 // Notifies the termination of the Settings UI |
|
432 // |
|
433 // @param aErrorCode The termination reason. KErrNone for normal |
|
434 // terminations. In case of error or pre-mature |
|
435 // aborting System wide Error codes. |
|
436 // --------------------------------------------------------------------------- |
|
437 // |
|
438 void CLocSysUiView::LocationUIDismissed( TInt /*aErrorCode*/ ) |
|
439 { |
|
440 // Check if the Location System UI View is the active view |
|
441 // If not Activate it |
|
442 TVwsViewId activeViewId; |
|
443 if ( KErrNone != AppUi()->GetActiveViewId( activeViewId ) || |
|
444 activeViewId.iViewUid != Id()) |
|
445 { |
|
446 TRAP_IGNORE( AppUi()->ActivateLocalViewL( Id())); |
|
447 } |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 // void CLocSysUiView::SessionStateChanged |
|
452 // Inherited from MLocSettingsUiEcomNotifer |
|
453 // Notifies any change in the state of the underlying Settings UI |
|
454 // session |
|
455 // |
|
456 // @param aErrorCode Error Code denoting the state change |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 void CLocSysUiView::EComSessionStateChanged( TInt /*aErrorCode*/ ) |
|
460 { |
|
461 if ( iContainer ) |
|
462 { |
|
463 // Update the Settings UI contents |
|
464 TRAP_IGNORE( iEngine->UpdateAvailableSettingsUisL()); |
|
465 |
|
466 // Obtain the latest Settings descriptions and update |
|
467 // Update the list box contents |
|
468 TRAP_IGNORE( iContainer->UpdateListBoxL( iEngine->SettingsUiArray())); |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // void CLocSysUiView::ListBoxItemSelected |
|
474 // |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CLocSysUiView::ListBoxItemSelectedL() |
|
478 { |
|
479 if ( iContainer ) |
|
480 { |
|
481 // Launch the corresponding Settings UI |
|
482 TRAPD( error, |
|
483 iContainer->GetFocussedSettingsUiL().LaunchLocationUIL( |
|
484 KDefaultParamValue, |
|
485 this )); |
|
486 if ( KErrNone == error ) |
|
487 { |
|
488 iSettingsUiDismissalPending = ETrue; |
|
489 } |
|
490 else if( KErrNoMemory == error ) |
|
491 { |
|
492 User::Leave( error ); |
|
493 } |
|
494 } |
|
495 } |
|
496 |
|
497 // --------------------------------------------------------------------------- |
|
498 // void CLocSysUiView::HandleScreenSizeChange |
|
499 // |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 void CLocSysUiView::HandleScreenSizeChange() |
|
503 { |
|
504 if (iContainer) |
|
505 { |
|
506 iContainer->SetRect( ClientRect() ); |
|
507 } |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // void CLocSysUiView::OpenLocalizedResourceFileL |
|
512 // Opens the nearest localized resourcefile using aResourceLoader. |
|
513 // aResourceLoader should be opened only once before closing it. |
|
514 // Otherwise it will raise a panic. Therefore it is better to have |
|
515 // multiple resource loaders. |
|
516 // |
|
517 // @param aResourceFileName Drive and name of resource file in format |
|
518 // <path>:<rsc_file_name> |
|
519 // @param aResourceLoader Resource loader for the resource. The loader |
|
520 // must not be opened allready or it will raise |
|
521 // a panic. It is caller's responsibility to |
|
522 // close the resource loader after using the |
|
523 // resource. |
|
524 // --------------------------------------------------------------------------- |
|
525 // |
|
526 void CLocSysUiView::OpenLocalizedResourceFileL( |
|
527 const TDesC& aResourceFileName, |
|
528 RConeResourceLoader& aResourceLoader ) |
|
529 { |
|
530 RFs fsSession; |
|
531 User::LeaveIfError( fsSession.Connect()); |
|
532 |
|
533 // Add the RFs session to the CleanupStack |
|
534 CleanupClosePushL( fsSession ); |
|
535 |
|
536 TFileName* tmpName = new(ELeave) TFileName; |
|
537 CleanupStack::PushL( tmpName ); |
|
538 |
|
539 // Append the Resource Files Directory |
|
540 tmpName->Append( KDC_RESOURCE_FILES_DIR ); |
|
541 |
|
542 // Append the Ressource File Name |
|
543 tmpName->Append( aResourceFileName ); |
|
544 |
|
545 // Obtain the drive where the DLL is installed |
|
546 TFileName* dllDrive = new (ELeave) TFileName; |
|
547 CleanupStack::PushL( dllDrive ); |
|
548 Dll::FileName( *dllDrive ); |
|
549 |
|
550 // Obtain the Complete path for the Resource File |
|
551 TParse parse; |
|
552 User::LeaveIfError( parse.Set( *dllDrive, NULL, NULL ) ); |
|
553 User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) ); |
|
554 TFileName* fileName = new(ELeave) TFileName; |
|
555 CleanupStack::PushL( fileName ); |
|
556 fileName->Append( parse.FullName()); |
|
557 |
|
558 // Get language of resource file |
|
559 BaflUtils::NearestLanguageFile( fsSession, *fileName ); |
|
560 |
|
561 // Open resource file |
|
562 aResourceLoader.OpenL( *fileName ); |
|
563 |
|
564 // Pop all the fields |
|
565 CleanupStack::PopAndDestroy( fileName ); |
|
566 CleanupStack::PopAndDestroy( dllDrive ); |
|
567 CleanupStack::PopAndDestroy( tmpName ); |
|
568 |
|
569 CleanupStack::PopAndDestroy(); // fsSession |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CLocSysUiView::HandleHelpFeature |
|
574 // ----------------------------------------------------------------------------- |
|
575 void CLocSysUiView::HandleHelpFeature( CEikMenuPane& aMenuPane ) const |
|
576 { |
|
577 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
578 { |
|
579 aMenuPane.SetItemDimmed( EAknCmdHelp, EFalse ); |
|
580 } |
|
581 else |
|
582 { |
|
583 aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue ); |
|
584 } |
|
585 } |
|