convergedconnectionhandler/cchclientapi/src/cchuitimer.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2009-2009 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:  For timer handling.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cchuitimer.h"
       
    20 #include "mcchuitimerobserver.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CCchUiTimer::CCchUiTimer( MCchUiTimerObserver& aObserver ) 
       
    28     : CTimer( EPriorityStandard ), iObserver( aObserver )
       
    29     {    
       
    30     }
       
    31 
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 void CCchUiTimer::ConstructL()
       
    37     {    
       
    38     CActiveScheduler::Add( this );
       
    39     CTimer::ConstructL();
       
    40     }   
       
    41     
       
    42     
       
    43 // ---------------------------------------------------------------------------
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CCchUiTimer* CCchUiTimer::NewL( MCchUiTimerObserver& aObserver )
       
    47     {    
       
    48     CCchUiTimer* self = new ( ELeave ) CCchUiTimer( aObserver );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CCchUiTimer::~CCchUiTimer()
       
    60     {    
       
    61     CTimer::Cancel();
       
    62     }
       
    63    
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Start timer.
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TInt CCchUiTimer::StartTimer( TTimerType /*aTimerType*/ )
       
    70     {    
       
    71     TInt error ( KErrNone );
       
    72     
       
    73     if ( CTimer::IsActive() )
       
    74         {
       
    75         CTimer::Cancel();
       
    76         }
       
    77         
       
    78     return error;
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Stop timer.
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CCchUiTimer::StopTimer()
       
    87     {
       
    88     if ( CTimer::IsActive() )
       
    89         {
       
    90         CTimer::Cancel();
       
    91         }
       
    92     }
       
    93 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // RunL
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CCchUiTimer::RunL()
       
   100     {    
       
   101     iObserver.TimerExpired();
       
   102     }