|
1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file ctlbstimerutils.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "ctlbstimerutils.h" |
|
20 |
|
21 |
|
22 /** |
|
23 Function : NewL |
|
24 Description : It performs the two construction and returns an object |
|
25 of type CT_MsgTimerUtils |
|
26 @internalTechnology |
|
27 @param : |
|
28 @return : N/A |
|
29 @precondition : none |
|
30 @postcondition : none |
|
31 */ |
|
32 EXPORT_C CT_LbsTimerUtils* CT_LbsTimerUtils::NewL(MT_LbsTimerUtilsObserver* aObserver, TInt aTimerId) |
|
33 { |
|
34 CT_LbsTimerUtils* self = new(ELeave) CT_LbsTimerUtils(aObserver, aTimerId); |
|
35 |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(); |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 |
|
44 /** |
|
45 Function : CT_MsgTimerUtils |
|
46 Description : Constructor |
|
47 @internalTechnology |
|
48 @param : |
|
49 @return : N/A |
|
50 @precondition : none |
|
51 @postcondition : none |
|
52 */ |
|
53 CT_LbsTimerUtils::CT_LbsTimerUtils(MT_LbsTimerUtilsObserver* aObserver, TInt aTimerId) |
|
54 : |
|
55 CTimer(CTimer::EPriorityHigh), |
|
56 iObserver(aObserver), |
|
57 iTimerId(aTimerId) |
|
58 { |
|
59 CActiveScheduler::Add(this); |
|
60 } |
|
61 |
|
62 |
|
63 /** |
|
64 Function : ~CT_MsgTimerUtils |
|
65 Description : Destructor |
|
66 @internalTechnology |
|
67 @param : |
|
68 @return : N/A |
|
69 @precondition : none |
|
70 @postcondition : none |
|
71 */ |
|
72 EXPORT_C CT_LbsTimerUtils::~CT_LbsTimerUtils() |
|
73 { |
|
74 Cancel(); |
|
75 } |
|
76 |
|
77 void CT_LbsTimerUtils::ConstructL() |
|
78 { |
|
79 CTimer::ConstructL(); |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 Function : After |
|
85 Description : Calls the After function CTimer for the given number of secs |
|
86 @internalTechnology |
|
87 @param : |
|
88 @return : N/A |
|
89 @precondition : none |
|
90 @postcondition : none |
|
91 */ |
|
92 EXPORT_C void CT_LbsTimerUtils::SetTimer(const TTimeIntervalMicroSeconds32 aPeriod) |
|
93 { |
|
94 iTargetTime = 0; |
|
95 HighRes(aPeriod); |
|
96 } |
|
97 |
|
98 |
|
99 EXPORT_C void CT_LbsTimerUtils::SetTimer(const TTime& aUtcTargetTime) |
|
100 { |
|
101 Cancel(); |
|
102 |
|
103 iTargetTime = aUtcTargetTime; |
|
104 |
|
105 TTime zeroTime(0); |
|
106 |
|
107 if (aUtcTargetTime == zeroTime) |
|
108 { |
|
109 return; |
|
110 } |
|
111 |
|
112 TTime timeNow; |
|
113 timeNow.UniversalTime(); |
|
114 |
|
115 TTimeIntervalMicroSeconds delay(0); |
|
116 |
|
117 if (timeNow < aUtcTargetTime) |
|
118 { |
|
119 delay = aUtcTargetTime.MicroSecondsFrom(timeNow); |
|
120 } |
|
121 |
|
122 TInt delay32 = static_cast<TInt>(I64LOW(delay.Int64())); |
|
123 |
|
124 if (delay32 < 0) |
|
125 { |
|
126 delay32 = 0; |
|
127 } |
|
128 |
|
129 TTimeIntervalMicroSeconds32 time32 = TTimeIntervalMicroSeconds32(delay32); |
|
130 |
|
131 HighRes(time32); |
|
132 } |
|
133 |
|
134 EXPORT_C void CT_LbsTimerUtils::CancelTimer() |
|
135 { |
|
136 Cancel(); |
|
137 } |
|
138 |
|
139 /** |
|
140 Function : RunL |
|
141 Description : Gives the status of the operation |
|
142 @internalTechnology |
|
143 @param : |
|
144 @return : N/A |
|
145 @precondition : none |
|
146 @postcondition : none |
|
147 */ |
|
148 void CT_LbsTimerUtils::RunL() |
|
149 { |
|
150 if (iObserver) |
|
151 { |
|
152 iObserver->HandleTimerL(iTimerId, iTargetTime); |
|
153 } |
|
154 } |