|
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 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: Timer for the notifier* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CCseSchedulerTimer.h" // Header file for this class |
|
22 #include "MCseSchedulerTimerObserver.h" // Observer for informing engine |
|
23 #include <e32const.h> |
|
24 #include <e32cmn.h> |
|
25 #include <e32base.h> |
|
26 #include "CseDebug.h" // Debug macros |
|
27 |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 // None |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 // None |
|
34 |
|
35 // CONSTANTS |
|
36 // None |
|
37 |
|
38 // MACROS |
|
39 // None |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 // None |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 // None |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 // None |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None |
|
52 |
|
53 |
|
54 |
|
55 // ============================ MEMBER FUNCTIONS =============================== |
|
56 // --------------------------------------------------------------------------- |
|
57 // CCseSchedulerTimer::CCseSchedulerTimer() |
|
58 // |
|
59 // --------------------------------------------------------------------------- |
|
60 CCseSchedulerTimer::CCseSchedulerTimer( MCseSchedulerTimerObserver* aObserver ) : CTimer( CActive::EPriorityStandard ) |
|
61 { |
|
62 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::CCseSchedulerTimer"); |
|
63 |
|
64 // C++ default constructor |
|
65 iObserver = aObserver; |
|
66 |
|
67 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::CCseSchedulerTimer"); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CCseSchedulerTimer::~CCseSchedulerTimer() |
|
72 // |
|
73 // --------------------------------------------------------------------------- |
|
74 CCseSchedulerTimer::~CCseSchedulerTimer() |
|
75 { |
|
76 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::~CCseSchedulerTimer"); |
|
77 Cancel(); |
|
78 iObserver = NULL; |
|
79 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::~CCseSchedulerTimer"); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CCseSchedulerTimer::NewL() |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 CCseSchedulerTimer* CCseSchedulerTimer::NewL( |
|
87 MCseSchedulerTimerObserver* aObserver ) |
|
88 { |
|
89 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::NewL"); |
|
90 |
|
91 // Symbian C++ constructor |
|
92 CCseSchedulerTimer* self = new ( ELeave ) CCseSchedulerTimer(aObserver); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop( self ); |
|
96 |
|
97 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::NewL"); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CCseSchedulerTimer::ConstructL() |
|
103 // |
|
104 // --------------------------------------------------------------------------- |
|
105 void CCseSchedulerTimer::ConstructL() |
|
106 { |
|
107 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::ConstructL"); |
|
108 |
|
109 CTimer::ConstructL(); |
|
110 CActiveScheduler::Add( this ); |
|
111 |
|
112 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::ConstructL"); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CCseSchedulerTimer::SetTimer() |
|
117 // |
|
118 // --------------------------------------------------------------------------- |
|
119 void CCseSchedulerTimer::SetTimer( const TTime& aTime ) |
|
120 { |
|
121 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::SetTimer"); |
|
122 |
|
123 // Just cancel existing and start new one |
|
124 Cancel(); |
|
125 AtUTC( aTime ); |
|
126 |
|
127 #ifdef _DEBUG |
|
128 TBuf<100> startTimeBuf; |
|
129 _LIT( KDateTimeFormat,"CCseSchedulerTimer::SetTimer (UTC): %1%*D/%2%*M/%3%*Y %H:%T:%S.%C#" ); |
|
130 TRAP_IGNORE( aTime.FormatL( startTimeBuf, KDateTimeFormat ) ); |
|
131 CSELOGTEXT_HIGH_LEVEL( startTimeBuf ); |
|
132 #endif // _DEBUG |
|
133 |
|
134 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::SetTimer"); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CCseSchedulerTimer::DoCancel() |
|
139 // |
|
140 // --------------------------------------------------------------------------- |
|
141 void CCseSchedulerTimer::DoCancel() |
|
142 { |
|
143 CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::DoCancel"); |
|
144 |
|
145 CTimer::DoCancel(); |
|
146 |
|
147 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::DoCancel"); |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CCseSchedulerTimer::RunL() |
|
152 // |
|
153 // --------------------------------------------------------------------------- |
|
154 void CCseSchedulerTimer::RunL() |
|
155 { |
|
156 CSELOGSTRING2_HIGH_LEVEL(">>>CCseSchedulerTimer::RunL, iStatus: %d", iStatus.Int()); |
|
157 |
|
158 // Timer has fired. If everything went fine just kick the observer |
|
159 if ( iStatus.Int() == KErrNone ) |
|
160 { |
|
161 iObserver->RunPluginsL(); |
|
162 } |
|
163 else |
|
164 { |
|
165 // Something went propably wrong, let the observer error handler decide what. |
|
166 iObserver->TimerErrorL( iStatus.Int() ); |
|
167 } |
|
168 |
|
169 CSELOGSTRING_HIGH_LEVEL("<<<CCseSchedulerTimer::RunL"); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CCseSchedulerTimer::RunError |
|
174 // From CActive, called when RunL leaves. |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CCseSchedulerTimer::RunError( |
|
178 TInt aError ) |
|
179 { |
|
180 CSELOGSTRING2_HIGH_LEVEL(">>>CCseSchedulerServerSession::RunError: aError = %d", aError ); |
|
181 // ATM there isn't leaving code in RunL so we just cancel timer if it is active. |
|
182 Cancel(); |
|
183 |
|
184 #if CSE_LOGGING_METHOD == 0 |
|
185 ( void )aError; |
|
186 #endif |
|
187 |
|
188 // Return KErrNone to avoid crash. |
|
189 return KErrNone; |
|
190 } |
|
191 |
|
192 // End of file |