|
1 /* |
|
2 * Copyright (c) 2002-2007 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: UI class of Psln. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "PslnUi.h" |
|
22 |
|
23 #include <barsread.h> |
|
24 #include <StringLoader.h> |
|
25 |
|
26 // Navi pane, Title Pane & Tab groups |
|
27 #include <aknnavi.h> |
|
28 #include <aknnavide.h> |
|
29 #include <akntitle.h> |
|
30 |
|
31 // Notes & Dialogs |
|
32 #include <AknGlobalNote.h> |
|
33 #include <aknnotewrappers.h> |
|
34 #include <AknWaitDialog.h> |
|
35 |
|
36 // DRM. |
|
37 #include <DRMHelper.h> |
|
38 #include <DRMRights.h> |
|
39 |
|
40 // Psln specific. |
|
41 #include <psln.rsg> |
|
42 #include "PslnModel.h" |
|
43 #include "PslnSkinEntry.h" |
|
44 #include "PslnFeatures.h" |
|
45 #include "PslnSoundActivator.h" |
|
46 #include "pslntaskactivatesounds.h" |
|
47 #include "pslntaskgenericupdate.h" |
|
48 #include "pslnidletaskcreateviews.h" |
|
49 #include "PslnConst.h" |
|
50 #include "PslnDebug.h" |
|
51 #include "PslnModel.h" |
|
52 #include "PslnPropertySubscriber.h" |
|
53 |
|
54 // Views |
|
55 #include "PslnMainView.h" |
|
56 #include "PslnGeneralThemeView.h" |
|
57 #include "PslnScreenSaverView.h" |
|
58 #include "PslnWallpaperView.h" |
|
59 |
|
60 // Framework |
|
61 #include "PslnPluginHandler.h" |
|
62 #include <pslnfwplugininterface.h> |
|
63 #include <pslnfwbaseview.h> |
|
64 |
|
65 // Help texts |
|
66 #include <hlplch.h> |
|
67 #include <csxhelp/skins.hlp.hrh> |
|
68 #include <UsbWatcherInternalPSKeys.h> // KPSUidUsbWatcher |
|
69 #include <usbpersonalityids.h> // Usb Personality Ids |
|
70 |
|
71 // Sets internal state correctly when leave occurs in skin changing. |
|
72 |
|
73 // Handles application exit correctly when leave occurs in exiting. |
|
74 void HandleExitLeave( TAny* aPtr ) |
|
75 { |
|
76 CPslnUi* psln = static_cast<CPslnUi*>(aPtr); |
|
77 psln->HandleCmdExitLeave(); |
|
78 } |
|
79 |
|
80 // ========================= MEMBER FUNCTIONS ================================ |
|
81 // --------------------------------------------------------------------------- |
|
82 // C++ constructor can NOT contain any code, that might leave. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CPslnUi::CPslnUi() : iPslnUiStatus ( EPslnCreated ) |
|
86 { |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Symbian two-phased constructor. |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CPslnUi::ConstructL() |
|
94 { |
|
95 PSLN_TRACE_DEBUG1("CPslnUi::ConstructL, Start:%d", User::NTickCount() ); |
|
96 |
|
97 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
98 EnableExternalViewSwitches(ETrue); |
|
99 |
|
100 // Create ECOM plugin loader. |
|
101 PSLN_TRACE_DEBUG("CPslnUi::ConstructL PluginHandler"); |
|
102 iPluginHandler = CPslnPluginHandler::NewL( this ); |
|
103 |
|
104 PSLN_TRACE_DEBUG("CPslnUi::ConstructL Model"); |
|
105 // Force creation of model, since it is anyway created when ANY view is |
|
106 // activated. |
|
107 CreateModelL(); |
|
108 |
|
109 PSLN_TRACE_DEBUG("CPslnUi::ConstructL StatusPane"); |
|
110 // Show tabs for main views from resources |
|
111 CEikStatusPane* sp = StatusPane(); |
|
112 if ( sp ) |
|
113 { |
|
114 // Fetch pointer to the default navi pane control |
|
115 iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( |
|
116 TUid::Uid(EEikStatusPaneUidNavi)); |
|
117 } |
|
118 |
|
119 // New main view |
|
120 PSLN_TRACE_DEBUG("CPslnUi::ConstructL View-Main"); |
|
121 CPslnMainView* view = CPslnMainView::NewLC(); |
|
122 AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
123 CleanupStack::Pop( view ); // the view has to be popped from cleanupstack here |
|
124 iMainView = view; |
|
125 SetDefaultViewL( *view ); |
|
126 |
|
127 iIdleActivateSkin = CIdle::NewL( CActive::EPriorityIdle ); |
|
128 iIdleUpdateSkin = CIdle::NewL( CActive::EPriorityIdle ); |
|
129 |
|
130 PSLN_TRACE_DEBUG("CPslnUi::ConstructL OK"); |
|
131 User::LeaveIfError( iEnableUSBWatchProperty.Attach( |
|
132 KPSUidUsbWatcher, KUsbWatcherSelectedPersonality) ); |
|
133 iUSBWatchSubscriber = new (ELeave) CPslnPropertySubscriber( |
|
134 TCallBack(USBCallBackL, this), iEnableUSBWatchProperty ); |
|
135 iUSBWatchSubscriber->Subscribe(); |
|
136 |
|
137 |
|
138 TInt value = KErrNone; |
|
139 iEnableUSBWatchProperty.Get(value); |
|
140 if (value == KUsbPersonalityIdMS) |
|
141 { |
|
142 iUSBAttached = ETrue; |
|
143 } |
|
144 else |
|
145 { |
|
146 iUSBAttached = EFalse; |
|
147 } |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // Destructor |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 CPslnUi::~CPslnUi() |
|
155 { |
|
156 PSLN_TRACE_DEBUG("CPslnUi::Destructor"); |
|
157 |
|
158 HideProgressBar(); |
|
159 // Reset skin info when exiting normally. This prevents model class |
|
160 // from trying to revert back to previous skin. |
|
161 if ( iView && iView->Id().iUid == KPslnMainView2.iUid ) |
|
162 { |
|
163 // It is possible that Model is not created, if exiting immediately after |
|
164 // application launch. So first check that Model is created. |
|
165 if ( iModel ) |
|
166 { |
|
167 TInt currentlySelected = iModel->ActiveSkinIndex(); |
|
168 iModel->SetCurrentSelectedSkinIndex( currentlySelected ); |
|
169 } |
|
170 } |
|
171 delete iModel; |
|
172 // This nullification is needed, since external DLL's may try to access |
|
173 // model through view framework and it might succeed even if model and UI |
|
174 // classes are already deleted, but external DLLs aren't. |
|
175 // This is due to that model reference is passed as a pointer due to delayed |
|
176 // construction - it is not available at the time when view is constructed. |
|
177 iModel = NULL; |
|
178 delete iDecoratedTabGroup; |
|
179 |
|
180 if ( iPluginHandler ) |
|
181 { |
|
182 delete iPluginHandler; |
|
183 } |
|
184 |
|
185 delete iIdleTask; |
|
186 delete iIdleActivateSkin; |
|
187 delete iIdleUpdateSkin; |
|
188 |
|
189 |
|
190 if( iUSBWatchSubscriber ) |
|
191 { |
|
192 iUSBWatchSubscriber->Cancel(); |
|
193 } |
|
194 iEnableUSBWatchProperty.Close(); |
|
195 delete iUSBWatchSubscriber; |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // Handles event when focus loss or gain. |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CPslnUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination ) |
|
203 { |
|
204 PSLN_TRACE_DEBUG("CPslnUi::HandlwWSEvent"); |
|
205 if ( iView ) |
|
206 { |
|
207 TInt eventType = aEvent.Type(); |
|
208 TUid currentView = iView->Id(); |
|
209 |
|
210 // do this everytime when foreground gained. |
|
211 if ( ( currentView.iUid == KPslnGeneralView.iUid ) && |
|
212 ( eventType == EEventFocusGained ) && |
|
213 ( GetStatus( EPslnListUpdateNeeded ) || |
|
214 GetStatus( EPslnProtectedSkinInList ) ) && IsForeground() ) |
|
215 { |
|
216 PSLN_TRACE_DEBUG("CPslnUi::HandlwWSEvent Update list"); |
|
217 SetStateOff( EPslnListUpdateNeeded ); |
|
218 DoCreateWaitNoteL(); |
|
219 } |
|
220 } |
|
221 CAknViewAppUi::HandleWsEventL( aEvent, aDestination ); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // Handles commands directed to this class. |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CPslnUi::HandleCommandL( TInt aCommand ) |
|
229 { |
|
230 PSLN_TRACE_DEBUG1("CPslnUi::HandleCommand %d", aCommand ); |
|
231 switch ( aCommand ) |
|
232 { |
|
233 //both exit commands should do the same thing |
|
234 case EEikCmdExit: |
|
235 case EAknCmdExit: |
|
236 case EAknSoftkeyExit: |
|
237 HandleCmdExitL(); |
|
238 break; |
|
239 |
|
240 case EPslnCmdAppActivate: |
|
241 { |
|
242 if (!iIdleActivateSkin->IsActive()) |
|
243 { |
|
244 iIdleActivateSkin->Start(TCallBack( DoActivateSkinL, this )); |
|
245 } |
|
246 } |
|
247 break; |
|
248 case EPslnCmdAppDownload: |
|
249 DownloadSkinL(); |
|
250 break; |
|
251 case EAknCmdHelp: |
|
252 case EPslnCmdAppHelp: |
|
253 { |
|
254 HlpLauncher::LaunchHelpApplicationL( |
|
255 iEikonEnv->WsSession(), AppHelpContextL()); |
|
256 } |
|
257 break; |
|
258 case EAknSoftkeyBack: |
|
259 // If General view is active and Back key is |
|
260 // pressed and there is skin activation ongoing |
|
261 // set internal state off. |
|
262 if ( iView && GetStatus( EPslnSkinChangeRequested ) && |
|
263 ( iView->Id().iUid == KPslnGeneralView.iUid ) ) |
|
264 { |
|
265 SetStateOff( EPslnSkinChangeRequested ); |
|
266 } |
|
267 ActivateLocalViewL( KPslnMainView2 ); |
|
268 break; |
|
269 default: |
|
270 CAknViewAppUi::HandleCommandL( aCommand ); |
|
271 break; |
|
272 } |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CPslnUi::HandleResourceChangeL |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CPslnUi::HandleResourceChangeL( TInt aType ) |
|
280 { |
|
281 PSLN_TRACE_DEBUG("CPslnUi::HandleResourceChangeL"); |
|
282 if ( iView && !GetStatus( EPslnSkinChangeRequested ) && |
|
283 iView->Id().iUid == KPslnGeneralView.iUid && |
|
284 aType == KAknsMessageSkinChange ) |
|
285 { |
|
286 iGeneralThemeView->UpdateSkinListItemsDColumnOnlyL(); |
|
287 } |
|
288 CAknViewAppUi::HandleResourceChangeL( aType ); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // CPslnUi::ActivateLocalViewL |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CPslnUi::ActivateLocalViewL( TUid aViewId ) |
|
296 { |
|
297 if ( GetStatus( EPslnListUpdateNeeded ) && |
|
298 ( aViewId.iUid == KPslnGeneralView.iUid ) ) |
|
299 { |
|
300 PSLN_TRACE_DEBUG("CPslnUi::ActivateLocalViewL update list"); |
|
301 SetStateOff( EPslnListUpdateNeeded ); |
|
302 DoCreateWaitNoteL(); |
|
303 } |
|
304 CAknViewAppUi::ActivateLocalViewL( aViewId ); |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // CPslnUi::SkinContentChanged |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 void CPslnUi::SkinContentChanged() |
|
312 { |
|
313 PSLN_TRACE_DEBUG("CPslnUi::SkinContentChanged"); |
|
314 if ( !iView || iView->Id().iUid != KPslnGeneralView.iUid ) |
|
315 { |
|
316 SetStateOn( EPslnListUpdateNeeded ); |
|
317 } |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // CPslnUi::SkinConfigurationChanged |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CPslnUi::SkinConfigurationChanged( |
|
325 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
326 { |
|
327 PSLN_TRACE_DEBUG("CPslnUi::SkinConfigurationChanged"); |
|
328 TRAPD( err, SkinConfigurationChangedL( aReason ) ); |
|
329 if ( err != KErrNone ) |
|
330 { |
|
331 TRAP_IGNORE( iGeneralThemeView->UpdateSkinListItemsL() ); |
|
332 } |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // CPslnUi::SkinPackageChanged |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CPslnUi::SkinPackageChanged( |
|
340 const TAknsSkinStatusPackageChangeReason aReason ) |
|
341 { |
|
342 PSLN_TRACE_DEBUG("CPslnUi::SkinPackageChanged"); |
|
343 if ( aReason == EAknsSkinStatusPackageListUpdate ) |
|
344 { |
|
345 if ( !iView || iView->Id().iUid != KPslnGeneralView.iUid ) |
|
346 { |
|
347 SetStateOn( EPslnListUpdateNeeded ); |
|
348 } |
|
349 else |
|
350 { |
|
351 PSLN_TRACE_DEBUG("CPslnUi::SkinPackageChanged update list"); |
|
352 //To Fix Defect:ESNN-7CXCT2:Themes: Layout is incorrect |
|
353 //when removing memory card which the active theme is installed in. |
|
354 //DoCreateWaitNoteL take too much time and stop the skin refresh. |
|
355 //Need to wait for the Skin Server finish its work,so we use CIdle. |
|
356 //Also we need User::After to delay some time to make sure |
|
357 //iIdleUpdateSkin start late enough. |
|
358 User::After(KPslnUpdateSkinDelay); |
|
359 if (!iIdleUpdateSkin->IsActive()) |
|
360 { |
|
361 iIdleUpdateSkin->Start(TCallBack( DoCreateWaitNoteL, this )); |
|
362 } |
|
363 SetStateOff( EPslnListUpdateNeeded ); |
|
364 } |
|
365 } |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // Return model pointer. |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 CPslnModel* CPslnUi::Model() const |
|
373 { |
|
374 return iModel; |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // Updates tab group to current tab index |
|
379 // The parameters are optional. |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 #ifdef RD_CONTROL_PANEL |
|
383 void CPslnUi::UpdateTabIndex( const TInt aMyId, const TInt /*aMyTabIndex*/ ) |
|
384 #else |
|
385 void CPslnUi::UpdateTabIndex( const TInt /*aMyId*/, const TInt aMyTabIndex ) |
|
386 #endif // RD_CONTROL_PANEL |
|
387 { |
|
388 #ifdef RD_CONTROL_PANEL |
|
389 if ( aMyId != KErrNotFound ) |
|
390 { |
|
391 if ( iMainView ) |
|
392 { |
|
393 iMainView->SetActiveFolder( TUid::Uid( aMyId ) ); |
|
394 } |
|
395 } |
|
396 #else |
|
397 if ( aMyTabIndex != KErrNotFound ) |
|
398 { |
|
399 if ( iTabGroup ) |
|
400 { |
|
401 iTabGroup->SetActiveTabById( aMyTabIndex ); |
|
402 } |
|
403 } |
|
404 if ( ( iView == iMainView ) && iTabGroup && iMainView ) |
|
405 { |
|
406 iTabGroup->SetActiveTabByIndex( iMainView->ActiveView() ); |
|
407 } |
|
408 #endif //RD_CONTROL_PANEL |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // Creates given view. |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 void CPslnUi::CreateViewL( TUid aViewUid ) |
|
416 { |
|
417 PSLN_TRACE_DEBUG1("CPslnUi::CreateViewL, Start:%d", User::NTickCount() ); |
|
418 TBitFlags views = ViewSupport(); |
|
419 |
|
420 if ( aViewUid == KPslnWallpaperView && |
|
421 !GetStatus( EPslnWallpaperViewCreated ) ) |
|
422 { |
|
423 |
|
424 if ( views.IsSet( EPslnWallpaperView ) ) |
|
425 { |
|
426 CAknView* view = CPslnWallpaperView::NewLC(); |
|
427 AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
428 CleanupStack::Pop( view ); |
|
429 |
|
430 SetStateOn( EPslnWallpaperViewCreated ); |
|
431 |
|
432 PSLN_TRACE_DEBUG("CPslnUi::CreateViewL - Wallpaper"); |
|
433 PSLN_TRACE_DEBUG1("CPslnUi::CreateViewL, End:%d", User::NTickCount() ); |
|
434 } |
|
435 } |
|
436 // Screensaver view. |
|
437 else if ( aViewUid == KPslnScreenSaverView && |
|
438 !GetStatus( EPslnScreenSaverViewCreated ) ) |
|
439 { |
|
440 if ( views.IsSet( EPslnScreensaverView ) ) |
|
441 { |
|
442 CAknView* view = CPslnScreenSaverView::NewLC(); |
|
443 AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
444 CleanupStack::Pop( view ); |
|
445 |
|
446 SetStateOn( EPslnScreenSaverViewCreated ); |
|
447 |
|
448 PSLN_TRACE_DEBUG("CPslnUi::CreateViewL - ScreenSaver"); |
|
449 PSLN_TRACE_DEBUG1("CPslnUi::CreateViewL, End:%d", User::NTickCount() ); |
|
450 } |
|
451 } |
|
452 // General view. |
|
453 else if ( aViewUid.iUid == KPslnGeneralView.iUid && |
|
454 !GetStatus( EPslnGeneralViewCreated ) ) |
|
455 { |
|
456 CAknView* view = CPslnGeneralThemeView::NewLC(); |
|
457 AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
458 iGeneralThemeView = static_cast< CPslnGeneralThemeView* >( view ); |
|
459 CleanupStack::Pop( view ); |
|
460 |
|
461 SetStateOn( EPslnGeneralViewCreated ); |
|
462 |
|
463 PSLN_TRACE_DEBUG("CPslnUi::CreateViewL - General"); |
|
464 PSLN_TRACE_DEBUG1("CPslnUi::CreateViewL, End:%d", User::NTickCount() ); |
|
465 } |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // Return navi control container pointer. |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 CAknNavigationControlContainer* CPslnUi::NaviContainer() const |
|
473 { |
|
474 return iNaviPane; |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // Return tab group pointer. |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 CAknNavigationDecorator* CPslnUi::PslnTabGroup() |
|
482 { |
|
483 if ( !GetStatus( EPslnTabGroupCreated ) ) |
|
484 { |
|
485 TRAP_IGNORE( ConstructTabGroupL() ); |
|
486 } |
|
487 return iDecoratedTabGroup; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // Return plugin handler pointer. |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 CPslnPluginHandler* CPslnUi::PluginHandler() const |
|
495 { |
|
496 return iPluginHandler; |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // Adds new view to UI class, if the UI class is not already completed. |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 void CPslnUi::AddNewViewL( CAknView* aNewView ) |
|
504 { |
|
505 if ( GetStatus( EPslnCreated ) ) |
|
506 { |
|
507 if ( aNewView && !View( aNewView->Id() ) ) |
|
508 { |
|
509 AddViewL( aNewView ); |
|
510 } |
|
511 } |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // When this method is called, UI class considers itself to be complete. |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 void CPslnUi::AllViewsDone() |
|
519 { |
|
520 SetStateOff( EPslnCreated ); |
|
521 } |
|
522 |
|
523 // --------------------------------------------------------------------------- |
|
524 // Handles errors that occur when handling images. |
|
525 // --------------------------------------------------------------------------- |
|
526 // |
|
527 void CPslnUi::HandleImageErrorsL( TInt aError ) |
|
528 { |
|
529 PSLN_TRACE_DEBUG1("CPslnUi::HandleImageError %d", aError ); |
|
530 if ( aError == KErrNoMemory || aError == KErrTooBig ) |
|
531 { |
|
532 // Show information note |
|
533 HBufC* prompt = iCoeEnv->AllocReadResourceLC( R_PSLN_IMAGE_TOO_LARGE ); |
|
534 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
|
535 note->ExecuteLD( *prompt ); |
|
536 CleanupStack::PopAndDestroy( prompt ); |
|
537 } |
|
538 else if ( aError == KErrCancel || aError == KErrCouldNotConnect ) |
|
539 { |
|
540 // Other error codes are ignored; as not real errors (i.e. KErrCancel), |
|
541 // or such errors that Psln cannot react to them (KErrCouldNotConnect) |
|
542 } |
|
543 else |
|
544 { |
|
545 // Show information note |
|
546 HBufC* prompt = iCoeEnv->AllocReadResourceLC( R_PSLN_IMAGE_CORRUPTED ); |
|
547 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
|
548 note->ExecuteLD( *prompt ); |
|
549 CleanupStack::PopAndDestroy( prompt ); |
|
550 } |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 // Indicate that tab group has been changed. |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 #ifndef RD_CONTROL_PANEL |
|
558 void CPslnUi::TabChangedL( TInt aIndex ) |
|
559 { |
|
560 PSLN_TRACE_DEBUG("CPslnUi::TabChangedL 1" ); |
|
561 // If it is one of the dynamically created views, check if the view is |
|
562 // already created. If view is not created, create it. |
|
563 if ( aIndex == KPslnGeneralView.iUid ) |
|
564 { |
|
565 if ( !GetStatus( EPslnGeneralViewCreated ) ) |
|
566 { |
|
567 CreateViewL( KPslnGeneralView ); |
|
568 } |
|
569 } |
|
570 else if ( aIndex == KPslnWallpaperView.iUid ) |
|
571 { |
|
572 if ( !GetStatus( EPslnWallpaperViewCreated ) ) |
|
573 { |
|
574 CreateViewL( KPslnWallpaperView ); |
|
575 } |
|
576 } |
|
577 else if ( aIndex == KPslnScreenSaverView.iUid ) |
|
578 { |
|
579 if ( !GetStatus( EPslnScreenSaverViewCreated ) ) |
|
580 { |
|
581 CreateViewL( KPslnScreenSaverView ); |
|
582 } |
|
583 } |
|
584 if ( iMainView ) |
|
585 { |
|
586 iMainView->SetActiveFolder( aIndex ); |
|
587 ActivateLocalViewL( TUid::Uid( iMainView->ActiveFolderUid() ) ); |
|
588 } |
|
589 } |
|
590 #endif //RD_CONTROL_PANEL |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // Loads views when application is idle. |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 void CPslnUi::LoadViewsWhenIdleL() |
|
597 { |
|
598 if ( !iIdleTask ) |
|
599 { |
|
600 iIdleTask = CPslnIdleTaskCreateViews::NewL( this ); |
|
601 } |
|
602 } |
|
603 |
|
604 // --------------------------------------------------------------------------- |
|
605 // Constructs the Tab group. |
|
606 // --------------------------------------------------------------------------- |
|
607 void CPslnUi::ConstructTabGroupL() |
|
608 { |
|
609 #ifdef RD_CONTROL_PANEL |
|
610 return; |
|
611 #else |
|
612 if ( GetStatus( EPslnTabGroupCreated ) ) |
|
613 { |
|
614 // Tabgroup has already been created. |
|
615 return; |
|
616 } |
|
617 // Tabgroup has been read from resource and it were pushed to the navi pane. |
|
618 // Get pointer to the navigation decorator |
|
619 // and set this to be a MAknTabObserver. |
|
620 if ( iNaviPane ) |
|
621 { |
|
622 iDecoratedTabGroup = iNaviPane->ResourceDecorator(); |
|
623 } |
|
624 if ( iDecoratedTabGroup ) |
|
625 { |
|
626 PSLN_TRACE_DEBUG("CPslnUi::ConstructTabGroupL DecoTabGrp"); |
|
627 iTabGroup = static_cast <CAknTabGroup*> |
|
628 ( iDecoratedTabGroup->DecoratedControl() ); |
|
629 iTabGroup->SetObserver( this ); |
|
630 } |
|
631 TInt tabCount = 1; // index 0 = general view |
|
632 TBitFlags views = ViewSupport(); |
|
633 |
|
634 // Update Tab group to contain default plugins. |
|
635 if ( iPluginHandler ) |
|
636 { |
|
637 CPslnFWPluginInterface* plugin = |
|
638 iPluginHandler->GetPlugin( KPslnASPluginUid ); |
|
639 if ( plugin ) |
|
640 { |
|
641 AddPluginToTab( *plugin ); |
|
642 static_cast <CPslnFWBaseView*> |
|
643 (plugin)->SetNaviPaneDecorator( iDecoratedTabGroup ); |
|
644 tabCount++; // index 1 = AS plugin |
|
645 } |
|
646 plugin = iPluginHandler->GetPlugin( KPslnAIPluginUid ); |
|
647 if ( plugin ) |
|
648 { |
|
649 AddPluginToTab( *plugin ); |
|
650 static_cast <CPslnFWBaseView*> |
|
651 (plugin)->SetNaviPaneDecorator( iDecoratedTabGroup ); |
|
652 tabCount++; // index 2 = AI plugin |
|
653 } |
|
654 } |
|
655 |
|
656 // Add tabs for screen saver and wallpaper. |
|
657 if ( iTabGroup ) |
|
658 { |
|
659 if ( views.IsSet( EPslnWallpaperView ) ) |
|
660 { |
|
661 TResourceReader reader; |
|
662 iCoeEnv->CreateResourceReaderLC( reader, R_PSLN_WALLPAPER_TAB ); |
|
663 iTabGroup->AddTabL( reader ); |
|
664 CleanupStack::PopAndDestroy(); // reader - AppUi now owns this tab, |
|
665 tabCount++; // index 3 = Wallpaper view |
|
666 } |
|
667 |
|
668 if ( views.IsSet( EPslnScreensaverView ) ) |
|
669 { |
|
670 TResourceReader reader2; |
|
671 iCoeEnv->CreateResourceReaderLC( reader2, R_PSLN_SCREENSAVER_TAB ); |
|
672 iTabGroup->AddTabL( reader2 ); |
|
673 CleanupStack::PopAndDestroy(); // reader2 - AppUi now owns this tab, |
|
674 tabCount++; // index 4 = Screensaver view |
|
675 } |
|
676 PSLN_TRACE_DEBUG("CPslnUi::ConstructTabGroupL Default Tabs added to TabGrp"); |
|
677 } |
|
678 |
|
679 // Add rest of the plugins to tabs. |
|
680 if ( iPluginHandler ) |
|
681 { |
|
682 // Fetch the plugin array. |
|
683 CArrayPtrFlat<CPslnFWPluginInterface>* pluginArray = |
|
684 iPluginHandler->GetPluginArray(); |
|
685 CleanupStack::PushL( pluginArray ); |
|
686 TInt pluginCount = pluginArray->Count(); |
|
687 PSLN_TRACE_DEBUG1("CPslnUi::ConstructTabGroupL Plugin count=%d", pluginCount ); |
|
688 |
|
689 // Go through all the plugins and add plugins to tab group. |
|
690 for ( TInt i = 0; i < pluginCount; i++ ) |
|
691 { |
|
692 CPslnFWPluginInterface* plugin = pluginArray->operator[]( i ); |
|
693 |
|
694 if ( !plugin ) |
|
695 { |
|
696 PSLN_TRACE_DEBUG("CPslnUi::ConstructTabGroupL Plugin fails"); |
|
697 } |
|
698 // Default plugins can be skipped. |
|
699 else if ( plugin->Id().iUid == KPslnASPluginUid.iUid || |
|
700 plugin->Id().iUid == KPslnAIPluginUid.iUid ) |
|
701 { |
|
702 PSLN_TRACE_DEBUG("CPslnUi::ConstructTabGroupL Plugin skipped"); |
|
703 } |
|
704 else |
|
705 { |
|
706 PSLN_TRACE_DEBUG1("CPslnUi::ConstructTabGroupL Plugin Id=%d", plugin->Id().iUid ); |
|
707 AddPluginToTab( *plugin ); |
|
708 static_cast <CPslnFWBaseView*> |
|
709 (plugin)->SetNaviPaneDecorator( iDecoratedTabGroup ); |
|
710 // Inform to the plugin which tab index it is using. |
|
711 static_cast <CPslnFWBaseView*> |
|
712 (plugin)->SetTabIndex( tabCount++ ); |
|
713 PSLN_TRACE_DEBUG("CPslnUi::ConstructTabGroupL Plugin added to tab"); |
|
714 } |
|
715 } |
|
716 CleanupStack::Pop( pluginArray ); // plugin handler owns plugin array |
|
717 } |
|
718 // Push empty navi pane, so that tab group is not shown with default item (first), |
|
719 // if other than main view is activated externally. |
|
720 iNaviPane->PushDefaultL(); |
|
721 SetStateOn( EPslnTabGroupCreated ); |
|
722 #endif //RD_CONTROL_PANEL |
|
723 } |
|
724 |
|
725 |
|
726 // --------------------------------------------------------------------------- |
|
727 // Is this class able to handle a new skin activation related command. |
|
728 // --------------------------------------------------------------------------- |
|
729 TBool CPslnUi::IsReadyToHandleCommands() |
|
730 { |
|
731 return !GetStatus( EPslnSkinChangeRequested ); |
|
732 } |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // Ensure that Exit() is called when trying to exit and leave occurs. |
|
736 // --------------------------------------------------------------------------- |
|
737 void CPslnUi::HandleCmdExitLeave() |
|
738 { |
|
739 Exit(); |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------------------------- |
|
743 // Sets title pane back to default text. |
|
744 // --------------------------------------------------------------------------- |
|
745 void CPslnUi::SetTitleToDefaultL() |
|
746 { |
|
747 // Set default title back. But do not change title when application is about |
|
748 // to die. |
|
749 if ( iCoeEnv && Model() ) |
|
750 { |
|
751 TResourceReader rReader; |
|
752 iCoeEnv->CreateResourceReaderLC( rReader, R_PSLN_SKIN_LIST_VIEW_TITLE ); |
|
753 if ( iAvkonAppUi ) |
|
754 { |
|
755 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
756 if ( sp ) |
|
757 { |
|
758 CAknTitlePane* title = static_cast<CAknTitlePane*>( |
|
759 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
760 |
|
761 if ( title ) |
|
762 { |
|
763 title->SetFromResourceL( rReader ); |
|
764 } |
|
765 } |
|
766 } |
|
767 CleanupStack::PopAndDestroy(); // rReader |
|
768 } |
|
769 } |
|
770 |
|
771 // --------------------------------------------------------------------------- |
|
772 // Checks if a view has been created. |
|
773 // --------------------------------------------------------------------------- |
|
774 TBitFlags CPslnUi::ViewSupport() |
|
775 { |
|
776 // Initially all views are 'on'. |
|
777 TBitFlags viewFlags; |
|
778 viewFlags.SetAll(); |
|
779 if ( GetStatus( EPslnViewSupportChecked ) ) |
|
780 { |
|
781 if ( GetStatus( EPslnNoScreenSaverView ) ) |
|
782 { |
|
783 viewFlags.Clear( EPslnScreensaverView ); |
|
784 } |
|
785 if ( GetStatus( EPslnNoWallpaperView ) ) |
|
786 { |
|
787 viewFlags.Clear( EPslnWallpaperView ); |
|
788 } |
|
789 } |
|
790 else |
|
791 { |
|
792 TBool noWallpaperView = PslnFeatures::IsSupported( KPslnRemoveWallpaper ); |
|
793 TBool noScreenSaverView = PslnFeatures::IsSupported( KPslnRemoveScreensaver ); |
|
794 if ( noWallpaperView ) |
|
795 { |
|
796 SetStateOn( EPslnNoWallpaperView ); |
|
797 viewFlags.Clear( EPslnWallpaperView ); |
|
798 } |
|
799 if ( noScreenSaverView ) |
|
800 { |
|
801 SetStateOn( EPslnNoScreenSaverView ); |
|
802 viewFlags.Clear( EPslnScreensaverView ); |
|
803 } |
|
804 SetStateOn( EPslnViewSupportChecked ); |
|
805 } |
|
806 return viewFlags; |
|
807 } |
|
808 |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 // --------------------------------------------------------------------------- |
|
812 void CPslnUi::SetDRMProtectedSkinInSkinList( |
|
813 const TBool& aProtectedSkinInList ) |
|
814 { |
|
815 if ( aProtectedSkinInList ) |
|
816 { |
|
817 SetStateOn( EPslnProtectedSkinInList ); |
|
818 } |
|
819 else |
|
820 { |
|
821 SetStateOff( EPslnProtectedSkinInList ); |
|
822 } |
|
823 } |
|
824 |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // Callback - USB status change. |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 TInt CPslnUi::USBCallBackL(TAny* aPtr) |
|
831 { |
|
832 CPslnUi* self = static_cast<CPslnUi*>(aPtr); |
|
833 if ( self ) |
|
834 { |
|
835 self->HandleUSBCallBackL(); |
|
836 } |
|
837 return KErrNone; |
|
838 } |
|
839 |
|
840 |
|
841 /** |
|
842 * USB Attach State. |
|
843 * @return ETrue when USB already attached, otherwise EFalse, |
|
844 */ |
|
845 // --------------------------------------------------------------------------- |
|
846 // USB Attach State. |
|
847 // --------------------------------------------------------------------------- |
|
848 TBool CPslnUi::USBAttachState() |
|
849 { |
|
850 return iUSBAttached; |
|
851 } |
|
852 |
|
853 // --------------------------------------------------------------------------- |
|
854 // Called when a key is pressed and no other class has catched the event. |
|
855 // Handles only key events that are meant to control the tab group. |
|
856 // --------------------------------------------------------------------------- |
|
857 #ifdef RD_CONTROL_PANEL |
|
858 TKeyResponse CPslnUi::HandleKeyEventL( |
|
859 const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ ) |
|
860 #else |
|
861 TKeyResponse CPslnUi::HandleKeyEventL( |
|
862 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
863 #endif // RD_CONTROL_PANEL |
|
864 { |
|
865 PSLN_TRACE_DEBUG("CPslnUi::HandleKeyEventL"); |
|
866 |
|
867 #ifndef RD_CONTROL_PANEL |
|
868 // If tab group is not yet created, create it. |
|
869 if ( !GetStatus( EPslnTabGroupCreated ) ) |
|
870 { |
|
871 ConstructTabGroupL(); |
|
872 } |
|
873 iTabGroup = static_cast<CAknTabGroup*> |
|
874 ( iDecoratedTabGroup->DecoratedControl() ); |
|
875 |
|
876 // Only forward key events to tabgroup when: |
|
877 // 1) TabGroup has been created (and is not NULL) |
|
878 // 2) Active view is not MainView (there is no tab group in Main) |
|
879 // 3) key event is either left key or right key |
|
880 if ( iTabGroup && iView && iView->Id().iUid != KPslnMainView2.iUid && |
|
881 ( aKeyEvent.iScanCode == EStdKeyLeftArrow || |
|
882 aKeyEvent.iScanCode == EStdKeyRightArrow ) ) |
|
883 { |
|
884 PSLN_TRACE_DEBUG("CPslnUi::HandleKeyEventL forward event to Tab"); |
|
885 // If preview is about to activate, cancel it. |
|
886 if ( GetStatus( EPslnSkinChangeRequested ) && |
|
887 iView->Id().iUid == KPslnGeneralView.iUid ) |
|
888 { |
|
889 SetStateOff( EPslnSkinChangeRequested ); |
|
890 } |
|
891 |
|
892 return iTabGroup->OfferKeyEventL( aKeyEvent, aType ); |
|
893 } |
|
894 #endif // !RD_CONTROL_PANEL |
|
895 return EKeyWasNotConsumed; |
|
896 } |
|
897 |
|
898 // --------------------------------------------------------------------------- |
|
899 // CPslnUi::SkinConfigurationChangedL |
|
900 // --------------------------------------------------------------------------- |
|
901 // |
|
902 void CPslnUi::SkinConfigurationChangedL( |
|
903 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
904 { |
|
905 PSLN_TRACE_DEBUG1("CPslnUi::SkinConfigurationChangedL internal state before: %d", iPslnUiStatus ); |
|
906 HBufC* errorBuf = NULL; |
|
907 |
|
908 switch( aReason ) |
|
909 { |
|
910 // Skin activation failed due to OOM. |
|
911 // Set skin activation user activity off, so that subsequent attempts can be made. |
|
912 // Also, set error note text. |
|
913 // Finally, set skin activation attempt off and update skin list. |
|
914 case EAknsSkinStatusConfigurationFailedOOM: |
|
915 SetStateOff( EPslnSkinChangeRequested ); |
|
916 errorBuf = StringLoader::LoadLC( R_PSLN_QTN_MEMLO_RAM_OUT_OF_MEM ); |
|
917 if ( GetStatus( EPslnSkinActivated ) ) |
|
918 { |
|
919 SetStateOff( EPslnSkinActivated ); |
|
920 HideProgressBar(); |
|
921 DoCreateWaitNoteL(); |
|
922 } |
|
923 break; |
|
924 // Skin activation failed due to skin being corrupted. |
|
925 // Set skin activation user activity off, so that subsequent attempts can be made. |
|
926 // Also, set error note text. |
|
927 // Then set skin activation attempt off and update skin list. |
|
928 // Finally, activate default skin. |
|
929 case EAknsSkinStatusConfigurationFailedCorrupt: |
|
930 SetStateOff( EPslnSkinChangeRequested ); |
|
931 iGeneralThemeView->HightlightDefaultSkin(); |
|
932 errorBuf = StringLoader::LoadLC( R_PSLN_QTN_SKINS_ERROR_CORRUPTED ); |
|
933 if ( GetStatus( EPslnSkinActivated ) ) |
|
934 { |
|
935 SetStateOff( EPslnSkinActivated ); |
|
936 HideProgressBar(); |
|
937 DoCreateWaitNoteL(); |
|
938 } |
|
939 SetStateOn( EPslnListUpdateNeeded ); |
|
940 break; |
|
941 // Skin activation was success. |
|
942 // Set skin activation user activity off. |
|
943 // Show confirmation note about the skin change and set activation |
|
944 // request state off. Finally, check if there are sounds in the skin. |
|
945 case EAknsSkinStatusConfigurationDeployed: |
|
946 SetStateOff( EPslnSkinChangeRequested ); |
|
947 if ( GetStatus( EPslnSkinActivated ) ) |
|
948 { |
|
949 SetStateOff( EPslnSkinActivated ); |
|
950 HideProgressBar(); |
|
951 SkinDeployedL(); |
|
952 } |
|
953 else // Theme changed by other app, update view. |
|
954 { |
|
955 iModel->PerformCompleteUpdateL(); |
|
956 iGeneralThemeView->UpdateSkinListItemsL( iModel->ActiveSkinIndex() + |
|
957 PslnFeatures::IsEnhancedEmbeddedLinksSupported() ); |
|
958 } |
|
959 |
|
960 if ( GetStatus( EPslnSoundActivationPending ) ) |
|
961 { |
|
962 SetStateOff( EPslnSoundActivationPending ); |
|
963 ActivateSoundsL(); |
|
964 } |
|
965 break; |
|
966 default: |
|
967 break; |
|
968 } |
|
969 |
|
970 if( errorBuf ) |
|
971 { |
|
972 ShowErrorNoteL( *errorBuf ); |
|
973 CleanupStack::PopAndDestroy( errorBuf ); |
|
974 } |
|
975 PSLN_TRACE_DEBUG1("CPslnUi::SkinConfigurationChangedL internal state after: %d", iPslnUiStatus ); |
|
976 } |
|
977 |
|
978 // --------------------------------------------------------------------------- |
|
979 // Activate a Skin. |
|
980 // --------------------------------------------------------------------------- |
|
981 // |
|
982 void CPslnUi::ActivateSkinL() |
|
983 { |
|
984 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL"); |
|
985 TInt skinIndex = iModel->CurrentSelectedSkinIndex(); |
|
986 |
|
987 CPslnSkinEntry* entry = iModel->VisibleSkin( skinIndex ); |
|
988 if( !entry ) |
|
989 { |
|
990 SetStateOff( EPslnSkinChangeRequested ); |
|
991 return; |
|
992 } |
|
993 |
|
994 TBool showWaitNote = EFalse; |
|
995 TInt drmError = KErrNone; |
|
996 HBufC* errorBuf = NULL; |
|
997 |
|
998 PSLN_TRACE_DEBUG1("CPslnUi::ActivateSkinL entry->Protection: %d", entry->Protection() ); |
|
999 switch ( entry->Protection() ) |
|
1000 { |
|
1001 case EAknsSrvNoRights: |
|
1002 drmError = CDRMRights::ENoRights; |
|
1003 showWaitNote = ETrue; |
|
1004 break; |
|
1005 case EAknsSrvFutureRights: |
|
1006 drmError = CDRMRights::ERightsExpired; |
|
1007 break; |
|
1008 case EAknsSrvExpiredRights: |
|
1009 drmError = CDRMRights::ERightsExpired; |
|
1010 showWaitNote = ETrue; |
|
1011 break; |
|
1012 default : |
|
1013 break; |
|
1014 } |
|
1015 |
|
1016 // DRMHelper handles the error. |
|
1017 if ( drmError ) |
|
1018 { |
|
1019 RAknsSrvSession skinsrv; |
|
1020 User::LeaveIfError( skinsrv.Connect() ); |
|
1021 CleanupClosePushL( skinsrv ); |
|
1022 |
|
1023 TInt fileserverhandle; |
|
1024 TInt filehandle; |
|
1025 fileserverhandle = skinsrv.OpenBitmapFile( entry->FullName(), filehandle ); |
|
1026 RFile file; |
|
1027 User::LeaveIfError( file.AdoptFromServer( fileserverhandle, filehandle ) ); |
|
1028 CleanupClosePushL( file ); |
|
1029 |
|
1030 TInt returnCode = KErrNone; |
|
1031 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL use DRMHelper to show the error note"); |
|
1032 CDRMHelper* drmhelper = CDRMHelper::NewLC( *CCoeEnv::Static() ); |
|
1033 returnCode = drmhelper->HandleErrorL( |
|
1034 drmError, |
|
1035 file ); |
|
1036 |
|
1037 PSLN_TRACE_DEBUG1("CPslnUi::ActivateSkinL DRMHelper returns: %d", returnCode ); |
|
1038 if ( returnCode && showWaitNote ) |
|
1039 { |
|
1040 if ( GetStatus( EPslnListUpdateNeeded ) ) |
|
1041 { |
|
1042 SetStateOff( EPslnListUpdateNeeded ); |
|
1043 DoCreateWaitNoteL(); |
|
1044 } |
|
1045 } |
|
1046 SetStateOff( EPslnSkinChangeRequested ); |
|
1047 CleanupStack::PopAndDestroy( 3 ); // drmHelper, skinsrv, file |
|
1048 } |
|
1049 else |
|
1050 { |
|
1051 if ( entry->Protection() == EAknsSrvCountBased ) |
|
1052 { |
|
1053 errorBuf = StringLoader::LoadLC( R_PSLN_QTN_DRM_PREV_RIGHTS_SET ); |
|
1054 } |
|
1055 // Check for corruption. |
|
1056 if ( entry->IsCorrupted() ) |
|
1057 { |
|
1058 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL corrupt skin!"); |
|
1059 errorBuf = StringLoader::LoadLC( R_PSLN_QTN_SKINS_ERROR_CORRUPTED ); |
|
1060 } |
|
1061 |
|
1062 // Non-DRMHelper error handling. |
|
1063 if ( errorBuf ) |
|
1064 { |
|
1065 SetStateOff( EPslnSkinChangeRequested ); |
|
1066 ShowErrorNoteL( *errorBuf ); |
|
1067 CleanupStack::PopAndDestroy( errorBuf ); |
|
1068 } |
|
1069 // No errors, activate the skin. |
|
1070 else |
|
1071 { |
|
1072 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL 2"); |
|
1073 // Start changing active skin. |
|
1074 iModel->GuardActivationLC(); |
|
1075 TBool shownote = EFalse; |
|
1076 |
|
1077 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL directly"); |
|
1078 shownote = iModel->ActivateSkinL( skinIndex ); |
|
1079 |
|
1080 if ( shownote ) |
|
1081 { |
|
1082 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL skin activated"); |
|
1083 SetStateOn( EPslnSkinActivated ); |
|
1084 ShowProgressBarL(); |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 // If user declined to activate protected skin, re-initialize status |
|
1089 // flag. |
|
1090 if ( GetStatus( EPslnSkinChangeRequested ) ) |
|
1091 { |
|
1092 PSLN_TRACE_DEBUG("CPslnUi::ActivateSkinL decline DRM activation"); |
|
1093 SetStateOff( EPslnSkinChangeRequested ); |
|
1094 } |
|
1095 } |
|
1096 CleanupStack::PopAndDestroy(); // activation guard |
|
1097 } |
|
1098 } |
|
1099 } |
|
1100 |
|
1101 // --------------------------------------------------------------------------- |
|
1102 // CPslnUi::ActivateSoundsL |
|
1103 // --------------------------------------------------------------------------- |
|
1104 // |
|
1105 void CPslnUi::ActivateSoundsL() |
|
1106 { |
|
1107 PSLN_TRACE_DEBUG("CPslnUi::ActivateSoundsL"); |
|
1108 |
|
1109 // Is sounds are not supperted, ignore. |
|
1110 if ( !PslnFeatures::IsSoundsInSkinsSupported() |
|
1111 |
|
1112 // If sounds are supported, but general view is not active, ignore. |
|
1113 || iView && iView->Id().iUid != KPslnGeneralView.iUid ) |
|
1114 { |
|
1115 return; |
|
1116 } |
|
1117 |
|
1118 TPath skinPath; |
|
1119 CPslnSkinEntry* entry = iModel->VisibleSkin( iModel->ActiveSkinIndex() ); |
|
1120 if( entry ) |
|
1121 { |
|
1122 entry->GetSkinPath( skinPath ); |
|
1123 skinPath.Append( KPslnPathSeparator ); |
|
1124 } |
|
1125 else |
|
1126 { |
|
1127 User::Leave( KErrUnknown ); |
|
1128 } |
|
1129 |
|
1130 // Find sound files. |
|
1131 CPslnSoundActivator* activator = CPslnSoundActivator::NewLC(); |
|
1132 TInt numberOfSounds = 0; |
|
1133 activator->CollectSoundsL( skinPath, numberOfSounds ); |
|
1134 |
|
1135 PSLN_TRACE_DEBUG1("CPslnUi::ActivateSoundsL num of tunes %d", numberOfSounds ); |
|
1136 |
|
1137 if ( numberOfSounds <= 0 ) |
|
1138 { |
|
1139 CleanupStack::PopAndDestroy( activator ); |
|
1140 return; |
|
1141 } |
|
1142 |
|
1143 // Launch profile settings loader. |
|
1144 CPslnTaskActivateSounds* activateTask = new (ELeave) |
|
1145 CPslnTaskActivateSounds( *activator ); |
|
1146 CleanupStack::PushL( activateTask ); |
|
1147 |
|
1148 CreateAndShowWaitWrapperL( |
|
1149 *activateTask, |
|
1150 R_PSLN_QTN_GEN_NOTE_OPENING, |
|
1151 KNullDesC() ); |
|
1152 |
|
1153 HBufC* noteText = NULL; |
|
1154 |
|
1155 PSLN_TRACE_DEBUG1("CPslnUi::ActivateSoundsL error %d", activateTask->iActivationErr ); |
|
1156 |
|
1157 if( activateTask->iActivationErr == KErrNone ) |
|
1158 { |
|
1159 if ( numberOfSounds == 1 ) |
|
1160 { |
|
1161 noteText = StringLoader::LoadLC( |
|
1162 R_PSLN_QTN_SKINS_NOTE_TONE_ACTIVATED ); |
|
1163 } |
|
1164 else |
|
1165 { |
|
1166 noteText = StringLoader::LoadLC( |
|
1167 R_PSLN_QTN_SKINS_NOTE_TONES_ACTIVATED ); |
|
1168 } |
|
1169 |
|
1170 CAknConfirmationNote* note = |
|
1171 new (ELeave) CAknConfirmationNote( ETrue ); |
|
1172 note->ExecuteLD( *noteText ); |
|
1173 } |
|
1174 else |
|
1175 { |
|
1176 if( activateTask->iActivationErr == KErrPermissionDenied ) |
|
1177 { |
|
1178 noteText = StringLoader::LoadLC( |
|
1179 R_PSLN_QTN_PROFILES_INFO_TONE_NO_DRM ); |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 noteText = StringLoader::LoadLC( |
|
1184 R_PSLN_QTN_FILE_FORMAT_ERROR ); |
|
1185 } |
|
1186 CAknErrorNote* note = |
|
1187 new (ELeave) CAknErrorNote( ETrue ); |
|
1188 note->ExecuteLD( *noteText ); |
|
1189 } |
|
1190 |
|
1191 CleanupStack::PopAndDestroy( 3, activator ); |
|
1192 } |
|
1193 |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // CPslnUi::DownloadSkinL |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CPslnUi::DownloadSkinL() |
|
1199 { |
|
1200 PSLN_TRACE_DEBUG("CPslnUi::DownloadSkinL"); |
|
1201 iModel->DownloadSkinL(); |
|
1202 } |
|
1203 |
|
1204 // --------------------------------------------------------------------------- |
|
1205 // CPslnUi::CreateAndShowWaitWrapperL |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // |
|
1208 void CPslnUi::CreateAndShowWaitWrapperL( MAknBackgroundProcess& aTask, |
|
1209 const TInt aResourceID, const TDesC& aString, |
|
1210 const TBool aShowImmediately ) |
|
1211 { |
|
1212 HBufC* noteText = NULL; |
|
1213 if ( aString.Length() == 0 ) |
|
1214 { |
|
1215 noteText = StringLoader::LoadLC( aResourceID, iEikonEnv ); |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 noteText = StringLoader::LoadLC( aResourceID, aString, iEikonEnv ); |
|
1220 } |
|
1221 |
|
1222 CAknWaitNoteWrapper* wrapper = CAknWaitNoteWrapper::NewL(); |
|
1223 CleanupDeletePushL( wrapper ); |
|
1224 if ( wrapper ) |
|
1225 { |
|
1226 wrapper->ExecuteL( |
|
1227 R_PSLN_GENERAL_WAIT_NOTE, aTask, *noteText, aShowImmediately ); |
|
1228 } |
|
1229 |
|
1230 CleanupStack::PopAndDestroy( 2, noteText ); // noteText, wrapper |
|
1231 } |
|
1232 |
|
1233 // --------------------------------------------------------------------------- |
|
1234 // CPslnUi::AddPluginToTabL |
|
1235 // --------------------------------------------------------------------------- |
|
1236 // |
|
1237 #ifndef RD_CONTROL_PANEL |
|
1238 void CPslnUi::AddPluginToTabL( CPslnFWPluginInterface& aPlugin ) |
|
1239 { |
|
1240 PSLN_TRACE_DEBUG("CPslnUi::AddPluginToTabL Start"); |
|
1241 HBufC* buf = HBufC::NewLC( KPslnItemLength ); |
|
1242 TPtr ptrBuf = buf->Des(); |
|
1243 aPlugin.GetTabTextL( ptrBuf ); |
|
1244 TInt pluginUid = aPlugin.Id().iUid; |
|
1245 if ( iTabGroup ) |
|
1246 { |
|
1247 iTabGroup->AddTabL( pluginUid, ptrBuf ); |
|
1248 } |
|
1249 PSLN_TRACE_DEBUG("CPslnUi::AddPluginToTabL Default Plugin added to tab"); |
|
1250 CleanupStack::PopAndDestroy( buf ); |
|
1251 } |
|
1252 #endif //!RD_CONTROL_PANEL |
|
1253 |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // Handles Exit command. |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CPslnUi::HandleCmdExitL() |
|
1259 { |
|
1260 Exit(); |
|
1261 } |
|
1262 |
|
1263 // --------------------------------------------------------------------------- |
|
1264 // Shows error note. |
|
1265 // --------------------------------------------------------------------------- |
|
1266 // |
|
1267 void CPslnUi::ShowErrorNoteL( HBufC& aErrorBuf ) const |
|
1268 { |
|
1269 // Display global note. |
|
1270 CAknGlobalNote* errorNote = CAknGlobalNote::NewLC(); |
|
1271 errorNote->ShowNoteL( EAknGlobalErrorNote, aErrorBuf ); |
|
1272 CleanupStack::PopAndDestroy( errorNote ); |
|
1273 } |
|
1274 // --------------------------------------------------------------------------- |
|
1275 // Callback when idle time occurs for skin update. |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // |
|
1278 TInt CPslnUi::DoCreateWaitNoteL( TAny* aAny ) |
|
1279 { |
|
1280 static_cast< CPslnUi* >( aAny )->DoCreateWaitNoteL(); |
|
1281 return EFalse; |
|
1282 } |
|
1283 // --------------------------------------------------------------------------- |
|
1284 // CPslnUi::DoCreateWaitNoteL |
|
1285 // --------------------------------------------------------------------------- |
|
1286 // |
|
1287 void CPslnUi::DoCreateWaitNoteL() |
|
1288 { |
|
1289 CPslnTaskGenericUpdate* updateTask = |
|
1290 new (ELeave) CPslnTaskGenericUpdate( |
|
1291 *this, &CPslnModel::PerformCompleteUpdateL, ETrue ); |
|
1292 CleanupStack::PushL( updateTask ); |
|
1293 |
|
1294 CreateAndShowWaitWrapperL( *updateTask, |
|
1295 R_PSLN_QTN_GEN_NOTE_OPENING, KNullDesC(), EFalse ); |
|
1296 |
|
1297 User::LeaveIfError( updateTask->iCallErr ); |
|
1298 |
|
1299 CleanupStack::PopAndDestroy( updateTask ); |
|
1300 } |
|
1301 |
|
1302 // --------------------------------------------------------------------------- |
|
1303 // This operation needs to be atomic. If it leaves, set state back to previous. |
|
1304 // --------------------------------------------------------------------------- |
|
1305 // |
|
1306 TInt CPslnUi::ActivateSkin( const TInt aPslnStatus ) |
|
1307 { |
|
1308 TInt error = KErrNone; |
|
1309 if ( !GetStatus( aPslnStatus ) ) |
|
1310 { |
|
1311 SetStateOn( aPslnStatus ); |
|
1312 TRAPD( err, ActivateSkinL() ); |
|
1313 if ( err != KErrNone ) |
|
1314 { |
|
1315 SetStateOff( aPslnStatus ); |
|
1316 error = err; |
|
1317 } |
|
1318 } |
|
1319 return error; |
|
1320 } |
|
1321 |
|
1322 // --------------------------------------------------------------------------- |
|
1323 // Non-leaving version of AddPluginToTabL. |
|
1324 // --------------------------------------------------------------------------- |
|
1325 // |
|
1326 #ifndef RD_CONTROL_PANEL |
|
1327 TInt CPslnUi::AddPluginToTab( CPslnFWPluginInterface& aPlugin ) |
|
1328 { |
|
1329 TRAPD( err, AddPluginToTabL( aPlugin ) ); |
|
1330 if ( err ) |
|
1331 { |
|
1332 PSLN_TRACE_DEBUG1("CPslnUi::AddPluginToTab plugin fails: ", aPlugin.Id().iUid ); |
|
1333 } |
|
1334 return err; |
|
1335 } |
|
1336 #endif //!RD_CONTROL_PANEL |
|
1337 |
|
1338 // --------------------------------------------------------------------------- |
|
1339 // Show skin activated note. |
|
1340 // --------------------------------------------------------------------------- |
|
1341 // |
|
1342 void CPslnUi::SkinDeployedL() |
|
1343 { |
|
1344 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
1345 // Only set sound state - no conf note anymore. |
|
1346 SetStateOn( EPslnSoundActivationPending ); |
|
1347 #else |
|
1348 HBufC* skinName = HBufC::NewLC( KMaxName ); |
|
1349 TPtr skinNamePtr = skinName->Des(); |
|
1350 TInt skinIndex = iModel->ActiveSkinIndex(); |
|
1351 |
|
1352 iModel->GetSkinNameByIndex( |
|
1353 skinIndex, |
|
1354 skinNamePtr, |
|
1355 EPslnSkinNameTypeTitle ); |
|
1356 |
|
1357 // Show confirmation note about skin change. |
|
1358 HBufC* noteTxt = StringLoader::LoadL( |
|
1359 R_PSLN_CONFIRM_ACTIVE_SKIN_STRING, |
|
1360 skinNamePtr, |
|
1361 iEikonEnv ); |
|
1362 CleanupStack::PushL( noteTxt ); |
|
1363 |
|
1364 SetStateOn( EPslnSoundActivationPending ); |
|
1365 CAknConfirmationNote* note = |
|
1366 new (ELeave) CAknConfirmationNote( ETrue ); |
|
1367 note->ExecuteLD( *noteTxt ); |
|
1368 CleanupStack::PopAndDestroy( 2, skinName ); // skinName, noteTxt |
|
1369 |
|
1370 #endif |
|
1371 iGeneralThemeView->UpdateSkinListItemsL(); |
|
1372 } |
|
1373 |
|
1374 // --------------------------------------------------------------------------- |
|
1375 // Creates model class. |
|
1376 // --------------------------------------------------------------------------- |
|
1377 // |
|
1378 void CPslnUi::CreateModelL() |
|
1379 { |
|
1380 if ( !GetStatus( EPslnModelCreated ) ) |
|
1381 { |
|
1382 iModel = CPslnModel::NewL( this ); |
|
1383 SetStateOn( EPslnModelCreated ); |
|
1384 } |
|
1385 } |
|
1386 |
|
1387 // --------------------------------------------------------------------------- |
|
1388 // Callback when idle time occurs for skin activation. |
|
1389 // --------------------------------------------------------------------------- |
|
1390 // |
|
1391 TInt CPslnUi::DoActivateSkinL( TAny* aAny ) |
|
1392 { |
|
1393 static_cast< CPslnUi* >( aAny )->DoActivateSkinL(); |
|
1394 return EFalse; |
|
1395 } |
|
1396 |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // Callback when idle time occurs for skin activation. |
|
1399 // --------------------------------------------------------------------------- |
|
1400 // |
|
1401 void CPslnUi::DoActivateSkinL() |
|
1402 { |
|
1403 TInt error = ActivateSkin( EPslnSkinChangeRequested ); |
|
1404 if ( error == KErrNoMemory ) |
|
1405 { |
|
1406 HBufC* errorBuf = StringLoader::LoadLC( |
|
1407 R_PSLN_QTN_MEMLO_RAM_OUT_OF_MEM ); |
|
1408 // Display global note. |
|
1409 CAknGlobalNote* errorNote = CAknGlobalNote::NewLC(); |
|
1410 errorNote->ShowNoteL( EAknGlobalErrorNote, *errorBuf ); |
|
1411 CleanupStack::PopAndDestroy( 2 ); // errorNote & errorBuf |
|
1412 } |
|
1413 } |
|
1414 |
|
1415 |
|
1416 /** |
|
1417 * Handle USB Callback. |
|
1418 */ |
|
1419 void CPslnUi::HandleUSBCallBackL() |
|
1420 { |
|
1421 if ( iView && iView->Id().iUid == KPslnGeneralView.iUid ) |
|
1422 { |
|
1423 TInt value = KErrNone; |
|
1424 iEnableUSBWatchProperty.Get(value); |
|
1425 |
|
1426 if (value == KUsbPersonalityIdMS ) |
|
1427 { |
|
1428 iUSBAttached = ETrue; |
|
1429 } |
|
1430 else |
|
1431 { |
|
1432 iUSBAttached = EFalse; |
|
1433 } |
|
1434 } |
|
1435 } |
|
1436 |
|
1437 // --------------------------------------------------------------------------- |
|
1438 // CPslnUi::ShowProgressBarL |
|
1439 // --------------------------------------------------------------------------- |
|
1440 // |
|
1441 void CPslnUi::ShowProgressBarL() |
|
1442 { |
|
1443 if ( iWaitDialog == NULL ) |
|
1444 { |
|
1445 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
1446 ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ), ETrue ); |
|
1447 iWaitDialog->PrepareLC( R_PSLN_GENERAL_WAIT_NOTE ); |
|
1448 |
|
1449 HBufC* noteText = NULL; |
|
1450 noteText = StringLoader::LoadLC( R_PSLN_QTN_GEN_NOTE_PROCESSING, iEikonEnv ); |
|
1451 iWaitDialog->SetTextL( *noteText ); |
|
1452 CleanupStack::PopAndDestroy( noteText ); |
|
1453 |
|
1454 iWaitDialog->RunLD(); |
|
1455 } |
|
1456 } |
|
1457 |
|
1458 // --------------------------------------------------------------------------- |
|
1459 // CPslnUi::HideProgressBar |
|
1460 // --------------------------------------------------------------------------- |
|
1461 // |
|
1462 void CPslnUi::HideProgressBar() |
|
1463 { |
|
1464 if( iWaitDialog ) |
|
1465 { |
|
1466 TRAP_IGNORE( iWaitDialog->ProcessFinishedL() ) |
|
1467 delete iWaitDialog; |
|
1468 iWaitDialog = NULL; |
|
1469 } |
|
1470 } |
|
1471 |
|
1472 // End of File |
|
1473 |