Revision: 201021 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:42:47 +0300
branchRCL_3
changeset 16 1f307dce3b5a
parent 15 2e08ef6b6eda
child 18 98bf2adac59c
Revision: 201021 Kit: 2010123
group/screensaver.mmp
inc/screensaverengine.h
inc/screensavershareddatamonitor.h
scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/data/ScreenSaverAnimPlugin.rss
scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/loc/screensaveranimplugin.loc
scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPlugin.cpp
scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPluginHelper.cpp
scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/inc/GifAnimationPlugin.h
scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/src/GifAnimationPluginControl.cpp
src/screensaverctrlmovingtext.cpp
src/screensaverctrlplugin.cpp
src/screensaverengine.cpp
src/screensavershareddatai.cpp
src/screensavershareddatamonitor.cpp
--- a/group/screensaver.mmp	Tue May 25 12:43:23 2010 +0300
+++ b/group/screensaver.mmp	Wed Jun 09 09:42:47 2010 +0300
@@ -64,7 +64,8 @@
 SOURCE      screensaversubscriber.cpp
 SOURCE      screensaverrepositorywatcher.cpp 
 SOURCE      screensavershareddatamonitor.cpp 
-SOURCE      screensaverengine.cpp 
+SOURCE      screensaverengine.cpp
+SOURCE      screensaveractivitymanager.cpp
 
 START RESOURCE screensaver.rss
 HEADER
@@ -114,7 +115,6 @@
 LIBRARY     CenRepNotifHandler.lib
 LIBRARY     efsrv.lib
 LIBRARY     flogger.lib
-LIBRARY     activitymanager.lib
 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
 LIBRARY     gfxtrans.lib
 LIBRARY     akntransitionutils.lib
--- a/inc/screensaverengine.h	Tue May 25 12:43:23 2010 +0300
+++ b/inc/screensaverengine.h	Wed Jun 09 09:42:47 2010 +0300
@@ -39,6 +39,7 @@
 class CScreensaverSharedDataMonitor;
 class CScreensaverAppUi;
 class CScreensaverView;
+class CScreensaverActivityManager;
 class CPowerSaveDisplayMode;
 
 /**
@@ -139,6 +140,12 @@
      */
     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:
     
     /**
@@ -173,7 +180,7 @@
     /**
     * Stops monitoring the user activity
     */
-    void StopActivityMonitoring( CUserActivityManager*& aActivityManager );
+    void StopActivityMonitoring( CScreensaverActivityManager*& aActivityManager );
 
     /**
     * Gets the color model from the resource
@@ -263,7 +270,7 @@
     /**
     * The trigger for screensaver activation
     */
-    CUserActivityManager* iActivityManagerScreensaver;
+    CScreensaverActivityManager* iActivityManagerScreensaver;
 
     
     /**
@@ -320,6 +327,11 @@
     */
     CPeriodic* iPauseTimer;
     
+    /**
+    * Set if the pause timer was started when preview was stopped
+    */
+    TBool iPauseTimerStartedAfterPreview;
+    
     };
 
 
--- a/inc/screensavershareddatamonitor.h	Tue May 25 12:43:23 2010 +0300
+++ b/inc/screensavershareddatamonitor.h	Wed Jun 09 09:42:47 2010 +0300
@@ -118,6 +118,11 @@
     * Callback function. Called when charger state changes
     */
     static TInt HandleChargerStateChanged( TAny* aPtr );
+    
+    /**
+    * Callback function. Called when the message waiting display state changes
+    */
+    static TInt HandleMessageWaitingStateChanged( TAny* aPtr );
 
 private:
     
@@ -170,6 +175,9 @@
     */
     RProperty iChargerStateProperty;
     CSubscriber* iChargerStateSubscriber;
+    
+    CRepository* iMessageWaitingRepository;
+    CScreensaverRepositoryWatcher* iMessageWaitingWatcher;
 
     };
 
--- a/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/data/ScreenSaverAnimPlugin.rss	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/data/ScreenSaverAnimPlugin.rss	Wed Jun 09 09:42:47 2010 +0300
@@ -107,7 +107,7 @@
 RESOURCE SLIDER r_anim_timeout_slider 
     {
     layout = EAknSettingsItemSliderLayout;
-    minvalue = 1;
+    minvalue = 5;
     maxvalue = 60;
     step = 1;
     valuetype = EAknSliderValueBareFigure;
--- a/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/loc/screensaveranimplugin.loc	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/loc/screensaveranimplugin.loc	Wed Jun 09 09:42:47 2010 +0300
@@ -59,7 +59,7 @@
 //d:Minimum value
 //l:setting_slider_pane_t2
 //r:3.1
-#define qtn_sanim_duration_slider_min "1 sec."
+#define qtn_sanim_duration_slider_min "5 sec."
 
 //d:Text in slider control
 //d:Screen saver animation duration setting page
--- a/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPlugin.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPlugin.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -53,7 +53,7 @@
 const TInt KUrlMaxLen = 1024;
 
 // Animation Timeout values
-const TInt KMinDurationValue = 1;
+const TInt KMinDurationValue = 5;
 const TInt KMaxDurationValue = 60;
 const TInt KDefaultDurationValue = 5;
 
--- a/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPluginHelper.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverAnimPlugin/src/ScreenSaverAnimPluginHelper.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -104,7 +104,13 @@
     iDRMHelper->SetAutomatedType( 
                    CDRMHelper::EAutomatedTypeScreenSaver );
     res = iDRMHelper->CanSetAutomated( aSelectedFiles->MdcaPoint( 0 ), canbeautomated );
-
+    if ( KErrUnderflow == res )
+        {
+        TInt resourceId = R_SANIM_ERROR_WRONG_FORMAT;
+        // Show information note
+        ShowErrorNoteL( resourceId );    
+        return EFalse;        
+        }
     if ( res )
         {
         iDRMHelper->HandleErrorL( res, aSelectedFiles->MdcaPoint( 0 ) );        
--- a/scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/inc/GifAnimationPlugin.h	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/inc/GifAnimationPlugin.h	Wed Jun 09 09:42:47 2010 +0300
@@ -257,11 +257,15 @@
         // code of last loading error occured
         TInt                iLastError;        
 
-	    // pointer to adapter, we do not own the instance
-    	MPluginAdapter*             iPluginAdapter;
-    	
-    	// if true, no DRM rights are consumed
-    	TBool               isPreviewMode;
+        // pointer to adapter, we do not own the instance
+        MPluginAdapter*             iPluginAdapter;
+        
+        // if true, no DRM rights are consumed
+        TBool               isPreviewMode;
+        
+        // a flag to make sure the first ViewerBitmapChangedL is finished,
+        // then we could draw image on screen
+        TBool               isViewerBitmapChangedL;
     };
 
 
--- a/scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/src/GifAnimationPluginControl.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/scrsaver/scrsaverplugins/ScreenSaverGifAnimPlugin/src/GifAnimationPluginControl.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -68,6 +68,7 @@
     DBG_TRACE_FN_BEGIN;
 
     iPluginAdapter = aPluginAdapter;
+    isViewerBitmapChangedL = EFalse;
     
     if ( aParentControl != NULL )
         {
@@ -248,7 +249,9 @@
         
     if ( iDrawingBitmap 
       && iEngine 
-      && iLastError == KErrNone ) // loading was successful
+      && iLastError == KErrNone // loading was successful
+      && isViewerBitmapChangedL ) // need to check whether first ViewerBitmapChangedL
+                                  // has been called; 
         {
         TSize screenSize( rect.Size() );
         TPoint destinationPoint( 
@@ -544,7 +547,7 @@
                     }
                 }
             }
-            
+        isViewerBitmapChangedL = ETrue;
         MakeVisible( ETrue );
         DrawNow();
         }
--- a/src/screensaverctrlmovingtext.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/src/screensaverctrlmovingtext.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -187,7 +187,14 @@
     // is displaying. Other indicators' state changing also dismisses
     // screensaver. Once redisplaying, the indicators are updated anyway.
     // Key lock indicator depends on status of key guard.
+    TIndicatorPayload payload;
+    payload.iType = EPayloadTypeInteger;
+    
     Array().SetDependencyStatus( ESsKeyLockInd, !Model().SharedDataInterface()->IsKeyguardOn() );
+    payload.iInteger = Model().SharedDataInterface()->UnreadMessagesNumber();
+    Array().SetIndicatorPayload( ESsNewMessagesInd, payload );
+    Array().SetDependencyStatus( ESsNewMessagesInd, ( payload.iInteger <= 0 ) );
+    Array().SetDependencyStatus( ESsVoicemailInd, !Model().SharedDataInterface()->IsHaveNewVoicemail() );
     SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh move") );
     // Don't move bar during this refresh
     SetMoving( EFalse );
--- a/src/screensaverctrlplugin.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/src/screensaverctrlplugin.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -123,7 +123,15 @@
     // is displaying. Other indicators' state changing also dismisses
     // screensaver. Once redisplaying, the indicators are updated anyway.
     // Key lock indicator depends on status of key guard.
+    TIndicatorPayload payload;
+    payload.iType = EPayloadTypeInteger;
+    
     Array().SetDependencyStatus( ESsKeyLockInd, !Model().SharedDataInterface()->IsKeyguardOn() );
+    payload.iInteger = Model().SharedDataInterface()->UnreadMessagesNumber();
+    Array().SetIndicatorPayload( ESsNewMessagesInd, payload );
+    Array().SetDependencyStatus( ESsNewMessagesInd, ( payload.iInteger <= 0 ) );
+    Array().SetDependencyStatus( ESsVoicemailInd, !Model().SharedDataInterface()->IsHaveNewVoicemail() );
+
     Array().SetVisibilityForIndicators();
 
     SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlPlugin::Refresh DrawObject") );
--- a/src/screensaverengine.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/src/screensaverengine.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -23,7 +23,6 @@
 #include <Profile.hrh>
 #include <screensaver.rsg>
 #include <AknUtils.h>
-#include <activitymanager.h>
 
 #include "screensaverengine.h"
 #include "screensaverctrlmovingtext.h"
@@ -32,12 +31,14 @@
 #include "screensaverappui.h"
 #include "ScreensaverUtils.h"
 #include "screensaverutility.h"
+#include "screensaveractivitymanager.h"
 
 // Minimum plugin suspension time
 const TInt KMinPluginSuspensionTime = 500000; // 0.5 sec
 
 // Inactivity timeout in seconds when keys locked
 const TInt KTimeoutShort = 5000000;
+const TInt KTimeoutPreviewLocked = 2000000;
 
 const TInt KNoPreview = 0;
 
@@ -126,14 +127,12 @@
     {
     SCRLOGGER_WRITE("Model: StartScreenSaver()");
 
-    // Ignore start while in preview to avoid double-start lock
+    // Stop if previewing. If keylock was activated, the pause timer will
+    // be started and the selected (not necessarily previewed) screensaver
+    // will start
     if ( iScreenSaverIsPreviewing )
         {
-        // Reset user activity so that screensaver is enabled after
-        // preview even if no user activity happens any more
-        // Note that this puts on backlight but it should be on at this
-        // time anyway (unless a plugin set it off, but what the hey)
-        User::ResetInactivityTime();
+        StopScreenSaver();
         return;
         }
 
@@ -186,7 +185,7 @@
     {
     SCRLOGGER_WRITE("Stopping Screensaver");
 
-    if ( !iScreenSaverIsPreviewing && iSharedDataI->IsKeyguardOn() )
+    if ( iSharedDataI->IsKeyguardOn() || iScreenSaverIsPreviewing )
         {
         StartPauseTimer();
         }
@@ -219,6 +218,7 @@
         iSharedDataI->SetScreensaverPreviewState( EScreenSaverPreviewNone );
 
         KillTimer( iPreviewTimer );
+        ResetInactivityTimeout();
         }
     }
 
@@ -252,6 +252,7 @@
         {
         ScreensaverUtility::BringToForeground();
         }
+    iActivityManagerScreensaver->SetInactivityTimeout(0);
     }
 
 // -----------------------------------------------------------------------------
@@ -563,7 +564,7 @@
 
     // Start monitoring activity for screensaver
     iActivityManagerScreensaver
-        = CUserActivityManager::NewL( CActive::EPriorityStandard );
+        = CScreensaverActivityManager::NewL( CActive::EPriorityUserInput );
         iActivityManagerScreensaver->Start( Timeout(), 
             TCallBack( HandleInactiveEventL,this ),
             TCallBack( HandleActiveEventL, this ) );
@@ -573,7 +574,7 @@
 // CScreensaverEngine::StopActivityMonitoring
 // -----------------------------------------------------------------------------
 //
-void CScreensaverEngine::StopActivityMonitoring( CUserActivityManager*& aActivityManager )
+void CScreensaverEngine::StopActivityMonitoring( CScreensaverActivityManager*& aActivityManager )
     {
     if ( aActivityManager )
         {
@@ -665,6 +666,14 @@
 //
 void CScreensaverEngine::StartPauseTimer()
     {
+    if ( iScreenSaverIsPreviewing )
+        {
+        iPauseTimerStartedAfterPreview = ETrue;
+        }
+  
+    TInt timeout = ( iScreenSaverIsPreviewing )? KTimeoutPreviewLocked :
+                                                 KTimeoutShort;
+    
     KillTimer( iPauseTimer );
     
     TRAP_IGNORE( iPauseTimer = CPeriodic::NewL( CActive::EPriorityHigh ) );
@@ -675,7 +684,7 @@
         return;
         }
     
-    iPauseTimer->Start( KTimeoutShort, KTimeoutShort, TCallBack(
+    iPauseTimer->Start( timeout, timeout, TCallBack(
         HandlePauseTimerExpiry, this ) );
     }
 
@@ -717,6 +726,7 @@
     {
     CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr);
     _this->KillTimer( _this->iPauseTimer );
+    _this->iPauseTimerStartedAfterPreview = EFalse;
 
     if ( _this->iSharedDataI->IsKeyguardOn() )
         {
@@ -731,11 +741,14 @@
 // CScreensaverEngine::HandleActiveEventL
 // -----------------------------------------------------------------------------
 //
-TInt CScreensaverEngine::HandleActiveEventL( TAny* /* aPtr */)
+TInt CScreensaverEngine::HandleActiveEventL( TAny* aPtr )
     {
-    SCRLOGGER_WRITE("HandleActiveEventL(), do nothing");
-    // We can be pretty sure the short timeout has passed and its
-    // active event handler stops the saver
+    SCRLOGGER_WRITE("HandleActiveEventL(), stop if previewing");
+    CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr);
+    if ( _this->iScreenSaverIsPreviewing )
+        {
+        _this->StopScreenSaver();
+        }
     return KErrNone;
     }
 
@@ -748,7 +761,12 @@
     SCRLOGGER_WRITE("HandleInactiveEventL(), starting screensaver");
 
     CScreensaverEngine* _this= STATIC_CAST(CScreensaverEngine*, aPtr);
-    
+    // Inactivity is detected immediately when preview starts
+    if ( _this->iScreenSaverIsPreviewing )
+        {
+        _this->ResetInactivityTimeout();
+        return KErrNone;
+        }
     // 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
@@ -774,6 +792,33 @@
     return KErrNone;
     }
 
+// ---------------------------------------------------------------------------
+// CScreensaverEngine::HandleKeyguardStateChanged
+// ---------------------------------------------------------------------------
+//
+void CScreensaverEngine::HandleKeyguardStateChanged( TBool aEnabled )
+    {
+    if ( aEnabled )
+        {
+        // Keys locked - if screensaver is running, this was caused by
+        // automatic keyguard and screensaver should refresh the view
+        // to show the keylock indicator
+        if ( iScreenSaverIsOn && !iScreenSaverIsPreviewing )
+            {
+            View()->UpdateAndRefresh();
+            }
+        if ( !( iPauseTimerStartedAfterPreview && 
+                iPauseTimer && iPauseTimer->IsActive() ) )
+            {
+            StartScreenSaver();
+            }
+        }
+    else
+        {
+        StopScreenSaver();
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CScreensaverEngine::View
 // -----------------------------------------------------------------------------
--- a/src/screensavershareddatai.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/src/screensavershareddatai.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -57,9 +57,9 @@
 const TInt KScreensaverStartedFromIdle = 1;
 
 // Screen saver text type.
-_LIT( KScreenSaverTypeText, "Text" );
-//Screensaver "None" (Sleep mode)
-_LIT( KScreenSaverTypeNone, "None" );
+// _LIT( KScreenSaverTypeText, "Text" );
+// Screensaver "None" (Sleep mode)
+// _LIT( KScreenSaverTypeNone, "None" );
 
 // Define security policies for Screensavers property keys
 _LIT_SECURITY_POLICY_PASS(KSSPolicyPass);
@@ -520,8 +520,8 @@
 TBool CScreensaverSharedDataI::IsHaveNewVoicemail() const
     {
     // Show the indicator, if either line has messages waiting
-    if ( ( VoiceMailCount( KNcnVoiceMailCountInLine1 ) > 0 ) 
-        || ( VoiceMailCount( KNcnVoiceMailCountInLine2 ) > 0 ) )
+    if ( ( VoiceMailCount( KCtsyMessageWaitingVoiceMailCount ) > 0 ) 
+        || ( VoiceMailCount( KCtsyMessageWaitingAuxLineCount ) > 0 ) )
         {
         return ETrue;
         }
@@ -586,6 +586,9 @@
     {
     switch (aEvent)
         {
+        case EMsvEntriesChanged:
+            AppUi()->ScreensaverView()->UpdateAndRefresh();
+            break;
         case EMsvCloseSession:
         case EMsvServerTerminated:
             delete iInboxFolder;
--- a/src/screensavershareddatamonitor.cpp	Tue May 25 12:43:23 2010 +0300
+++ b/src/screensavershareddatamonitor.cpp	Wed Jun 09 09:42:47 2010 +0300
@@ -26,6 +26,8 @@
 #include <ScreensaverInternalPSKeys.h>
 #include <UikonInternalPSKeys.h>             // kuikmmcinserted
 #include <hwrmpowerstatesdkpskeys.h>
+#include <ctsydomaincrkeys.h>
+#include <centralrepository.h>
 
 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
 #include <akntransitionutils.h>
@@ -72,6 +74,9 @@
     
     DeleteSubscriber( iChargerStateSubscriber );
     iChargerStateProperty.Close();
+    
+    delete iMessageWaitingWatcher;
+    delete iMessageWaitingRepository;
     }
 
 // -----------------------------------------------------------------------------
@@ -150,6 +155,12 @@
     iChargerStateSubscriber = new (ELeave) CSubscriber( 
         TCallBack( HandleChargerStateChanged, this ), iChargerStateProperty );
     iChargerStateSubscriber->SubscribeL();
+    
+    iMessageWaitingRepository = CRepository::NewL( KCRUidCtsyMessageWaitingIndicator );
+    iMessageWaitingWatcher = CScreensaverRepositoryWatcher::NewL( KCRUidCtsyMessageWaitingIndicator,
+                                                                  TCallBack( HandleMessageWaitingStateChanged, this ),
+                                                                  iMessageWaitingRepository );
+
     }
 
 // -----------------------------------------------------------------------------
@@ -250,22 +261,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;
     }
 
@@ -363,4 +359,18 @@
     return KErrNone;
     }
 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CScreensaverSharedDataMonitor::HandleMessageWaitingStateChanged( TAny* aPtr )
+    {
+    CScreensaverSharedDataMonitor* self = STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr);
+    if ( self->iMessageWaitingWatcher->ChangedKey() == KCtsyMessageWaitingDisplayStatus )
+        {
+        self->View()->UpdateAndRefresh();
+        }
+    return KErrNone;
+    }
+
 // End of file