|
1 /* |
|
2 * Copyright (c) 2010 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 // INCLUDE FILES |
|
19 #include "tmstimer.h" |
|
20 |
|
21 using namespace TMS; |
|
22 |
|
23 // --------------------------------------------------------- |
|
24 // TMSTimer::TMSTimer |
|
25 // --------------------------------------------------------- |
|
26 // |
|
27 TMSTimer::TMSTimer(TInt aPriority) : |
|
28 CTimer(aPriority) |
|
29 { |
|
30 CActiveScheduler::Add(this); |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------- |
|
34 // TMSTimer::ConstructL |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 void TMSTimer::ConstructL() |
|
38 { |
|
39 CTimer::ConstructL(); |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // TMSTimer::NewL |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C TMSTimer* TMSTimer::NewL(TInt aPriority) |
|
47 { |
|
48 TMSTimer* self = new (ELeave) TMSTimer(aPriority); |
|
49 |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(self); |
|
53 |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------- |
|
58 // TMSTimer::~TMSTimer |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C TMSTimer::~TMSTimer() |
|
62 { |
|
63 Cancel(); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // TMSTimer::RunL() |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 void TMSTimer::RunL() |
|
71 { |
|
72 if (iStatus != KErrNone) |
|
73 { |
|
74 //error code is ignored, as CPeriodic. |
|
75 return; |
|
76 } |
|
77 |
|
78 if (!iTimerObserver) |
|
79 { |
|
80 //"TMSTimer::RunL CallBack" ); |
|
81 iCallBack.CallBack(); |
|
82 } |
|
83 else |
|
84 { |
|
85 //"TMSTimer::RunL HandleTimeOutL" ); |
|
86 iTimerObserver->HandleTimeOutL(); |
|
87 } |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // TMSTimer::After() |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C void TMSTimer::After(TTimeIntervalMicroSeconds32 anInterval, |
|
95 TCallBack aCallBack) |
|
96 { |
|
97 if (IsActive()) |
|
98 { |
|
99 Cancel(); |
|
100 } |
|
101 iTimerObserver = NULL; |
|
102 iCallBack = aCallBack; |
|
103 CTimer::After(anInterval); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // TMSTimer::After() |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 |
|
111 EXPORT_C void TMSTimer::After(TTimeIntervalMicroSeconds32 anInterval, |
|
112 TMSTimerObsrv* aObserver) |
|
113 { |
|
114 //__ASSERT_DEBUG( aObserver, Panic( EPhoneUtilsParameterNotInitialized ) ); |
|
115 |
|
116 if (IsActive()) |
|
117 { |
|
118 Cancel(); |
|
119 } |
|
120 iTimerObserver = aObserver; |
|
121 CTimer::After(anInterval); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // TMSTimer::CancelTimer |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void TMSTimer::CancelTimer() |
|
129 { |
|
130 Cancel(); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // TMSTimer::DoCancel |
|
135 // --------------------------------------------------------- |
|
136 // |
|
137 void TMSTimer::DoCancel() |
|
138 { |
|
139 iTimerObserver = NULL; |
|
140 CTimer::DoCancel(); |
|
141 } |
|
142 |
|
143 // End of File |