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