servicewidget/servicewidgetdatapublisher/src/cservicewidgettimer.cpp
changeset 0 5e5d6b214f4f
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Event listener implementation presence
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "cservicewidgettimer.h"
       
    20 #include "mservicewidgetobservers.h"
       
    21 //system includes
       
    22 #include <e32base.h>
       
    23 #include "swpdebugtrace.h"
       
    24 // ================= MEMBER FUNCTIONS =======================
       
    25 // --------------------------------------------------------------------------
       
    26 // CServiceWidgetTimer::CServiceWidgetTimer
       
    27 // --------------------------------------------------------------------------
       
    28 //
       
    29 CServiceWidgetTimer::CServiceWidgetTimer( MServiceWidgetTimerObserver& aObserver )
       
    30     : CActive( CActive::EPriorityStandard ),
       
    31     iObserver( aObserver )
       
    32    	{
       
    33     CActiveScheduler::Add( this );
       
    34     }
       
    35     
       
    36 // --------------------------------------------------------------------------
       
    37 // CServiceWidgetTimer::ConstructL
       
    38 // --------------------------------------------------------------------------
       
    39 //
       
    40 void CServiceWidgetTimer::ConstructL()
       
    41     {
       
    42     TRACE_SWP(TXT("CServiceWidgetTimer::ConstructL() start") );
       
    43     User::LeaveIfError( iTimer.CreateLocal() );
       
    44     TRACE_SWP(TXT("CServiceWidgetTimer::ConstructL() end") );
       
    45     }
       
    46 
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CServiceWidgetTimer::NewL
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 CServiceWidgetTimer* CServiceWidgetTimer::NewL(MServiceWidgetTimerObserver& aObserver )
       
    53     {
       
    54     TRACE_SWP(TXT("CServiceWidgetTimer::NewL() start") );
       
    55     CServiceWidgetTimer* self = new(ELeave) CServiceWidgetTimer( aObserver );
       
    56     CleanupStack::PushL(self);
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop(self);
       
    59     TRACE_SWP(TXT("CServiceWidgetTimer::NewL() end") );
       
    60     return self;
       
    61     }
       
    62 // ---------------------------------------------------------
       
    63 // CServiceWidgetTimer::~CServiceWidgetTimer()
       
    64 // C++ Destructor 
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CServiceWidgetTimer::~CServiceWidgetTimer()
       
    68     {
       
    69     TRACE_SWP(TXT("CServiceWidgetTimer::~CServiceWidgetTimer() start") );
       
    70     Cancel(); // Cancel any request, if outstanding
       
    71   	iTimer.Close(); // Destroy the RTimer object
       
    72   	TRACE_SWP(TXT("CServiceWidgetTimer::~CServiceWidgetTimer() end") );
       
    73     }
       
    74 // ---------------------------------------------------------
       
    75 // CServiceWidgetTimer::RunL()
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void CServiceWidgetTimer::RunL()
       
    79     {
       
    80 	TRACE_SWP(TXT("CServiceWidgetTimer::RunL() start") );
       
    81     if( iStatus.Int() == KErrNone )
       
    82 	    {
       
    83 	    iObserver.HandleTimerExpiredL();	
       
    84 	    }
       
    85 	TRACE_SWP(TXT("CServiceWidgetTimer::RunL() end") );
       
    86     }
       
    87 // ---------------------------------------------------------
       
    88 // CServiceWidgetTimer::RunL()
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void CServiceWidgetTimer::DoCancel()
       
    92     {
       
    93     TRACE_SWP(TXT("CServiceWidgetTimer::DoCancel() start") );
       
    94    	iTimer.Cancel();
       
    95    	TRACE_SWP(TXT("CServiceWidgetTimer::DoCancel() end") );
       
    96     }
       
    97 // ---------------------------------------------------------
       
    98 // CServiceWidgetTimer::StartListening()
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 void CServiceWidgetTimer::StartListening(TTimeIntervalMicroSeconds32 anInterval)
       
   102     {
       
   103     TRACE_SWP(TXT("CServiceWidgetTimer::StartListening() start") );
       
   104     if(!IsActive() )
       
   105         {
       
   106         iTimer.After ( iStatus, anInterval );
       
   107 		SetActive (); // Tell scheduler a request is active
       
   108         }
       
   109     TRACE_SWP(TXT("CServiceWidgetTimer::StartListening() end") );
       
   110     }
       
   111 // ---------------------------------------------------------
       
   112 // CServiceWidgetTimer::StopListening()
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 void CServiceWidgetTimer::StopListening()
       
   116     {
       
   117     TRACE_SWP(TXT("CServiceWidgetTimer::StopListening() start") );
       
   118     if(IsActive() )
       
   119         {
       
   120         Cancel();
       
   121         }
       
   122     TRACE_SWP(TXT("CServiceWidgetTimer::StopListening() end") );
       
   123     }
       
   124     
       
   125 //  End of File  
       
   126 
       
   127