wlanutilities/wlansniffer/mainapplication/src/wsfactivetimeupdater.cpp
changeset 0 56b72877c1cb
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Implementation of CWsfActiveTimeUpdater.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  EXTERNAL INCLUDES
       
    20 #include <e32base.h>
       
    21 
       
    22 //  INTERNAL INCLUDES
       
    23 #include "wsfactivetimeupdater.h"
       
    24 #include "wsfactivetimerhandler.h"
       
    25 
       
    26 #include "wsflogger.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 //  CONSTRUCTION AND DESTRUCTION
       
    31 // ---------------------------------------------------------------------------
       
    32 // CWsfActiveTimeUpdater::NewL
       
    33 // ---------------------------------------------------------------------------
       
    34 //   
       
    35 CWsfActiveTimeUpdater* CWsfActiveTimeUpdater::NewL( 
       
    36                                 MWsfActiveTimerHandler* aActiveTimerHandler )
       
    37     {
       
    38     LOG_ENTERFN( "CWsfActiveTimeUpdater::NewL" );
       
    39     CWsfActiveTimeUpdater* thisPtr = NewLC( aActiveTimerHandler );
       
    40     CleanupStack::Pop( thisPtr );
       
    41     return thisPtr;
       
    42     }
       
    43     
       
    44 // ---------------------------------------------------------------------------
       
    45 // CWsfActiveTimeUpdater::NewLC
       
    46 // ---------------------------------------------------------------------------
       
    47 //   
       
    48 CWsfActiveTimeUpdater* CWsfActiveTimeUpdater::NewLC( 
       
    49                                 MWsfActiveTimerHandler* aActiveTimerHandler )
       
    50     {
       
    51     LOG_ENTERFN( "CWsfActiveTimeUpdater::NewLC" );
       
    52     CWsfActiveTimeUpdater* thisPtr = 
       
    53                 new ( ELeave ) CWsfActiveTimeUpdater( aActiveTimerHandler );
       
    54     CleanupStack::PushL( thisPtr );
       
    55     thisPtr->ConstructL();
       
    56     return thisPtr;
       
    57     }
       
    58     
       
    59 // ---------------------------------------------------------------------------
       
    60 // CWsfActiveTimeUpdater::~CWsfActiveTimeUpdater
       
    61 // ---------------------------------------------------------------------------
       
    62 //   
       
    63 CWsfActiveTimeUpdater::~CWsfActiveTimeUpdater()
       
    64     {
       
    65     LOG_ENTERFN( "CWsfActiveTimeUpdater::~CWsfActiveTimeUpdater" );
       
    66     if( iPeriodic )
       
    67         {
       
    68         iPeriodic->Cancel();
       
    69         }
       
    70     delete iPeriodic;
       
    71     }
       
    72     
       
    73 // ---------------------------------------------------------------------------
       
    74 // CWsfActiveTimeUpdater::CWsfActiveTimeUpdater
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CWsfActiveTimeUpdater::CWsfActiveTimeUpdater( 
       
    78                                 MWsfActiveTimerHandler* aActiveTimerHandler )
       
    79     : iActiveTimerHandler( aActiveTimerHandler )
       
    80     {
       
    81     }
       
    82     
       
    83 // ---------------------------------------------------------------------------
       
    84 // CWsfActiveTimeUpdater::ConstructL
       
    85 // ---------------------------------------------------------------------------
       
    86 //       
       
    87 void CWsfActiveTimeUpdater::ConstructL()
       
    88     {
       
    89     LOG_ENTERFN( "CWsfActiveTimeUpdater::ConstructL" );
       
    90     iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
    91     }
       
    92     
       
    93 //  METHODS
       
    94 // ---------------------------------------------------------------------------
       
    95 // CWsfActiveTimeUpdater::Start
       
    96 // ---------------------------------------------------------------------------
       
    97 //   
       
    98 void CWsfActiveTimeUpdater::Start( TInt aUpdateInterval )
       
    99     {
       
   100     LOG_ENTERFN( "CWsfActiveTimeUpdater::Start" );
       
   101     // Start periodic timer
       
   102     iPeriodic->Start( TTimeIntervalMicroSeconds32( 0 ), 
       
   103                       TTimeIntervalMicroSeconds32( aUpdateInterval ), 
       
   104                       TCallBack( UpdateTimeL, this ) );
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CWsfActiveTimeUpdater::Stop
       
   109 // ---------------------------------------------------------------------------
       
   110 //       
       
   111 void CWsfActiveTimeUpdater::Stop()
       
   112     {
       
   113     LOG_ENTERFN( "CWsfActiveTimeUpdater::Stop" );
       
   114     // Cancel the timer request
       
   115     iPeriodic->Cancel();
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CWsfActiveTimeUpdater::DoUpdateTimeL
       
   120 // ---------------------------------------------------------------------------
       
   121 //   
       
   122 void CWsfActiveTimeUpdater::DoUpdateTimeL()
       
   123     {
       
   124     LOG_ENTERFN( "CWsfActiveTimeUpdater::DoUpdateTimeL" );
       
   125     iActiveTimerHandler->UpdateActiveTimeL();
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CWsfActiveTimeUpdater::UpdateTimeL
       
   130 // ---------------------------------------------------------------------------
       
   131 //    
       
   132 TInt CWsfActiveTimeUpdater::UpdateTimeL( TAny* aUpdater )
       
   133     {
       
   134     LOG_ENTERFN( "CWsfActiveTimeUpdater::UpdateTimeL" );
       
   135     static_cast<CWsfActiveTimeUpdater*>( aUpdater )->DoUpdateTimeL();
       
   136     return 0;
       
   137     } 
       
   138 
       
   139 // End of file