commsconfig/cscengine/src/cscengtimer.cpp
changeset 0 a4daefaec16c
child 6 fc8c25e5a2e8
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:  For timer handling.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cscengtimer.h"
       
    20 #include "cscenglogger.h"
       
    21 #include "mcscengtimerobserver.h"
       
    22 
       
    23 const TInt KWaitConnectionToClose = 5000000; // 5 seconds
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CCSCEngTimer::CCSCEngTimer( MCSCEngTimerObserver& aObserver ) 
       
    31     : CTimer( EPriorityStandard ), iObserver( aObserver )
       
    32     {    
       
    33     }
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CCSCEngTimer::ConstructL()
       
    40     {
       
    41     CSCENGDEBUG( "CCSCEngTimer::ConstructL - begin" ); 
       
    42     
       
    43     CActiveScheduler::Add( this );
       
    44     CTimer::ConstructL();
       
    45     
       
    46     CSCENGDEBUG( "CCSCEngTimer::ConstructL - end" ); 
       
    47     }   
       
    48     
       
    49     
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CCSCEngTimer* CCSCEngTimer::NewL( MCSCEngTimerObserver& aObserver )
       
    54     {    
       
    55     CCSCEngTimer* self = new ( ELeave ) CCSCEngTimer( aObserver );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCSCEngTimer::~CCSCEngTimer()
       
    67     {
       
    68     CSCENGDEBUG( "CCSCEngTimer::~CCSCEngTimer - begin" ); 
       
    69     
       
    70     CTimer::Cancel();
       
    71     
       
    72     CSCENGDEBUG( "CCSCEngTimer::~CCSCEngTimer - end" ); 
       
    73     }
       
    74    
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Start timer.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C TInt CCSCEngTimer::StartTimer( TTimerType aTimerType )
       
    81     {
       
    82     CSCENGDEBUG( "CCSCEngTimer::StartTimer" ); 
       
    83     
       
    84     TInt error ( KErrNone );
       
    85     
       
    86     if ( CTimer::IsActive() )
       
    87         {
       
    88         CTimer::Cancel();
       
    89         }
       
    90     
       
    91     if ( EConnectionMonitoringTimer == aTimerType )
       
    92         {
       
    93         CTimer::After( KWaitConnectionToClose );
       
    94         }
       
    95     else
       
    96         {
       
    97         error = KErrArgument;
       
    98         }
       
    99     
       
   100     return error;
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // Stop timer.
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C void CCSCEngTimer::StopTimer()
       
   109     {
       
   110     CSCENGDEBUG( "CCSCEngTimer::StopTimer - begin" ); 
       
   111 
       
   112     if ( CTimer::IsActive() )
       
   113         {
       
   114         CTimer::Cancel();
       
   115         }
       
   116     
       
   117     CSCENGDEBUG( "CCSCEngTimer::StopTimer - end" ); 
       
   118     }
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CCSCEngTimer::RunL
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CCSCEngTimer::RunL()
       
   126     {    
       
   127     iObserver.TimerExpired();
       
   128     }