|
1 /* |
|
2 * Copyright (c) 2008-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 the License "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 * Interface class for using the services of CCallbackTimer |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 |
|
26 #include "callbacktimer.h" |
|
27 |
|
28 // Implementation of class CCallbackTimer |
|
29 EXPORT_C CCallbackTimer* CCallbackTimer::NewL(MTimerObserver& aCallBackIf, TBool aEnableCancelCallback/*= EFalse*/) |
|
30 { |
|
31 CCallbackTimer* self = new (ELeave) CCallbackTimer(aCallBackIf, aEnableCancelCallback); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); // calls CTimer::ConstructL() |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CCallbackTimer::CCallbackTimer(MTimerObserver& aCallBackIf, TBool aEnableCancelCallback) |
|
39 : CTimer(CActive::EPriorityStandard), |
|
40 iCallBackIf(aCallBackIf), |
|
41 iEnableCancelCallback(aEnableCancelCallback) |
|
42 { |
|
43 CActiveScheduler::Add(this); |
|
44 } |
|
45 |
|
46 void CCallbackTimer::RunL() |
|
47 { |
|
48 // Notify the client |
|
49 // Don't inform about cancels if that feature is disabled |
|
50 TInt status = iStatus.Int(); |
|
51 if (iEnableCancelCallback || status != KErrCancel) |
|
52 { |
|
53 iCallBackIf.TimerRun(status); |
|
54 } |
|
55 } |