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