mmserv/tms/tmsserver/src/tmstimer.cpp
changeset 21 2ed61feeead6
parent 20 b67dd1fc57c5
child 23 06e621399b1b
child 25 6f7ceef7b1d1
equal deleted inserted replaced
20:b67dd1fc57c5 21:2ed61feeead6
     1 /*
       
     2  * Copyright (c) 2010 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  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "tmstimer.h"
       
    20 
       
    21 using namespace TMS;
       
    22 
       
    23 // ---------------------------------------------------------
       
    24 // TMSTimer::TMSTimer
       
    25 // ---------------------------------------------------------
       
    26 //
       
    27 TMSTimer::TMSTimer(TInt aPriority) :
       
    28     CTimer(aPriority)
       
    29     {
       
    30     CActiveScheduler::Add(this);
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------
       
    34 // TMSTimer::ConstructL
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 void TMSTimer::ConstructL()
       
    38     {
       
    39     CTimer::ConstructL();
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // TMSTimer::NewL
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 EXPORT_C TMSTimer* TMSTimer::NewL(TInt aPriority)
       
    47     {
       
    48     TMSTimer* self = new (ELeave) TMSTimer(aPriority);
       
    49 
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop(self);
       
    53 
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // TMSTimer::~TMSTimer
       
    59 // ---------------------------------------------------------
       
    60 //
       
    61 EXPORT_C TMSTimer::~TMSTimer()
       
    62     {
       
    63     Cancel();
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // TMSTimer::RunL()
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 void TMSTimer::RunL()
       
    71     {
       
    72     if (iStatus != KErrNone)
       
    73         {
       
    74         //error code is ignored, as CPeriodic.
       
    75         return;
       
    76         }
       
    77 
       
    78     if (!iTimerObserver)
       
    79         {
       
    80         //"TMSTimer::RunL CallBack" );
       
    81         iCallBack.CallBack();
       
    82         }
       
    83     else
       
    84         {
       
    85         //"TMSTimer::RunL HandleTimeOutL" );
       
    86         iTimerObserver->HandleTimeOutL();
       
    87         }
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // TMSTimer::RunL()
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 TInt TMSTimer::RunError(TInt aError)
       
    95     {
       
    96     //TODO: process error if HandleTimeOutL() in RunL leaves
       
    97     return aError;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // TMSTimer::After()
       
   102 // ---------------------------------------------------------
       
   103 //
       
   104 EXPORT_C void TMSTimer::After(TTimeIntervalMicroSeconds32 anInterval,
       
   105         TCallBack aCallBack)
       
   106     {
       
   107     if (IsActive())
       
   108         {
       
   109         Cancel();
       
   110         }
       
   111     iTimerObserver = NULL;
       
   112     iCallBack = aCallBack;
       
   113     CTimer::After(anInterval);
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // TMSTimer::After()
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 
       
   121 EXPORT_C void TMSTimer::After(TTimeIntervalMicroSeconds32 anInterval,
       
   122         TMSTimerObsrv* aObserver)
       
   123     {
       
   124     //__ASSERT_DEBUG( aObserver, Panic( EPhoneUtilsParameterNotInitialized ) );
       
   125 
       
   126     if (IsActive())
       
   127         {
       
   128         Cancel();
       
   129         }
       
   130     iTimerObserver = aObserver;
       
   131     CTimer::After(anInterval);
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 //  TMSTimer::CancelTimer
       
   136 // ---------------------------------------------------------
       
   137 //
       
   138 EXPORT_C void TMSTimer::CancelTimer()
       
   139     {
       
   140     Cancel();
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------
       
   144 //  TMSTimer::DoCancel
       
   145 // ---------------------------------------------------------
       
   146 //
       
   147 void TMSTimer::DoCancel()
       
   148     {
       
   149     iTimerObserver = NULL;
       
   150     CTimer::DoCancel();
       
   151     }
       
   152 
       
   153 //  End of File