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