--- a/inc/screensaverengine.h Fri Mar 12 15:42:50 2010 +0200
+++ b/inc/screensaverengine.h Mon Mar 15 12:40:37 2010 +0200
@@ -30,6 +30,9 @@
//delay before wserv timer is turned off
#define KWSERVHEARTBEATTIMEOUT 15
+// Delay after screensaver is stopped and hided.
+const TInt KDefaultScreenSaverTimeout = 2 * 60 * 1000000; // 2 mins
+
// FORWARD DECLARATIONS
class CUserActivityManager;
class CScreensaverSharedDataI;
@@ -126,6 +129,22 @@
* Updates the indicator attributes.
*/
void UpdateIndicatorAttributes( );
+
+ /*
+ * Start screensaver expiry timer. When the timer expires the screensaver
+ * will be stopped and hided.
+ *
+ * @param aTimeout Timeout after the screensaver stops and hides itself in
+ * microseconds. 0 or negative value will disable the timer.
+ */
+ void SetExpiryTimerTimeout( TInt aTimeout );
+
+
+ /**
+ * Informs the engine about changes in keyguard state
+ * @param aEnabled whether the keyguard is now on or off
+ */
+ void HandleKeyguardStateChanged( TBool aEnabled );
private:
@@ -227,6 +246,10 @@
*/
TInt DisplayFlag();
+ /**
+ * Callback fuction. Called when the screensaver expiry timer time out.
+ */
+ static TInt HandleExpiryTimerExpiry( TAny* aPtr );
private:
@@ -295,6 +318,15 @@
* used to intercept and capture application key event.
*/
RAknUiServer iAknUiServer;
+
+ /**
+ * The screensaver expiry timer. Screensaver will be stoped when this timer
+ * expires.
+ *
+ * Owned.
+ */
+ CPeriodic* iExpiryTimer;
+
};
--- a/src/screensaverctrlplugin.cpp Fri Mar 12 15:42:50 2010 +0200
+++ b/src/screensaverctrlplugin.cpp Mon Mar 15 12:40:37 2010 +0200
@@ -291,12 +291,13 @@
View()->SetDisplayObject( Model().SharedDataInterface()->DefaultScreensaverType() );
+ CScreensaverEngine& model = MUTABLE_CAST( CScreensaverEngine&, Model() );
+ model.SetExpiryTimerTimeout( KDefaultScreenSaverTimeout );
+
View()->ShowDisplayObject();
if ( aTime >= 0 )
{
- CScreensaverEngine& model = MUTABLE_CAST( CScreensaverEngine&, Model() );
-
model.StartSuspendTimer( aTime );
}
}
@@ -385,6 +386,8 @@
//
void CScreensaverCtrlPlugin::RequestTimeout( TInt aSecs )
{
+ CScreensaverEngine& model = MUTABLE_CAST( CScreensaverEngine&, Model() );
+ model.SetExpiryTimerTimeout( 0 );
StartPluginTimeoutTimer( aSecs );
}
--- a/src/screensaverengine.cpp Fri Mar 12 15:42:50 2010 +0200
+++ b/src/screensaverengine.cpp Mon Mar 15 12:40:37 2010 +0200
@@ -75,6 +75,7 @@
DisableSharedDataAndMonitor();
delete iIndicatorArray;
KillTimer( iPreviewTimer );
+ KillTimer( iExpiryTimer );
iAknUiServer.Close();
}
@@ -153,6 +154,8 @@
// Report whether started from Idle BEFORE bringing to foreground
iSharedDataI->SetSSStartedFromIdleStatus();
+
+ iSharedDataI->SetSSForcedLightsOn(1);
ScreensaverUtility::BringToForeground();
@@ -194,6 +197,8 @@
iScreenSaverIsOn = EFalse ;
+ KillTimer( iExpiryTimer );
+
View()->HideDisplayObject();
}
@@ -260,6 +265,8 @@
UpdateIndicatorAttributes();
+ SetExpiryTimerTimeout( KDefaultScreenSaverTimeout );
+
View()->ShowDisplayObject();
iSharedDataI->SetScreensaverStatus( ETrue );
@@ -459,6 +466,27 @@
// -----------------------------------------------------------------------------
+// Start screensaver expiry timer. When the timer expires the screensaver will
+// be stopped and hided.
+// -----------------------------------------------------------------------------
+//
+void CScreensaverEngine::SetExpiryTimerTimeout( TInt aTimeout )
+ {
+ SCRLOGGER_WRITEF( _L( "SCR:CScreensaverEngine::SetExpiryTimerTimeout(%d) start" ), aTimeout );
+ KillTimer( iExpiryTimer );
+
+ if ( 0 < aTimeout )
+ {
+ TRAP_IGNORE(
+ iExpiryTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+ iExpiryTimer->Start( aTimeout , aTimeout ,
+ TCallBack( HandleExpiryTimerExpiry, this ) );
+ )
+ }
+ }
+
+
+// -----------------------------------------------------------------------------
// CScreensaverEngine::CScreensaverEngine
// -----------------------------------------------------------------------------
//
@@ -685,10 +713,12 @@
SCRLOGGER_WRITE("HandleInactiveEventL(), starting screensaver");
CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr);
-/*
+
// Double-start is OK, it will be checked in StartScreenSaver()
+ // This will be trigged by keylock activation after keyguard
+ // timeout, or if keylock is disabled
_this->StartScreenSaver( );
-*/
+
return KErrNone;
}
@@ -712,6 +742,8 @@
SCRLOGGER_WRITE("HandleInactiveEventShortL()");
// Start, if keys are locked and short timeout in use
CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr);
+ // Restore inactivity timeout if it was reset at keylock activation
+ _this->iActivityManagerScreensaverShort->SetInactivityTimeout(KTimeoutShort);
if ( _this->iSharedDataI->IsKeyguardOn() )
{
@@ -739,6 +771,24 @@
return KErrNone;
}
+// ---------------------------------------------------------------------------
+// CScreensaverEngine::HandleKeyguardStateChanged
+// ---------------------------------------------------------------------------
+//
+void CScreensaverEngine::HandleKeyguardStateChanged( TBool aEnabled )
+ {
+ if ( aEnabled )
+ {
+ // Keyguard switch generates an activity event still, let the inactivity
+ // handler start the screensaver after one second
+ iActivityManagerScreensaverShort->SetInactivityTimeout(1);
+ }
+ else
+ {
+ StopScreenSaver();
+ }
+ }
+
// -----------------------------------------------------------------------------
// CScreensaverEngine::View
// -----------------------------------------------------------------------------
@@ -765,4 +815,26 @@
{
return iSharedDataI->IsScreenSaverAllowed();
}
+
+
+// -----------------------------------------------------------------------------
+// Handles expire timer timeout
+// -----------------------------------------------------------------------------
+//
+TInt CScreensaverEngine::HandleExpiryTimerExpiry( TAny* aPtr )
+ {
+ SCRLOGGER_WRITEF( _L( "SCR:CScreensaverEngine::HandleExpiryTimerExpiry(%d) start" ), aPtr );
+ CScreensaverEngine *control = STATIC_CAST( CScreensaverEngine*, aPtr );
+
+ if ( control )
+ {
+ control->KillTimer( control->iExpiryTimer );
+ control->StopScreenSaver();
+ control->iSharedDataI->SetSSForcedLightsOn( 0 );
+ }
+
+ return KErrNone;
+ }
+
+
// End of file.
--- a/src/screensavershareddatai.cpp Fri Mar 12 15:42:50 2010 +0200
+++ b/src/screensavershareddatai.cpp Mon Mar 15 12:40:37 2010 +0200
@@ -188,7 +188,7 @@
if (iSettingsRepository)
{
- iSettingsRepository->Get(KSettingsScreenSaverPeriod, timeout);
+ iSettingsRepository->Get(KSettingsAutomaticKeyguardTime, timeout);
}
// No less than minimum timeout
// Old backed up minutes 1-4 will cause default timeout after
@@ -690,13 +690,13 @@
//
void CScreensaverSharedDataI::ConnectToPslnSettingCRL()
{
- TRAPD(ret, iSettingsRepository = CRepository::NewL(KCRUidPersonalizationSettings));
+ TRAPD(ret, iSettingsRepository = CRepository::NewL(KCRUidSecuritySettings));
if( ret == KErrNone )
{
iSettingsRepositoryWatcher = CScreensaverRepositoryWatcher::NewL(
KCRUidPersonalizationSettings,
- KSettingsScreenSaverPeriod,
+ KSettingsAutomaticKeyguardTime,
CCenRepNotifyHandler::EIntKey,
TCallBack(HandleTimeoutChanged, this),
iSettingsRepository);
--- a/src/screensavershareddatamonitor.cpp Fri Mar 12 15:42:50 2010 +0200
+++ b/src/screensavershareddatamonitor.cpp Mon Mar 15 12:40:37 2010 +0200
@@ -199,9 +199,9 @@
// MMC, screensaver defaults to date & time when MMC removed
// -----------------------------------------------------------------------------
//
-TInt CScreensaverSharedDataMonitor::HandleMMCStateChanged(TAny* aPtr)
+TInt CScreensaverSharedDataMonitor::HandleMMCStateChanged(TAny* /*aPtr*/)
{
- STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
+ User::ResetInactivityTime();
return KErrNone;
}
@@ -211,10 +211,10 @@
// MMC, screensaver defaults to date & time when USB attached
// -----------------------------------------------------------------------------
//
-TInt CScreensaverSharedDataMonitor::HandleUSBStateChanged(TAny* aPtr)
+TInt CScreensaverSharedDataMonitor::HandleUSBStateChanged(TAny* /*aPtr*/)
{
// Same handler as in MMC removal, parameter tells it's because of USB
- STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
+ User::ResetInactivityTime();
return KErrNone;
}
@@ -238,22 +238,7 @@
CScreensaverSharedDataMonitor* _this =
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr);
- if ( _this->iData->IsKeyguardOn() )
- {
- // Keys locked - if screensaver is running, this was caused by
- // automatic keyguard and screensaver should refresh the view
- // to show the keylock indicator
-/* if ( _this->Model().ScreenSaverIsOn() )
- {
- _this->View()->UpdateAndRefresh();
- }
-*/
- _this->Model().StartScreenSaver();
- }
- else
- {
- _this->Model().StopScreenSaver();
- }
+ _this->Model().HandleKeyguardStateChanged( _this->iData->IsKeyguardOn() );
return KErrNone;
}