tsrc/musenginestub/src/musengsessiondurationtimer.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 0 f0cf47e981f9
child 23 bc78a40cd63c
--- a/tsrc/musenginestub/src/musengsessiondurationtimer.cpp	Thu Aug 19 09:51:39 2010 +0300
+++ b/tsrc/musenginestub/src/musengsessiondurationtimer.cpp	Tue Aug 31 15:12:07 2010 +0300
@@ -16,21 +16,21 @@
 */
 
 
-// USER INCLUDES
+// USER INCLUDES 
 #include "musengsessiondurationtimer.h"
 #include "musengsessiondurationtimerobserver.h"
 
 
 
 // -----------------------------------------------------------------------------
-//
+// 
 // -----------------------------------------------------------------------------
 //
-CMusEngSessionDurationTimer* CMusEngSessionDurationTimer::NewL(
-                        MMusEngSessionDurationTimerObserver& aObserver )
+CMusEngSessionDurationTimer* CMusEngSessionDurationTimer::NewL(  
+						MMusEngSessionDurationTimerObserver& aObserver )
     {
-    CMusEngSessionDurationTimer* self =
-            new (ELeave) CMusEngSessionDurationTimer( aObserver );
+    CMusEngSessionDurationTimer* self = 
+    		new (ELeave) CMusEngSessionDurationTimer( aObserver );
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self) ;
@@ -39,31 +39,74 @@
 
 
 // -----------------------------------------------------------------------------
-//
+// 
 // -----------------------------------------------------------------------------
 //
 CMusEngSessionDurationTimer::~CMusEngSessionDurationTimer()
     {
+    Cancel();
+    iTimer.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+//
+void CMusEngSessionDurationTimer::Start(TInt aDelay )
+    {    
+    if ( !IsActive() )
+        {
+        iTimer.After( iStatus, aDelay );
+        SetActive();    	  	   	    
+        }
+    
+    }
+
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+//
+CMusEngSessionDurationTimer::CMusEngSessionDurationTimer( 
+						MMusEngSessionDurationTimerObserver& aObserver ) 
+	: CActive( CActive::EPriorityStandard ), 
+	  iObserver( aObserver)
+    {
     }
 
 
 // -----------------------------------------------------------------------------
-//
+// 
 // -----------------------------------------------------------------------------
 //
-CMusEngSessionDurationTimer::CMusEngSessionDurationTimer(
-                        MMusEngSessionDurationTimerObserver& aObserver )
-    : iObserver( aObserver)
+void CMusEngSessionDurationTimer::ConstructL()
     {
+    CActiveScheduler::Add( this );
+    User::LeaveIfError( iTimer.CreateLocal() );
     }
 
 
 // -----------------------------------------------------------------------------
-//
+// 
 // -----------------------------------------------------------------------------
 //
-void CMusEngSessionDurationTimer::ConstructL()
+void CMusEngSessionDurationTimer::RunL()
     {
+    if ( iStatus.Int() == KErrNone )
+        {
+		iObserver.UpdateTimerEvent();
+        }
     }
 
 
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+//
+void CMusEngSessionDurationTimer::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+