mmsharing/mmshui/src/musuiactivetimer.cpp
branchRCL_3
changeset 33 bc78a40cd63c
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     1 /*
       
     2 * Copyright (c) 2005 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 
       
    19 
       
    20 #include "musuiactivetimer.h" 
       
    21 #include "musuiactivetimerobserver.h"
       
    22 
       
    23 #include "muslogger.h" // debug logging
       
    24 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // Symbian two-phase constructor.
       
    28 // -----------------------------------------------------------------------------
       
    29 // 
       
    30 CMusUiActiveTimer* CMusUiActiveTimer::NewL(  MMusUiActiveTimerObserver* aObserver )
       
    31     {
       
    32     CMusUiActiveTimer* self = new (ELeave) CMusUiActiveTimer( aObserver );
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // Symbian second-phase constructor.
       
    42 // -----------------------------------------------------------------------------
       
    43 // 
       
    44 void CMusUiActiveTimer::ConstructL()
       
    45     {
       
    46     MUS_LOG( "mus: [MUSUI ]  -> CMusUiActiveTimer::ConstructL" );
       
    47     
       
    48     User::LeaveIfError( iTimer.CreateLocal() );
       
    49     CActiveScheduler::Add( this );
       
    50     
       
    51     MUS_LOG( "mus: [MUSUI ]  <- CMusUiActiveTimer::ConstructL" );
       
    52     }
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // .
       
    57 // -----------------------------------------------------------------------------
       
    58 // 
       
    59 void CMusUiActiveTimer::After( TTimeIntervalMicroSeconds32 anInterval )
       
    60     {
       
    61     // No logging due to huge amount of calls in some use cases
       
    62     
       
    63     Cancel();
       
    64     iTimer.After( iStatus, anInterval );
       
    65     SetActive();
       
    66     
       
    67     // No logging due to huge amount of calls in some use cases
       
    68     }
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // C++ constructor.
       
    73 // -----------------------------------------------------------------------------
       
    74 // 
       
    75 CMusUiActiveTimer::CMusUiActiveTimer( MMusUiActiveTimerObserver* aObserver ) : 
       
    76     CActive( EPriorityNormal ),
       
    77     iObserver( aObserver )
       
    78     {
       
    79     // nothing
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // C++ destructor.
       
    85 // -----------------------------------------------------------------------------
       
    86 // 
       
    87 CMusUiActiveTimer::~CMusUiActiveTimer()
       
    88     {
       
    89     MUS_LOG( "mus: [MUSUI ]  -> CMusUiActiveTimer::~CMusUiActiveTimer" );
       
    90     
       
    91     Cancel();
       
    92     iTimer.Close();
       
    93     
       
    94     MUS_LOG( "mus: [MUSUI ]  <- CMusUiActiveTimer::~CMusUiActiveTimer" );
       
    95     }
       
    96     
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // 
       
   100 // -----------------------------------------------------------------------------
       
   101 // 
       
   102 void CMusUiActiveTimer::DoCancel()
       
   103     {
       
   104     // No logging due to huge amount of calls in some use cases
       
   105     
       
   106     iTimer.Cancel();
       
   107     
       
   108     // No logging due to huge amount of calls in some use cases
       
   109     }
       
   110 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // 
       
   114 // -----------------------------------------------------------------------------
       
   115 // 
       
   116 void CMusUiActiveTimer::RunL()
       
   117     {
       
   118     MUS_LOG( "mus: [MUSUI ]  -> CMusUiActiveTimer::RunL" );
       
   119     if (iObserver && iStatus == KErrNone)
       
   120         {
       
   121         iObserver->TimerComplete( this );
       
   122         }
       
   123     else
       
   124         {
       
   125         User::LeaveIfError(iStatus.Int());
       
   126         }
       
   127     MUS_LOG( "mus: [MUSUI ]  <- CMusUiActiveTimer::RunL" );
       
   128     }
       
   129 
       
   130 // -------------------------------------------------------------------------
       
   131 //  If RunL() leaves,It should be handled here.
       
   132 // -------------------------------------------------------------------------
       
   133 //
       
   134 TInt CMusUiActiveTimer::RunError( TInt aError )
       
   135     {
       
   136 	MUS_LOG( "mus: [MUSUI ]  -> CMusUiActiveTimer::RunError" );
       
   137     // Nothing can be done here.
       
   138     aError = KErrNone;
       
   139 
       
   140     MUS_LOG( "mus: [MUSUI ]  <- CMusUiActiveTimer::RunError" );
       
   141     return aError;
       
   142     }
       
   143 
       
   144 
       
   145 // end of file