|
1 /* |
|
2 * Copyright (c) 2006 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: Timer service for SVP |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "svptimer.h" |
|
19 #include "svplogger.h" |
|
20 #include "svptimerobserver.h" |
|
21 |
|
22 |
|
23 const TInt KMicroSecondsCoefficient = 1000; |
|
24 |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CSVPTimer::CSVPTimer |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CSVPTimer::CSVPTimer( MSVPTimerObserver& aObserver, TInt aTimerId ): |
|
31 CTimer( EPriorityHigh ), |
|
32 iObserver( aObserver ), |
|
33 iId( aTimerId ) |
|
34 { |
|
35 SVPDEBUG2("CSVPTimer::CSVPTimer -- ID: %i", iId ); |
|
36 |
|
37 CActiveScheduler::Add( this ); |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CSVPTimer::CSVPTimer |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CSVPTimer::ConstructL() |
|
45 { |
|
46 CTimer::ConstructL(); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CSVPTimer::CSVPTimer |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CSVPTimer* CSVPTimer::NewL( MSVPTimerObserver& aObserver, |
|
54 TInt aTimerId ) |
|
55 { |
|
56 CSVPTimer* self = new (ELeave) CSVPTimer( aObserver, aTimerId ); |
|
57 |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CSVPTimer::~CSVPTimer |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CSVPTimer::~CSVPTimer() |
|
70 { |
|
71 Cancel(); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CSVPTimer::RunL |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CSVPTimer::RunL() |
|
79 { |
|
80 SVPDEBUG1("CSVPTimer::RunL In"); |
|
81 // Pass control to the observer. |
|
82 SVPDEBUG2( "CSVPTimer::RunL Timer -- ID: %d", iId ); |
|
83 iObserver.TimedOut( iId ); |
|
84 SVPDEBUG1("CSVPTimer::RunL Out"); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CSVPTimer::SetTime |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CSVPTimer::SetTime( TInt aMilliSeconds ) |
|
92 { |
|
93 SVPDEBUG2( "CSVPTimer::SetTime aMilliSeconds: %d", aMilliSeconds ); |
|
94 |
|
95 // Milliseconds to microseconds conversion |
|
96 const TTimeIntervalMicroSeconds32 time( |
|
97 KMicroSecondsCoefficient * aMilliSeconds ); |
|
98 |
|
99 CTimer::After( time ); // NB, CTimer::After calls SetActive |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CSVPTimer::Stop |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CSVPTimer::Stop() |
|
107 { |
|
108 SVPDEBUG2( "CSVPTimer::Stop Timer -- ID: %d", iId ); |
|
109 Cancel(); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CSVPTimer::Id |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CSVPTimer::Id() const |
|
117 { |
|
118 return iId; |
|
119 } |
|
120 |
|
121 // End of File |