phoneplugins/csplugin/src/csptimer.cpp
changeset 72 c76a0b1755b9
parent 21 92ab7f8d0eab
equal deleted inserted replaced
64:6aaf0276100e 72:c76a0b1755b9
     1 /*
     1 /*
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
     2  * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  Timer service
    14  * Description:  Timer service
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include "csptimer.h"
    18 #include "csptimer.h"
    19 #include "mcsptimerobserver.h"
    19 #include "mcsptimerobserver.h"
    20 #include "csppanic.pan"
    20 #include "csppanic.pan"
    21 
    21 
    24 // ---------------------------------------------------------------------------
    24 // ---------------------------------------------------------------------------
    25 //
    25 //
    26 CSPTimer* CSPTimer::NewL()
    26 CSPTimer* CSPTimer::NewL()
    27     {
    27     {
    28     CSPTimer* self = CSPTimer::NewLC();
    28     CSPTimer* self = CSPTimer::NewLC();
    29     CleanupStack::Pop( self );
    29     CleanupStack::Pop(self);
    30     return self;
    30     return self;
    31     }
    31     }
    32 
    32 
    33 // ---------------------------------------------------------------------------
    33 // ---------------------------------------------------------------------------
    34 // Static constructor
    34 // Static constructor
    35 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
    36 //
    36 //
    37 CSPTimer* CSPTimer::NewLC()
    37 CSPTimer* CSPTimer::NewLC()
    38     {
    38     {
    39     CSPTimer* self = new( ELeave ) CSPTimer;
    39     CSPTimer* self = new (ELeave) CSPTimer;
    40     CleanupStack::PushL( self );
    40     CleanupStack::PushL(self);
    41     self->ConstructL();
    41     self->ConstructL();
    42     return self;
    42     return self;
    43     }
    43     }
    44 
    44 
    45 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    46 // Destructor
    46 // Destructor
    47 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    48 //
    48 //
    49 CSPTimer::~CSPTimer()
    49 CSPTimer::~CSPTimer()
    50     {
    50     {
    51     Cancel(); 
    51     Cancel();
    52     }
    52     }
    53 
    53 
    54 // ---------------------------------------------------------------------------
    54 // ---------------------------------------------------------------------------
    55 // Starts notify request
    55 // Starts notify request
    56 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    57 //
    57 //
    58 void CSPTimer::NotifyAfter( TInt aTimeout, 
    58 void CSPTimer::NotifyAfter(TInt aTimeout, MCSPTimerObserver& aTimerObserver)
    59         MCSPTimerObserver& aTimerObserver )
       
    60     {
    59     {
    61     __ASSERT_ALWAYS( !IsNotifyOngoing(), Panic( ECSPPanicTimerAlreadyActive ) );
    60     __ASSERT_ALWAYS(!IsNotifyOngoing(), Panic(ECSPPanicTimerAlreadyActive));
    62     After( aTimeout );
    61     After(aTimeout);
    63     iObserver = &aTimerObserver;
    62     iObserver = &aTimerObserver;
    64     }
    63     }
    65 
    64 
    66 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    67 // Cancels the outstancing request.
    66 // Cancels the outstancing request.
    86 // Notifies the observer about request.
    85 // Notifies the observer about request.
    87 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    88 //
    87 //
    89 void CSPTimer::RunL()
    88 void CSPTimer::RunL()
    90     {
    89     {
    91     if( iObserver ) 
    90     if (iObserver)
    92         {
    91         {
    93         iObserver->TimerEvent();
    92         iObserver->TimerEvent();
    94         }
    93         }
    95     }
    94     }
    96     
    95 
    97 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    98 // Constructor
    97 // Constructor
    99 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
   100 //
    99 //
   101 CSPTimer::CSPTimer() : 
   100 CSPTimer::CSPTimer() :
   102     CTimer( CActive::EPriorityStandard )
   101     CTimer(CActive::EPriorityStandard)
   103     {
   102     {
   104     CActiveScheduler::Add( this );
   103     CActiveScheduler::Add(this);
   105     }
   104     }
   106 
   105 
   107 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
   108 // Second phase constructor
   107 // Second phase constructor
   109 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------