|
1 /* |
|
2 * Copyright (c) 2002 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 * Active object to count messages background for mainview. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 |
|
25 #include "MceUtilsIdleClass.h" |
|
26 |
|
27 #include "MceLogText.h" |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 |
|
38 CMceUtilsIdleClass* CMceUtilsIdleClass::NewL( |
|
39 MMceUtilsIdleClassObserver& aObserver ) |
|
40 { |
|
41 CMceUtilsIdleClass* self = new (ELeave) CMceUtilsIdleClass( aObserver ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 CMceUtilsIdleClass::CMceUtilsIdleClass( |
|
47 MMceUtilsIdleClassObserver& aObserver ) |
|
48 : |
|
49 CActive( CActive::EPriorityIdle ), |
|
50 iObserver( aObserver ) |
|
51 { |
|
52 CActiveScheduler::Add(this); |
|
53 } |
|
54 |
|
55 // destructor |
|
56 CMceUtilsIdleClass::~CMceUtilsIdleClass() |
|
57 { |
|
58 Cancel(); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // CMceUtilsIdleClass::StartL |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 void CMceUtilsIdleClass::StartL() |
|
66 { |
|
67 MCELOGGER_ENTERFN("CMceUtilsIdleClass::StartL()"); |
|
68 if(!IsActive()) |
|
69 { |
|
70 TRequestStatus *s = &iStatus; |
|
71 User::RequestComplete(s, KErrNone); |
|
72 SetActive(); |
|
73 MCELOGGER_WRITE_TIMESTAMP("Started at: "); |
|
74 } |
|
75 #ifdef _DEBUG |
|
76 else |
|
77 { |
|
78 MCELOGGER_WRITE_TIMESTAMP("Already running, time: "); |
|
79 } |
|
80 #endif |
|
81 MCELOGGER_LEAVEFN("CMceUtilsIdleClass::StartL()"); |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CMceUtilsIdleClass::FinishL |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 void CMceUtilsIdleClass::ForceFinishL() |
|
90 { |
|
91 MCELOGGER_ENTERFN("CMceUtilsIdleClass::ForceFinishL()"); |
|
92 if(IsActive()) |
|
93 { |
|
94 // First consume the outstanding completion. |
|
95 Cancel(); |
|
96 // Now try to do remaining steps synchronously. |
|
97 TBool startAgain = EFalse; |
|
98 TInt i = 0; |
|
99 MCELOGGER_WRITE_TIMESTAMP("start time: "); |
|
100 startAgain = iObserver.MMceUtilsIdleClassStepL(); |
|
101 while( startAgain && i < 100 /* safety */) |
|
102 { |
|
103 i++; |
|
104 startAgain = iObserver.MMceUtilsIdleClassStepL(); |
|
105 } |
|
106 MCELOGGER_WRITE_TIMESTAMP("stop time: "); |
|
107 } |
|
108 MCELOGGER_LEAVEFN("CMceUtilsIdleClass::ForceFinishL()"); |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CMceUtilsIdleClass::DoCancel |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 void CMceUtilsIdleClass::DoCancel() |
|
117 { |
|
118 } |
|
119 |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CMceUtilsIdleClass::RunL |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 void CMceUtilsIdleClass::RunL() |
|
126 { |
|
127 MCELOGGER_ENTERFN("CMceUtilsIdleClass::RunL()"); |
|
128 QueueNextL(); |
|
129 #ifdef _DEBUG |
|
130 if(!IsActive()) |
|
131 { |
|
132 MCELOGGER_WRITE("CMceUtilsIdleClass: finished"); |
|
133 MCELOGGER_WRITE_TIMESTAMP("CMceUtilsIdleClass Time: "); |
|
134 } |
|
135 #endif |
|
136 MCELOGGER_LEAVEFN("CMceUtilsIdleClass::RunL()"); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CMceUtilsIdleClass::RunError |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 TInt CMceUtilsIdleClass::RunError(TInt /*aError*/) |
|
144 { |
|
145 // ignore all the errors |
|
146 return KErrNone; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // CMceUtilsIdleClass::QueueLoad |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 void CMceUtilsIdleClass::QueueNextL() |
|
154 { |
|
155 MCELOGGER_ENTERFN("CMceUtilsIdleClass::QueueNextL()"); |
|
156 TBool startAgain = EFalse; |
|
157 MCELOGGER_WRITE_TIMESTAMP("About to call MMceUtilsIdleClassStepL: "); |
|
158 startAgain = iObserver.MMceUtilsIdleClassStepL(); |
|
159 MCELOGGER_WRITE_TIMESTAMP("<--- MMceUtilsIdleClassStepL done "); |
|
160 // OPEN: should we start again in case of leave? |
|
161 // OPEN: Is there need for some safety counter??? |
|
162 if( startAgain ) |
|
163 { |
|
164 TRequestStatus *s = &iStatus; |
|
165 User::RequestComplete(s, KErrNone); |
|
166 SetActive(); |
|
167 MCELOGGER_WRITE_TIMESTAMP("Started again at: "); |
|
168 } |
|
169 MCELOGGER_LEAVEFN("CMceUtilsIdleClass::QueueNextL()"); |
|
170 } |
|
171 |
|
172 |
|
173 // End of File |