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