Revision: 201033 RCL_3 PDK_3.0.3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 21:20:26 +0300
branchRCL_3
changeset 27 fc25e03508fd
parent 26 e8d784ac1a4b
child 29 65be1d84df1f
Revision: 201033 Kit: 201035
inc/screensaverctrlnone.h
scrsaver/scrsaverplugins/SlideshowPlugin/inc/SlideshowPlugin.h
scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp
src/screensaverctrlnone.cpp
--- a/inc/screensaverctrlnone.h	Wed Sep 01 12:30:40 2010 +0100
+++ b/inc/screensaverctrlnone.h	Tue Sep 14 21:20:26 2010 +0300
@@ -108,6 +108,21 @@
     */
     void SwitchDisplayState( TInt aState );
     
+    /**
+     * Callback for closing the light and display resources
+     * 
+     * @param aPtr pointer to CScreensaverCtrlNone
+     */
+    static TInt CloseDisplayResource( TAny* aPtr );
+    
+    /**
+     * Timer for check and close display&light resource after refresh.
+     * There is possibility that light is turned on responding to some
+     * notifications(e.g new SMS). This timer makes sure that display
+     * resources are closed again after such events. 
+     */
+    CPeriodic* iTimer;
+    
     };
 
 #endif // C_SCREENSAVERCTRLNONE_H
--- a/scrsaver/scrsaverplugins/SlideshowPlugin/inc/SlideshowPlugin.h	Wed Sep 01 12:30:40 2010 +0100
+++ b/scrsaver/scrsaverplugins/SlideshowPlugin/inc/SlideshowPlugin.h	Tue Sep 14 21:20:26 2010 +0300
@@ -354,6 +354,9 @@
 
     // MDS session
     CMdESession* iMdESession;
+    
+    // MDS query owned 
+    CMdEObjectQuery* iQuery;
     };  
 
 
--- a/scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp	Wed Sep 01 12:30:40 2010 +0100
+++ b/scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp	Tue Sep 14 21:20:26 2010 +0300
@@ -134,8 +134,19 @@
     delete iDrmHelper;
     delete iModel;
 
-    // First model, then engine, otherwise bad things happen
-    delete iMdESession;
+    // Close and delete mds query
+    if ( iQuery )
+        {
+        iQuery->Cancel();
+        delete iQuery;
+        iQuery = NULL;
+        }
+
+	if ( iMdESession )
+        {
+        delete iMdESession;
+        iMdESession = NULL;
+        }
     
     // Logging done
     SSPLOGGER_DELETE;
@@ -1001,9 +1012,9 @@
     CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Image::KImageObject );
 
     // query objects with object definition "Image"
-    CMdEObjectQuery* query = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
+    iQuery = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
 
-    query->FindL( KDefaultRandomLoadingNumber );
+    iQuery->FindL( KDefaultRandomLoadingNumber );
     }
 
 // -----------------------------------------------------------------------------
--- a/src/screensaverctrlnone.cpp	Wed Sep 01 12:30:40 2010 +0100
+++ b/src/screensaverctrlnone.cpp	Tue Sep 14 21:20:26 2010 +0300
@@ -29,6 +29,10 @@
 const TInt KDisplayOff = 0;
 const TInt KDisplayOn = 1;
 
+
+const TInt KTimerDelay = 60*1000*1000;  // 60 seconds
+const TInt KTimerInterval = KTimerDelay; 
+
 // -----------------------------------------------------------------------------
 // CScreensaverCtrlNone::NewL
 // -----------------------------------------------------------------------------
@@ -48,6 +52,12 @@
 //
 CScreensaverCtrlNone::~CScreensaverCtrlNone()
     {
+	if( iTimer )
+		{
+        iTimer->Cancel();
+        delete iTimer;
+		}
+    
     }
 
 // -----------------------------------------------------------------------------
@@ -74,7 +84,6 @@
     {
     SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlNone::ClearScreen start") );
     SwitchDisplayState( KDisplayOn );
-    
     SwitchLights( ESSForceLightsOn );
     }
 
@@ -151,7 +160,10 @@
 //
 void CScreensaverCtrlNone::ConstructL()
     {
-    CreateWindowL();
+    iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+    iTimer->Start( KTimerDelay, KTimerInterval,
+                            TCallBack( CloseDisplayResource,this ) );
+	CreateWindowL();
     SetRect( iCoeEnv->ScreenDevice()->SizeInPixels() );
     ActivateL();
     }
@@ -191,5 +203,25 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CScreensaverCtrlNone::CloseDisplayResource
+// -----------------------------------------------------------------------------
+//
+TInt CScreensaverCtrlNone::CloseDisplayResource( TAny* aPtr )
+    {
+    SCRLOGGER_WRITEF( _L("CScreensaverCtrlNone::CloseResource()") );
+    CScreensaverCtrlNone* ctrl = static_cast<CScreensaverCtrlNone*>( aPtr );
+	
+    if( ctrl && ctrl->Model().ScreenSaverIsOn() && !ctrl->Model().ScreenSaverIsPreviewing() )
+        {
+        ctrl->SwitchDisplayState( KDisplayOff );
+        ctrl->SwitchLights( ESSForceLightsOff );
+        return KErrNone;
+        }
+    else
+        {
+        return KErrGeneral;
+        }
+    }
 
 //End of file