messagingapp/msgnotifications/msgnotifier/tsrc/mmstestbed/src/mmstestuitimer.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 61 8ba0afbb4637
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
     1 /*
       
     2  * Copyright (c) 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:
       
    15  */
       
    16 
       
    17 #include "mmstestuitimer.h"
       
    18 
       
    19 
       
    20 
       
    21 // ======== MEMBER FUNCTIONS ========
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 //
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CTestUiTimer::CTestUiTimer(): CTimer( 5 )
       
    28     {
       
    29     period = KPeriod;
       
    30     }
       
    31 
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 void CTestUiTimer::ConstructL()
       
    38     {
       
    39     CTimer::ConstructL();
       
    40     CActiveScheduler::Add(this);
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CTestUiTimer* CTestUiTimer::NewL()
       
    49     {
       
    50     CTestUiTimer* self = new(ELeave) CTestUiTimer();
       
    51     CleanupStack::PushL(self);
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop(self);
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CTestUiTimer::~CTestUiTimer()
       
    62     {
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CTestUiTimer::IssueRequest()
       
    71     {
       
    72     // No operation to cancel if this function is called
       
    73     iObject = NULL;
       
    74     After(period);
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 void CTestUiTimer::TimeoutOperation( CActive* aObject, TTimeIntervalSeconds aTimeoutInSeconds )
       
    82     {
       
    83     iObject = aObject;
       
    84     TTimeIntervalMicroSeconds32 timeout = aTimeoutInSeconds.Int() * 1000000;
       
    85     After( timeout );
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CTestUiTimer::DoCancel()
       
    93     {
       
    94     CTimer::DoCancel();
       
    95     if ( iObject )
       
    96         {
       
    97         iObject->Cancel();
       
    98         iObject = NULL;
       
    99         }
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CTestUiTimer::RunL()
       
   107     {
       
   108     if ( iObject )
       
   109         {
       
   110         // If we timeout while holding an active object, we cancel it
       
   111         iObject->Cancel();
       
   112         iObject = NULL;
       
   113         }
       
   114     else
       
   115         {
       
   116         CActiveScheduler::Stop();
       
   117         }
       
   118     }
       
   119 
       
   120 // ======== GLOBAL FUNCTIONS ========
       
   121