|
1 /* |
|
2 * Copyright (c) 2003 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: Screensaver engine class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <barsread.h> |
|
21 #include <activitymanager.h> |
|
22 #include <featmgr.h> |
|
23 #include <PUAcodes.hrh> |
|
24 #include <Profile.hrh> |
|
25 #include <screensaver.rsg> |
|
26 #include <AknUtils.h> |
|
27 |
|
28 #include "screensaverengine.h" |
|
29 #include "screensaverctrlmovingtext.h" |
|
30 #include "screensavershareddatai.h" |
|
31 #include "screensavershareddatamonitor.h" |
|
32 #include "screensaverappui.h" |
|
33 #include "ScreensaverUtils.h" |
|
34 #include "screensaverutility.h" |
|
35 |
|
36 |
|
37 // Minimum plugin suspension time |
|
38 const TInt KMinPluginSuspensionTime = 500000; // 0.5 sec |
|
39 |
|
40 // Inactivity timeout in seconds when keys locked |
|
41 const TInt KTimeoutShort = 5; |
|
42 |
|
43 const TInt KNoPreview = 0; |
|
44 |
|
45 const TInt KPreviewTimeout = 10000000; // 10 sec |
|
46 |
|
47 const TText KSilentProfileInd= KPuaCodeSilentSymbol; |
|
48 const TText KSilentVibraInd= KPuaCodeAprofSilentVibra; |
|
49 const TText KSoundVibraInd= KPuaCodeAprofSoundVibra; |
|
50 const TText KSoundInd= KPuaCodeAprofSound; |
|
51 |
|
52 // Class CScreensaverEngine |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CScreensaverEngine::NewL |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CScreensaverEngine* CScreensaverEngine::NewL() |
|
59 { |
|
60 CScreensaverEngine* self = new (ELeave) CScreensaverEngine(); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(); //self |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CScreensaverEngine::~CScreensaverEngine |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CScreensaverEngine::~CScreensaverEngine( ) |
|
72 { |
|
73 StopActivityMonitoring( iActivityManagerScreensaver ); |
|
74 StopActivityMonitoring( iActivityManagerScreensaverShort ); |
|
75 DisableSharedDataAndMonitor(); |
|
76 delete iIndicatorArray; |
|
77 KillTimer( iPreviewTimer ); |
|
78 iAknUiServer.Close(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CScreensaverEngine::SharedDataInterface |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CScreensaverSharedDataI* CScreensaverEngine::SharedDataInterface( ) const |
|
86 { |
|
87 return iSharedDataI; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CScreensaverEngine::ResetInactivityTimeout |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CScreensaverEngine::ResetInactivityTimeout() |
|
95 { |
|
96 if ( iActivityManagerScreensaver ) |
|
97 { |
|
98 SCRLOGGER_WRITEF(_L("SCR: Model: Setting inac timeout to %d secs"), |
|
99 Timeout()); |
|
100 iActivityManagerScreensaver->SetInactivityTimeout( Timeout( ) ); |
|
101 } |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CScreensaverEngine::ScreenSaverIsOn |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 TBool CScreensaverEngine::ScreenSaverIsOn( ) const |
|
109 { |
|
110 return iScreenSaverIsOn; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CScreensaverEngine::ScreenSaverIsPreviewing |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TBool CScreensaverEngine::ScreenSaverIsPreviewing( ) const |
|
118 { |
|
119 return iScreenSaverIsPreviewing; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CScreensaverEngine::StartScreenSaver |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CScreensaverEngine::StartScreenSaver( ) |
|
127 { |
|
128 SCRLOGGER_WRITE("Model: StartScreenSaver()"); |
|
129 |
|
130 // Ignore start while in preview to avoid double-start lock |
|
131 if ( iScreenSaverIsPreviewing ) |
|
132 { |
|
133 // Reset user activity so that screensaver is enabled after |
|
134 // preview even if no user activity happens any more |
|
135 // Note that this puts on backlight but it should be on at this |
|
136 // time anyway (unless a plugin set it off, but what the hey) |
|
137 User::ResetInactivityTime(); |
|
138 return; |
|
139 } |
|
140 |
|
141 // if (DisplayFlag() == 1) then screensaver can be activated |
|
142 // else screensaver can't come during phone call. |
|
143 // Also not OK to start until system startup has been completed |
|
144 if ( ( !DisplayFlag() ) && ( iSharedDataI->IsSystemStartupComplete() ) ) |
|
145 { |
|
146 if ( !iScreenSaverIsOn ) |
|
147 { |
|
148 // connect in StartScreenSaver, intercept and capture application |
|
149 // key event. It makes sure this event will not be received |
|
150 // by other applictions when screensaver is activated. |
|
151 iAknUiServer.ConnectAndSendAppsKeySuppress(ETrue); |
|
152 iScreenSaverIsOn = ETrue; |
|
153 |
|
154 // Report whether started from Idle BEFORE bringing to foreground |
|
155 iSharedDataI->SetSSStartedFromIdleStatus(); |
|
156 |
|
157 ScreensaverUtility::BringToForeground(); |
|
158 |
|
159 SCRLOGGER_WRITE("Model: SS is displaying (BringToForeground)"); |
|
160 |
|
161 // Compress heap while displaying. No longer possible to |
|
162 // compress all heaps (User::CompressAllHeaps() is a no-op) |
|
163 User::Heap().Compress(); |
|
164 |
|
165 DisplayObject(); |
|
166 } |
|
167 else |
|
168 { |
|
169 SCRLOGGER_WRITE("Model: StartScreenSaver(): already on, ignore"); |
|
170 } |
|
171 } |
|
172 else |
|
173 { |
|
174 SCRLOGGER_WRITE("Model: SS not displaying, not allowed."); |
|
175 ResetInactivityTimeout( ); |
|
176 } |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CScreensaverEngine::StopScreenSaver |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CScreensaverEngine::StopScreenSaver() |
|
184 { |
|
185 SCRLOGGER_WRITE("Stopping Screensaver"); |
|
186 |
|
187 if( iScreenSaverIsOn ) |
|
188 { |
|
189 // disconnect in StopScreenSaver, It makes sure other applications could |
|
190 // receive application key event when screensaver is disactivated. |
|
191 iAknUiServer.ConnectAndSendAppsKeySuppress(EFalse); |
|
192 // Indicate we've stopped |
|
193 iSharedDataI->SetScreensaverStatus( EFalse ); |
|
194 |
|
195 iScreenSaverIsOn = EFalse ; |
|
196 |
|
197 View()->HideDisplayObject(); |
|
198 } |
|
199 |
|
200 |
|
201 if( iScreenSaverIsPreviewing ) |
|
202 { |
|
203 iSharedDataI->SetScreensaverPreviewMode( KNoPreview ); |
|
204 |
|
205 iScreenSaverIsPreviewing = EFalse; |
|
206 |
|
207 View()->HideDisplayObject(); |
|
208 |
|
209 // Update preview progress |
|
210 iSharedDataI->SetScreensaverPreviewState( EScreenSaverPreviewEnd ); |
|
211 iSharedDataI->SetScreensaverPreviewState( EScreenSaverPreviewNone ); |
|
212 |
|
213 KillTimer( iPreviewTimer ); |
|
214 } |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CScreensaverEngine::StartPreviewModeL |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CScreensaverEngine::StartPreviewModeL( ) |
|
222 { |
|
223 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverEngine::StartPreviewModeL()") ); |
|
224 |
|
225 iScreenSaverIsPreviewing = ETrue; |
|
226 // Change the display object into what's being previewed |
|
227 View()->CreatePreviewDisplayObjectL(); |
|
228 |
|
229 if( iSharedDataI->ScreensaverPreviewState() == EScreenSaverPreviewError ) |
|
230 { |
|
231 iScreenSaverIsPreviewing = EFalse; |
|
232 return; |
|
233 } |
|
234 |
|
235 StartPreviewTimer(); |
|
236 |
|
237 UpdateIndicatorAttributes(); |
|
238 |
|
239 View()->ShowDisplayObject(); |
|
240 |
|
241 iSharedDataI->SetScreensaverPreviewState( EScreenSaverPreviewStart ); |
|
242 |
|
243 ScreensaverUtility::BringToForeground(); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CScreensaverEngine::DisplayObject |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CScreensaverEngine::DisplayObject() |
|
251 { |
|
252 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverEngine::DisplayObject()") ); |
|
253 //if the display object type is plugin, we should recreate the object |
|
254 //cause when plugin is suspend status, it will be changed to the default |
|
255 //type |
|
256 if ( iSharedDataI->DisplayObjectType() == EDisplayPlugin ) |
|
257 { |
|
258 View()->SetDisplayObject( EDisplayPlugin ); |
|
259 } |
|
260 |
|
261 UpdateIndicatorAttributes(); |
|
262 |
|
263 View()->ShowDisplayObject(); |
|
264 |
|
265 iSharedDataI->SetScreensaverStatus( ETrue ); |
|
266 } |
|
267 |
|
268 // ---------------------------------------------------------------------------- |
|
269 // CScreensaverEngine::StartSuspendTimer |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void CScreensaverEngine::StartSuspendTimer( TInt aSec ) |
|
273 { |
|
274 KillTimer( iSuspendTimer ); |
|
275 |
|
276 // Let's keep this operation reasonable. |
|
277 TInt realTime = ( aSec > KMinPluginSuspensionTime ) |
|
278 ? aSec : KMinPluginSuspensionTime; |
|
279 |
|
280 TRAP_IGNORE( iSuspendTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
|
281 |
|
282 iSuspendTimer->Start( realTime, realTime, TCallBack( |
|
283 HandleSuspendTimerExpiry, this ) ); |
|
284 |
|
285 SCRLOGGER_WRITEF(_L("SCR: iSuspendTimer->Start(%d, %d, HandleSuspensionTimerTimeout)"), |
|
286 realTime, realTime); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CScreensaverEngine::IndicatorArray |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 CScreensaverIndicatorArray& CScreensaverEngine::IndicatorArray() const |
|
294 { |
|
295 return *iIndicatorArray; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CScreensaverEngine::GetColorModel |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 const TScreensaverColorModel& CScreensaverEngine::GetColorModel() const |
|
303 { |
|
304 SCRLOGGER_WRITE("Host / Own use: GetColorModel()"); |
|
305 |
|
306 return iColorModel; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CScreensaverEngine::AddPartialModeLevel |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void CScreensaverEngine::AddPartialModeLevel( TInt aBpp, |
|
314 TScreensaverPartialModeType aType ) |
|
315 { |
|
316 TInt i; |
|
317 for (i = 0; i < iColorModel.iNumberOfPartialModes; i++ ) |
|
318 { |
|
319 if ( (iColorModel.iPartialModes[i].iBpp == aBpp) |
|
320 && (iColorModel.iPartialModes[i].iType == aType) ) |
|
321 { |
|
322 break; |
|
323 } |
|
324 } |
|
325 if ( i >= iColorModel.iNumberOfPartialModes ) |
|
326 { |
|
327 iColorModel.iPartialModes[iColorModel.iNumberOfPartialModes].iBpp |
|
328 = aBpp; |
|
329 iColorModel.iPartialModes[iColorModel.iNumberOfPartialModes].iType |
|
330 = aType; |
|
331 iColorModel.iNumberOfPartialModes++; |
|
332 } |
|
333 } |
|
334 |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CScreensaverEngine::UpdateIndicatorAttributes |
|
338 // This method is for updating screensaver indicator |
|
339 // attributes (payloads and dependencies). This is where indicator |
|
340 // payload values are connected to real values. |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 void CScreensaverEngine::UpdateIndicatorAttributes() |
|
344 { |
|
345 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverView::UpdateIndicatorAttributes()")); |
|
346 |
|
347 TIndicatorPayload payload; |
|
348 |
|
349 // First integer types. |
|
350 payload.iType = EPayloadTypeInteger; |
|
351 |
|
352 // Missed calls. |
|
353 payload.iInteger = iSharedDataI->NewMissedCalls(); |
|
354 iIndicatorArray->SetIndicatorPayload( ESsMissedCallsInd, payload ); |
|
355 // Missed calls indicator depends on status of new contacts note. |
|
356 iIndicatorArray->SetDependencyStatus( ESsMissedCallsInd, |
|
357 !iSharedDataI->IsNCNActive() ); |
|
358 |
|
359 // Unread messages |
|
360 payload.iInteger = iSharedDataI->UnreadMessagesNumber(); |
|
361 iIndicatorArray->SetIndicatorPayload( ESsNewMessagesInd, payload ); |
|
362 iIndicatorArray->SetDependencyStatus( ESsNewMessagesInd, (payload.iInteger > 0 |
|
363 ? EFalse : ETrue) ); |
|
364 |
|
365 // Then string types. |
|
366 payload.iType = EPayloadTypeText; |
|
367 |
|
368 // Profile information |
|
369 TBool nameDisplayed = (iSharedDataI->ActiveProfile() == EProfileGeneralId) ? EFalse : ETrue; |
|
370 TBool isSilent = iSharedDataI->IsSilentMode(); |
|
371 payload.iText.Zero( ); |
|
372 |
|
373 if ( nameDisplayed || isSilent || iShowExtendedProfileInd ) |
|
374 { |
|
375 // append alert type indicator |
|
376 if ( iShowExtendedProfileInd ) |
|
377 { |
|
378 TBool isVibra = iSharedDataI->IsVibraMode( ); |
|
379 if ( isSilent ) |
|
380 { |
|
381 payload.iText.Append( isVibra ? KSilentVibraInd |
|
382 : KSilentProfileInd ); |
|
383 } |
|
384 else |
|
385 { |
|
386 payload.iText.Append( isVibra ? KSoundVibraInd : KSoundInd ); |
|
387 } |
|
388 } |
|
389 else |
|
390 { |
|
391 // Check if this is silent mode and we have to add indicator |
|
392 // character to string. |
|
393 if ( isSilent ) |
|
394 { |
|
395 payload.iText.Append( KSilentProfileInd ); |
|
396 } |
|
397 } |
|
398 |
|
399 if ( nameDisplayed ) |
|
400 { |
|
401 const TDesC& profile = iSharedDataI->ProfileName( ); |
|
402 // Don't panic if profile name is too long, 'less than' ensures |
|
403 // the 1 free space used for silent/vibra |
|
404 if ( profile.Length( ) < KMaxPayloadTextLength ) |
|
405 { |
|
406 // append profile name |
|
407 payload.iText.Append( profile ); |
|
408 } |
|
409 } |
|
410 |
|
411 // Profile indicator shown |
|
412 iIndicatorArray->SetDependencyStatus( ESsProfileInd, EFalse ); |
|
413 } |
|
414 else |
|
415 { |
|
416 // Profile indicator not shown |
|
417 iIndicatorArray->SetDependencyStatus( ESsProfileInd, ETrue ); |
|
418 } |
|
419 |
|
420 iIndicatorArray->SetIndicatorPayload( ESsProfileInd, payload ); |
|
421 |
|
422 // AM/PM indicator is text but it is updated with every draw |
|
423 // in screensaver control, so that it changes properly even if |
|
424 // time rolls over between draws. Note that Am/Pm information is |
|
425 // maintained by screensaver display object, not shareddatainterface. |
|
426 if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
427 { |
|
428 // Am/Pm indicator depends on 12-hour clock |
|
429 iIndicatorArray->SetDependencyStatus( ESsAmPmInd, !ScreensaverUtility::Query12HourClock( ) ); |
|
430 } |
|
431 else |
|
432 { |
|
433 // Make sure it's not shown |
|
434 iIndicatorArray->SetDependencyStatus( ESsAmPmInd, ETrue ); |
|
435 } |
|
436 |
|
437 |
|
438 // Key lock indicator depends on status of key guard. |
|
439 iIndicatorArray->SetDependencyStatus( ESsKeyLockInd, !iSharedDataI->IsKeyguardOn() ); |
|
440 |
|
441 // Instant messaging indicator depends on existence of unseen IMs |
|
442 iIndicatorArray->SetDependencyStatus( ESsImInd, !iSharedDataI->IsHaveNewInstantMessages() ); |
|
443 |
|
444 // Mail indicator depends on existence of unseen mails |
|
445 iIndicatorArray->SetDependencyStatus( ESsMailInd, !iSharedDataI->IsHaveNewEmail() ); |
|
446 |
|
447 // Voicemail indicator depends on existence of unseen voicemail messages |
|
448 iIndicatorArray->SetDependencyStatus( ESsVoicemailInd, !iSharedDataI->IsHaveNewVoicemail() ); |
|
449 |
|
450 //Set visibility for indicators if selected screensaver is a plugin |
|
451 //which overides standard indicators |
|
452 //TODO: Convert the iControlType to the iSettingType |
|
453 // if ( (iSharedDataI->ScreensaverObjectType() == EDisplayPlugin ) && |
|
454 // ( AppUi()->ScreensaverView()->PluginFlags() & CScreensaverView::EPluginFlagOverrideIndicators ) ) |
|
455 // { |
|
456 iIndicatorArray->SetVisibilityForIndicators(); |
|
457 // } |
|
458 } |
|
459 |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CScreensaverEngine::CScreensaverEngine |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 CScreensaverEngine::CScreensaverEngine() |
|
466 { |
|
467 |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CScreensaverEngine::ConstructL |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CScreensaverEngine::ConstructL( ) |
|
475 { |
|
476 SetupColorModelL(); |
|
477 |
|
478 EnableSharedDataAndMonitorL(); |
|
479 |
|
480 iIndicatorArray = CScreensaverIndicatorArray::NewL( iSharedDataI->IsInvertedColors() ); |
|
481 |
|
482 StartActivityMonitoringL(); |
|
483 |
|
484 FeatureManager::InitializeLibL(); |
|
485 iShowExtendedProfileInd |
|
486 = FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ); |
|
487 FeatureManager::UnInitializeLib(); |
|
488 |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CScreensaverEngine::EnableSharedDataAndMonitorL |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void CScreensaverEngine::EnableSharedDataAndMonitorL() |
|
496 { |
|
497 iSharedDataI = CScreensaverSharedDataI::NewL(); |
|
498 |
|
499 iSharedDataMonitor = CScreensaverSharedDataMonitor::NewL( iSharedDataI ); |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CScreensaverEngine::DisableSharedDataAndMonitor |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 void CScreensaverEngine::DisableSharedDataAndMonitor( ) |
|
507 { |
|
508 delete iSharedDataMonitor; |
|
509 iSharedDataMonitor = NULL; |
|
510 |
|
511 delete iSharedDataI; |
|
512 iSharedDataI = NULL; |
|
513 |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CScreensaverEngine::StartActivityMonitoringL |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 void CScreensaverEngine::StartActivityMonitoringL( ) |
|
521 { |
|
522 // Actually screensaver is the last exe to be launch at the startup, |
|
523 // so when it is being launched the elapsed time(User::InactivityTime()) |
|
524 // is greater than the interval (15 sec) which screensaver pass to start |
|
525 // activitymanager for inactivitycallback. |
|
526 // So it has to do to reset inactivitytime (User::ResetInactivityTime() ) |
|
527 // once in the screensaver constructor so that the inactivity callback |
|
528 // called after the interval time expired. |
|
529 User::ResetInactivityTime(); |
|
530 |
|
531 // Start monitoring activity for screensaver |
|
532 iActivityManagerScreensaver |
|
533 = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
534 iActivityManagerScreensaver->Start( Timeout(), |
|
535 TCallBack( HandleInactiveEventL,this ), |
|
536 TCallBack( HandleActiveEventL, this ) ); |
|
537 |
|
538 // Start monitoring activity for screensaver, short timeout |
|
539 iActivityManagerScreensaverShort |
|
540 = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
541 |
|
542 iActivityManagerScreensaverShort->Start( KTimeoutShort, |
|
543 TCallBack( HandleInactiveEventShortL, this ), |
|
544 TCallBack( HandleActiveEventShortL, this ) ); |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CScreensaverEngine::StopActivityMonitoring |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void CScreensaverEngine::StopActivityMonitoring( CUserActivityManager*& aActivityManager ) |
|
552 { |
|
553 if ( aActivityManager ) |
|
554 { |
|
555 aActivityManager->Cancel(); |
|
556 delete aActivityManager; |
|
557 aActivityManager = NULL; |
|
558 } |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CScreensaverEngine::SetupColorModelL |
|
563 // THIS IS TEMPORARY VERSION OF SetupColorModelL function. It is used until |
|
564 // new version of LcdPartialMode module is integrated. |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CScreensaverEngine::SetupColorModelL() |
|
568 { |
|
569 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverEngine::SetupColorModelL()") ); |
|
570 TResourceReader reader; |
|
571 TInt i, ctmp; |
|
572 |
|
573 TInt suggestedDrawingMode; |
|
574 |
|
575 CEikonEnv::Static()->CreateResourceReaderLC( reader, R_SCREENSAVER_COLOR_MODEL ); |
|
576 suggestedDrawingMode = reader.ReadInt32( ); |
|
577 |
|
578 // |
|
579 // Let's find out how many partial modes hardware |
|
580 // actually supports. |
|
581 // |
|
582 AddPartialModeLevel( (TInt)3, |
|
583 (TScreensaverPartialModeType)EPartialModeTypeMostPowerSaving ); |
|
584 AddPartialModeLevel( (TInt)3, |
|
585 (TScreensaverPartialModeType)EPartialModeTypeDefault ); |
|
586 AddPartialModeLevel( (TInt)16, |
|
587 (TScreensaverPartialModeType)EPartialModeTypeFull ); |
|
588 |
|
589 if ( suggestedDrawingMode == ESsColorModel3BitMode ) |
|
590 { |
|
591 // This can always be done, just set default partial mode to |
|
592 // most power saving. First try 'most power saving' and if not supported |
|
593 // then try default. if default isn't supported leave with error code. |
|
594 iColorModel.iSystemPartialMode.iBpp = 3; |
|
595 iColorModel.iSystemPartialMode.iType |
|
596 = EPartialModeTypeMostPowerSaving; |
|
597 } |
|
598 |
|
599 // Read color indices for 3-bit mode. |
|
600 reader.Read( iColorModel.iColors, 8 * sizeof(TInt16) ); |
|
601 |
|
602 // Read rgb values for gradient effect. |
|
603 for (i = 0; i < 6; i++ ) |
|
604 { |
|
605 ctmp = reader.ReadInt32( ); |
|
606 iColorModel.iDarkGradient[i] = TRgb( ctmp ); |
|
607 } |
|
608 |
|
609 for (i = 0; i < 6; i++ ) |
|
610 { |
|
611 ctmp = reader.ReadInt32( ); |
|
612 iColorModel.iLightGradient[i] = TRgb( ctmp ); |
|
613 } |
|
614 |
|
615 CleanupStack::PopAndDestroy( ); // reader |
|
616 } |
|
617 |
|
618 // ---------------------------------------------------------------------------- |
|
619 // CScreensaverEngine::StartPreviewTimer |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 void CScreensaverEngine::StartPreviewTimer() |
|
623 { |
|
624 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverEngine::StartPreviewTimer()") ); |
|
625 |
|
626 KillTimer( iPreviewTimer ); |
|
627 |
|
628 TRAP_IGNORE( iPreviewTimer = CPeriodic::NewL( CActive::EPriorityHigh ) ); |
|
629 |
|
630 iPreviewTimer->Start( KPreviewTimeout, KPreviewTimeout, TCallBack( |
|
631 HandlePreviewTimerExpiry, this ) ); |
|
632 |
|
633 SCRLOGGER_WRITEF(_L("SCR: iPreviewTimer->Start(%d, %d, HandlePreviewTimerTimeout)"), |
|
634 KPreviewTimeout,KPreviewTimeout); |
|
635 } |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // CScreensaverEngine::KillTimer |
|
639 // Stops and deletes a timer |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 void CScreensaverEngine::KillTimer( CPeriodic*& aTimer ) |
|
643 { |
|
644 if ( aTimer ) |
|
645 { |
|
646 aTimer->Cancel( ); |
|
647 delete aTimer; |
|
648 aTimer = NULL; |
|
649 } |
|
650 } |
|
651 |
|
652 // ----------------------------------------------------------------------------- |
|
653 // CScreensaverEngine::HandlePreviewTimerExpiry |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 TInt CScreensaverEngine::HandlePreviewTimerExpiry( TAny* aPtr ) |
|
657 { |
|
658 CScreensaverEngine* Engine = STATIC_CAST(CScreensaverEngine*, aPtr); |
|
659 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverView::HandlePreviewTimerTimeout()")); |
|
660 |
|
661 Engine->KillTimer( Engine->iPreviewTimer ); |
|
662 Engine->StopScreenSaver(); |
|
663 |
|
664 return KErrNone; |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CScreensaverEngine::HandleActiveEventL |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 TInt CScreensaverEngine::HandleActiveEventL( TAny* /* aPtr */) |
|
672 { |
|
673 SCRLOGGER_WRITE("HandleActiveEventL(), do nothing"); |
|
674 // We can be pretty sure the short timeout has passed and its |
|
675 // active event handler stops the saver |
|
676 return KErrNone; |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // CScreensaverEngine::HandleInactiveEventL |
|
681 // ----------------------------------------------------------------------------- |
|
682 // |
|
683 TInt CScreensaverEngine::HandleInactiveEventL( TAny* aPtr ) |
|
684 { |
|
685 SCRLOGGER_WRITE("HandleInactiveEventL(), starting screensaver"); |
|
686 |
|
687 CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr); |
|
688 |
|
689 // Double-start is OK, it will be checked in StartScreenSaver() |
|
690 _this->StartScreenSaver( ); |
|
691 |
|
692 return KErrNone; |
|
693 } |
|
694 |
|
695 // ----------------------------------------------------------------------------- |
|
696 // CScreensaverEngine::HandleActiveEventShortL |
|
697 // ----------------------------------------------------------------------------- |
|
698 // |
|
699 TInt CScreensaverEngine::HandleActiveEventShortL( TAny* aPtr ) |
|
700 { |
|
701 SCRLOGGER_WRITE("HandleActiveEventShortL(), stopping saver"); |
|
702 STATIC_CAST(CScreensaverEngine*, aPtr)->StopScreenSaver(); |
|
703 return KErrNone; |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CScreensaverEngine::HandleInactiveEventShortL |
|
708 // ----------------------------------------------------------------------------- |
|
709 // |
|
710 TInt CScreensaverEngine::HandleInactiveEventShortL( TAny* aPtr ) |
|
711 { |
|
712 SCRLOGGER_WRITE("HandleInactiveEventShortL()"); |
|
713 // Start, if keys are locked and short timeout in use |
|
714 CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr); |
|
715 |
|
716 if ( _this->iSharedDataI->IsKeyguardOn() ) |
|
717 { |
|
718 SCRLOGGER_WRITE("HandleInactiveEventShortL() starting saver"); |
|
719 _this->StartScreenSaver( ); |
|
720 } |
|
721 |
|
722 return KErrNone; |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CScreensaverEngine::HandleSuspendTimerExpiry |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 TInt CScreensaverEngine::HandleSuspendTimerExpiry( TAny* aPtr ) |
|
730 { |
|
731 CScreensaverEngine* control= STATIC_CAST(CScreensaverEngine*, aPtr); |
|
732 SCRLOGGER_WRITEF(_L("SCR: Inside CScreensaverEngine::HandleSuspendTimerExpiry()")); |
|
733 |
|
734 control->KillTimer( control->iSuspendTimer ); |
|
735 |
|
736 control->View()->SetDisplayObject( EDisplayPlugin ); |
|
737 control->View()->ShowDisplayObject(); |
|
738 |
|
739 return KErrNone; |
|
740 } |
|
741 |
|
742 // ----------------------------------------------------------------------------- |
|
743 // CScreensaverEngine::View |
|
744 // ----------------------------------------------------------------------------- |
|
745 // |
|
746 CScreensaverView* CScreensaverEngine::View() const |
|
747 { |
|
748 return STATIC_CAST( CScreensaverAppUi*, CCoeEnv::Static()->AppUi() )->ScreensaverView(); |
|
749 } |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // CScreensaverEngine::Timeout |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 TInt CScreensaverEngine::Timeout( ) |
|
756 { |
|
757 return iSharedDataI->ScreensaverTimeout( ); |
|
758 } |
|
759 |
|
760 // ----------------------------------------------------------------------------- |
|
761 // CScreensaverEngine::DisplayFlag |
|
762 // ----------------------------------------------------------------------------- |
|
763 // |
|
764 TInt CScreensaverEngine::DisplayFlag( ) |
|
765 { |
|
766 return iSharedDataI->IsScreenSaverAllowed(); |
|
767 } |
|
768 // End of file. |