phoneapp/phoneuiutils/src/cphonetimer.cpp
changeset 0 5f000ab63145
child 15 2a26698d78ba
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *   See header.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cphonetimer.h"
       
    22 #include "phoneui.pan"
       
    23 #include "phonelogger.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // CPhoneTimer::CPhoneTimer
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 CPhoneTimer::CPhoneTimer( TInt aPriority ) :
       
    32     CTimer( aPriority)
       
    33     {
       
    34     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::CPhoneTimer() ");
       
    35     CActiveScheduler::Add( this );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CPhoneTimer::ConstructL
       
    40 // ---------------------------------------------------------
       
    41 //
       
    42 void CPhoneTimer::ConstructL()
       
    43     {
       
    44     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::ConstructL() ");
       
    45     CTimer::ConstructL();
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CPhoneTimer::NewL
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CPhoneTimer* CPhoneTimer::NewL( TInt aPriority )
       
    53     {
       
    54     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::NewL() ");
       
    55     CPhoneTimer* self = new (ELeave) CPhoneTimer( aPriority );
       
    56     
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60 
       
    61     return self;
       
    62     }
       
    63     
       
    64 // ---------------------------------------------------------
       
    65 // CPhoneTimer::~CPhoneTimer
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CPhoneTimer::~CPhoneTimer()
       
    69     {
       
    70     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::~CPhoneTimer() ");
       
    71     Cancel();    
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CPhoneTimer::RunL()
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void CPhoneTimer::RunL()
       
    79     {
       
    80     __PHONELOG1( EBasic, EPhoneUIUtils, 
       
    81         "CPhoneTimer::RunL iStatus(%d)", 
       
    82         iStatus.Int() );
       
    83     
       
    84     if ( iStatus != KErrNone )
       
    85         {
       
    86         //error code is ignored, as CPeriodic. 
       
    87         return;
       
    88         }
       
    89    
       
    90     if ( !iTimerObserver )
       
    91         {
       
    92         __PHONELOG( EBasic, EPhoneUIUtils, 
       
    93             "CPhoneTimer::RunL CallBack" );
       
    94         iCallBack.CallBack();
       
    95         }
       
    96     else
       
    97         {
       
    98         __PHONELOG( EBasic, EPhoneUIUtils, 
       
    99             "CPhoneTimer::RunL HandleTimeOutL" );
       
   100         iTimerObserver->HandleTimeOutL();
       
   101         }
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CPhoneTimer::After()
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 EXPORT_C void CPhoneTimer::After( 
       
   109     TTimeIntervalMicroSeconds32 anInterval, 
       
   110     TCallBack aCallBack )
       
   111     {
       
   112     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::After() ");
       
   113     
       
   114     if ( IsActive() )
       
   115         {
       
   116         Cancel();
       
   117         }
       
   118     iTimerObserver = NULL;
       
   119     iCallBack = aCallBack;
       
   120     CTimer::After( anInterval );
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // CPhoneTimer::After()
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 
       
   128 EXPORT_C void CPhoneTimer::After( 
       
   129     TTimeIntervalMicroSeconds32 anInterval, 
       
   130     MPhoneTimer* aObserver )
       
   131     {
       
   132     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::After() ");
       
   133     
       
   134     __ASSERT_DEBUG( aObserver, Panic( EPhoneUtilsParameterNotInitialized ) );
       
   135     
       
   136     if ( IsActive() )
       
   137         {
       
   138         Cancel();
       
   139         }
       
   140     iTimerObserver = aObserver;
       
   141     CTimer::After( anInterval );
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 //  CPhoneTimer::CancelTimer
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CPhoneTimer::CancelTimer()
       
   149     {
       
   150     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::CancelTimer() ");
       
   151     Cancel();
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------
       
   155 //  CPhoneTimer::DoCancel
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 void CPhoneTimer::DoCancel()
       
   159     {
       
   160     __LOGMETHODSTARTEND(EPhoneUIUtils, "CPhoneTimer::DoCancel() ");
       
   161     iTimerObserver = NULL;
       
   162     CTimer::DoCancel();
       
   163     }
       
   164 
       
   165 //  End of File