genericservices/taskscheduler/SCHSVR/SchTimer.cpp
changeset 68 ff3fc7722556
parent 0 e4d67989cc36
equal deleted inserted replaced
63:a117ad66e027 68:ff3fc7722556
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 
    15 
    16 // User includes
    16 // User includes
    17 #include "SchTimer.h"
    17 #include "SchTimer.h"
    18 #include "SCHMAN.H"
    18 #include "SCHMAN.H"
    19 #include "SCHEDULE.H"
    19 #include "SCHEDULE.H"
       
    20 #include "schlogger.h"
    20 
    21 
    21 // system includes
    22 // system includes
    22 #include <e32property.h>
    23 #include <e32property.h>
    23 
    24 
    24 /**
    25 /**
    28 SetNext method.  When the time has been reached it notifies the schedule
    29 SetNext method.  When the time has been reached it notifies the schedule
    29 manager via the CScheduleCriteriaManager::DueSchedule() method.
    30 manager via the CScheduleCriteriaManager::DueSchedule() method.
    30 
    31 
    31 @internalComponent
    32 @internalComponent
    32 */
    33 */
       
    34 _LIT(KTaskSchedulerPanic, "TaskScheduler ");
       
    35 
    33 NONSHARABLE_CLASS(CScheduleTimer) : public CTimer
    36 NONSHARABLE_CLASS(CScheduleTimer) : public CTimer
    34 	{
    37 	{
    35 public:
    38 public:
    36 	~CScheduleTimer();
    39 	~CScheduleTimer();
    37 	static CScheduleTimer* NewL(TInt aSchedule, CScheduleCriteriaManager& aManager);
    40 	static CScheduleTimer* NewL(TInt aSchedule, CScheduleCriteriaManager& aManager);
   137 	CPropertyNotifier(CConditionManager& aManager);
   140 	CPropertyNotifier(CConditionManager& aManager);
   138 	void AttachL();
   141 	void AttachL();
   139 	// From CActive
   142 	// From CActive
   140 	void RunL();
   143 	void RunL();
   141 	void DoCancel();
   144 	void DoCancel();
       
   145 	TInt RunError(TInt aError);
   142 
   146 
   143 public:
   147 public:
   144 	void SetPropertyL(const TUid& aCategory, TUint aKey);
   148 	void SetPropertyL(const TUid& aCategory, TUint aKey);
   145 	
   149 
   146 private:
   150 private:
   147 	TUid iCategory;
   151 	TUid iCategory;
   148 	TUint iKey;
   152 	TUint iKey;
   149 	RProperty iProperty;
   153 	RProperty iProperty;
   150 	CConditionManager& iConditionManager;
   154 	CConditionManager& iConditionManager;
   402 	}
   406 	}
   403 
   407 
   404 CPropertyNotifier::~CPropertyNotifier()
   408 CPropertyNotifier::~CPropertyNotifier()
   405 	{
   409 	{
   406 	Cancel();
   410 	Cancel();
       
   411 	iProperty.Close();
   407 	}
   412 	}
   408 
   413 
   409 void CPropertyNotifier::AttachL()
   414 void CPropertyNotifier::AttachL()
   410 	{
   415 	{
   411 	User::LeaveIfError(iProperty.Attach(iCategory, iKey));
   416 	User::LeaveIfError(iProperty.Attach(iCategory, iKey));
   414 	}
   419 	}
   415 
   420 
   416 void CPropertyNotifier::SetPropertyL(const TUid& aCategory, TUint aKey)
   421 void CPropertyNotifier::SetPropertyL(const TUid& aCategory, TUint aKey)
   417 	{
   422 	{
   418 	if (IsActive())
   423 	if (IsActive())
       
   424 	    {
   419 		Cancel();
   425 		Cancel();
       
   426 		iProperty.Close();
       
   427 	    }
   420 	iCategory = aCategory;
   428 	iCategory = aCategory;
   421 	iKey = aKey;
   429 	iKey = aKey;
   422 	AttachL();	
   430 	AttachL();	
   423 	}
   431 	}
   424 
   432 
   444 void CPropertyNotifier::DoCancel()
   452 void CPropertyNotifier::DoCancel()
   445 	{
   453 	{
   446 	iProperty.Cancel();
   454 	iProperty.Cancel();
   447 	}
   455 	}
   448 	
   456 	
   449 	
   457 TInt CPropertyNotifier::RunError(TInt aError)
       
   458     {
       
   459     if (aError)
       
   460         {
       
   461         LOGSTRING("CPropertyNotifier::RunL() leaves.");
       
   462         User::Panic(KTaskSchedulerPanic, aError);
       
   463         }
       
   464     return KErrNone;
       
   465     }
   450 	
   466 	
   451 //
   467 //
   452 
   468 
   453 CScheduleCriteriaManager* CScheduleCriteriaManager::NewL(CTaskScheduler& aOwner)
   469 CScheduleCriteriaManager* CScheduleCriteriaManager::NewL(CTaskScheduler& aOwner)
   454 	{
   470 	{
   625 			break;
   641 			break;
   626 		}	
   642 		}	
   627 	return condition;
   643 	return condition;
   628 	}	
   644 	}	
   629 	
   645 	
   630 	
   646 TInt CScheduleCriteriaManager::RunError(TInt aError)
       
   647     {
       
   648     if (aError)
       
   649         {
       
   650         LOGSTRING("CScheduleCriteriaManager::RunL() leaves.");
       
   651         User::Panic(KTaskSchedulerPanic, aError);
       
   652         }    
       
   653     return KErrNone;
       
   654     }
       
   655 
       
   656