featuremgmt/featuremgr/src/serverexe/featmgrtimer.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32base.h>
       
    20 #include "featmgrtimer.h"
       
    21 #include "featmgrdebug.h"
       
    22 #ifdef __WINS__
       
    23 #include <e32svr.h>
       
    24 #include <u32hal.h>
       
    25 #endif
       
    26 
       
    27 // LOCAL CONSTANTS
       
    28 // KFeatMgrTimer is a patchable constant and can be modified during buildrom time.
       
    29 // Note that it is not allowed to assign a value for constant in this file,
       
    30 // because hence gets inlined by compiler and cannot be patched by buildrom.
       
    31 IMPORT_C extern const TInt KFeatMgrTimer;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CFeatMgrTimer::NewL
       
    37 // Two-phased constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CFeatMgrTimer* CFeatMgrTimer::NewL( MFeatMgrTimerCallback& aCallback )
       
    41     {
       
    42     FUNC_LOG
       
    43 
       
    44     CFeatMgrTimer* p = new (ELeave) CFeatMgrTimer( aCallback );
       
    45     CleanupStack::PushL( p );
       
    46     p->ConstructL();
       
    47     CleanupStack::Pop( p );
       
    48 
       
    49     return p;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CFeatMgrTimer::CFeatMgrTimer
       
    54 // Constructor with callback class as a parameter.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CFeatMgrTimer::CFeatMgrTimer( MFeatMgrTimerCallback& aCallback )
       
    58                               : CTimer(EPriorityHigh), 
       
    59                               iCallback(aCallback)                              
       
    60     {
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CFeatMgrTimer::~CFeatMgrTimer
       
    65 // Destructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CFeatMgrTimer::~CFeatMgrTimer()
       
    69     {
       
    70     }
       
    71     
       
    72 // -----------------------------------------------------------------------------
       
    73 // CFeatMgrTimer::ConstructL
       
    74 // Symbian 2nd phase constructor can leave.
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CFeatMgrTimer::ConstructL()
       
    78     {
       
    79     FUNC_LOG
       
    80     
       
    81     CTimer::ConstructL();
       
    82 
       
    83     TInt timerVal( KFeatMgrTimer );
       
    84 #ifdef __WINS__
       
    85 	// KFeatMgrTimer is a Rom patchable constant, so need an emulator equivalent
       
    86 	// if WINS then read value from epoc.ini
       
    87 	// requires licencees to set property in epoc.ini
       
    88 	TInt load = 0;
       
    89 	TInt err = UserSvr::HalFunction(EHalGroupEmulator,EEmulatorHalIntProperty,
       
    90 	    (TAny*)"patchdata_featmgrserver_exe_KFeatMgrTimer",&load);
       
    91 	    INFO_LOG1( "CFeatMgrTimer::ConstrutcL - timer err %d", err );
       
    92 	if (err == KErrNone)
       
    93 		{
       
    94 		timerVal = load;
       
    95 		}
       
    96 #endif
       
    97     INFO_LOG1( "CFeatMgrTimer::ConstrutcL - timer value %d", timerVal );
       
    98     Set( timerVal );
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CFeatMgrTimer::Set
       
   103 // Start the timer to complete after the specified number of microseconds.
       
   104 // If the duration is zero, then timer is set to predefined maximum value.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CFeatMgrTimer::Set(const TTimeIntervalMicroSeconds32& aInterval)
       
   108     {
       
   109     FUNC_LOG
       
   110 
       
   111     INFO_LOG1( "CFeatMgrTimer::Set(%d)", aInterval.Int() );
       
   112 
       
   113     __ASSERT_ALWAYS( CActiveScheduler::Current(), User::Invariant() );
       
   114     
       
   115     if (!IsAdded())
       
   116         {
       
   117         CActiveScheduler::Add(this);
       
   118         }
       
   119     
       
   120     // If the timer is already running, cancel it... 
       
   121     if (IsActive())
       
   122         {
       
   123         Cancel();
       
   124         }
       
   125         
       
   126     // And set the new timer. If timer has specified maximum time, enforce that.
       
   127     TTime now;
       
   128     now.HomeTime();
       
   129     
       
   130     // Otherwise just set the time to specified interval.
       
   131     After(aInterval);
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CFeatMgrTimer::RunL
       
   136 // RunL() function will be run after the specified system time expires,
       
   137 // i.e. time is set by After() method,
       
   138 // -----------------------------------------------------------------------------
       
   139 void CFeatMgrTimer::RunL()
       
   140     {
       
   141     FUNC_LOG
       
   142 
       
   143     iCallback.TimerFired();
       
   144     }
       
   145 
       
   146 //  End of File