ipsservices/tsrc/profiletester/src/timeouttimer.cpp
branchRCL_3
changeset 26 968773a0b6ef
equal deleted inserted replaced
25:3533d4323edc 26:968773a0b6ef
       
     1 /*
       
     2  * ============================================================================
       
     3  *  Name        :  timeouttimer.cpp
       
     4  *  Part of     :  ipsservice / profiletester 
       
     5  *  Description :: timer implementation
       
     6  *  Version     : %version: 1 % << Don't touch! Updated by Synergy at check-out.
       
     7  *
       
     8  *  Copyright © 2010-2010 Nokia and/or its subsidiary(-ies).  All rights reserved.
       
     9  *  This material, including documentation and any related computer
       
    10  *  programs, is protected by copyright controlled by Nokia.  All
       
    11  *  rights are reserved.  Copying, including reproducing, storing,
       
    12  *  adapting or translating, any or all of this material requires the
       
    13  *  prior written consent of Nokia.  This material also contains
       
    14  *  confidential information which may not be disclosed to others
       
    15  *  without the prior written consent of Nokia.
       
    16  * ============================================================================
       
    17  */
       
    18 
       
    19 #include "timeouttimer.h"
       
    20 
       
    21 // -----------------------------------------------------------------------------
       
    22 // CTimeoutTimer::NewL
       
    23 // Two-phased constructor.
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 CTimeoutTimer* CTimeoutTimer::NewL(MTimeoutObserver& aHandle)
       
    27     {
       
    28     CTimeoutTimer* self = CTimeoutTimer::NewLC(aHandle);
       
    29     CleanupStack::Pop(self);
       
    30     return self;
       
    31     }
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CTimeoutTimer::NewLC
       
    35 // Two-phased constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CTimeoutTimer* CTimeoutTimer::NewLC(MTimeoutObserver& aHandle)
       
    39     {
       
    40     CTimeoutTimer* self = new (ELeave) CTimeoutTimer(aHandle);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     return self;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CTimeoutTimer::CTimeoutTimer
       
    48 // C++ default constructor can NOT contain any code, that might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CTimeoutTimer::CTimeoutTimer(MTimeoutObserver& aHandle) :
       
    52     CTimer(EPriorityStandard), iNotifyHandle(aHandle)
       
    53     {
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CTimeoutTimer::~CTimeoutTimer
       
    58 // Destructor
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CTimeoutTimer::~CTimeoutTimer()
       
    62     {
       
    63     Stop();
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CTimeoutTimer::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CTimeoutTimer::ConstructL()
       
    72     {
       
    73     CTimer::ConstructL();
       
    74     CActiveScheduler::Add(this);
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CTimeoutTimer::Start
       
    79 // Start
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CTimeoutTimer::Start(TInt aTimePeriod)
       
    83     {
       
    84     After(aTimePeriod);
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CTimeoutTimer::Stop
       
    89 // Stop
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CTimeoutTimer::Stop()
       
    93     {
       
    94     Cancel();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CTimeoutTimer::RunL
       
    99 // RunL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CTimeoutTimer::RunL()
       
   103     {
       
   104     if (iStatus == KErrNone)
       
   105         {
       
   106         iNotifyHandle.TimeoutNotify();
       
   107         }
       
   108     else
       
   109         {
       
   110         User::Leave(iStatus.Int());
       
   111         }
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CTimeoutTimer::RunError
       
   116 // RunError
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 TInt CTimeoutTimer::RunError(TInt /*aError*/)
       
   120     {
       
   121     return KErrNone;
       
   122     }