convergedcallengine/csplugin/src/csptimer.cpp
branchRCL_3
changeset 44 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
43:7d48bed6ce0c 44:987c9837762f
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Timer service
       
    15 *
       
    16 */
       
    17 
       
    18 #include "csptimer.h"
       
    19 #include "mcsptimerobserver.h"
       
    20 #include "csppanic.pan"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // Static constructor
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 CSPTimer* CSPTimer::NewL()
       
    27     {
       
    28     CSPTimer* self = CSPTimer::NewLC();
       
    29     CleanupStack::Pop( self );
       
    30     return self;
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Static constructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CSPTimer* CSPTimer::NewLC()
       
    38     {
       
    39     CSPTimer* self = new( ELeave ) CSPTimer;
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CSPTimer::~CSPTimer()
       
    50     {
       
    51     Cancel(); 
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Starts notify request
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CSPTimer::NotifyAfter( TInt aTimeout, 
       
    59         MCSPTimerObserver& aTimerObserver )
       
    60     {
       
    61     __ASSERT_ALWAYS( !IsNotifyOngoing(), Panic( ECSPPanicTimerAlreadyActive ) );
       
    62     After( aTimeout );
       
    63     iObserver = &aTimerObserver;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Cancels the outstancing request.
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CSPTimer::CancelNotify()
       
    71     {
       
    72     Cancel();
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Determines if there is active request outstanding.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 TBool CSPTimer::IsNotifyOngoing()
       
    80     {
       
    81     return IsActive();
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // From class CActive
       
    86 // Notifies the observer about request.
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CSPTimer::RunL()
       
    90     {
       
    91     if( iObserver ) 
       
    92         {
       
    93         iObserver->TimerEvent();
       
    94         }
       
    95     }
       
    96     
       
    97 // ---------------------------------------------------------------------------
       
    98 // Constructor
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CSPTimer::CSPTimer() : 
       
   102     CTimer( CActive::EPriorityStandard )
       
   103     {
       
   104     CActiveScheduler::Add( this );
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // Second phase constructor
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CSPTimer::ConstructL()
       
   112     {
       
   113     CTimer::ConstructL();
       
   114     }
       
   115 
       
   116 // End of File
       
   117