mmsharing/livecommsui/lcui/tsrc/ipvtengine/src/svptimer.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
     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 for SVP     
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "svptimer.h"
       
    20 #include "svptimerobserver.h"
       
    21 
       
    22 
       
    23 const TInt KMicroSecondsCoefficient = 1000;
       
    24 
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CSVPTimer::CSVPTimer
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CSVPTimer::CSVPTimer( MSVPTimerObserver& aObserver, TInt aTimerId ): 
       
    31     CTimer( EPriorityHigh ),
       
    32     iObserver( aObserver ),
       
    33     iId( aTimerId )
       
    34     {
       
    35     CActiveScheduler::Add( this );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CSVPTimer::CSVPTimer
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 void CSVPTimer::ConstructL()
       
    43     {
       
    44     CTimer::ConstructL();
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CSVPTimer::CSVPTimer
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CSVPTimer* CSVPTimer::NewL( MSVPTimerObserver& aObserver,
       
    52                             TInt aTimerId )
       
    53     {
       
    54     CSVPTimer* self = new (ELeave) CSVPTimer( aObserver, aTimerId );
       
    55     
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59 
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CSVPTimer::~CSVPTimer
       
    65 // ---------------------------------------------------------------------------
       
    66 //  
       
    67 CSVPTimer::~CSVPTimer()
       
    68     {
       
    69     Cancel();
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CSVPTimer::RunL
       
    74 // ---------------------------------------------------------------------------
       
    75 //  
       
    76 void CSVPTimer::RunL()
       
    77     {
       
    78     iObserver.TimedOut( iId );
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CSVPTimer::SetTime
       
    83 // ---------------------------------------------------------------------------
       
    84 //  
       
    85 void CSVPTimer::SetTime( TInt aMilliSeconds, TInt aTimerId )
       
    86     {
       
    87     if ( IsActive() )
       
    88         {
       
    89         //iObserver.TimedOut( iId ); // Discard previous request
       
    90         Cancel();
       
    91         }
       
    92         
       
    93     iId = aTimerId;
       
    94         
       
    95     // Milliseconds to microseconds conversion
       
    96     const TTimeIntervalMicroSeconds32 time(
       
    97         KMicroSecondsCoefficient * aMilliSeconds );
       
    98     
       
    99     CTimer::After( time ); // NB, CTimer::After calls SetActive
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CSVPTimer::Stop
       
   104 // ---------------------------------------------------------------------------
       
   105 //  
       
   106 void CSVPTimer::Stop()
       
   107     {
       
   108     Cancel(); 
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CSVPTimer::Id
       
   113 // ---------------------------------------------------------------------------
       
   114 //  
       
   115 TInt CSVPTimer::Id() const
       
   116     {
       
   117     return iId;
       
   118     }
       
   119 
       
   120 //  End of File