|
1 /* |
|
2 * Copyright (c) 2008 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: This is the source file for the CClockWorldItemProcessor class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // User includes |
|
22 #include "clockworlditemprocessor.h" |
|
23 #include "clockworldcontainer.h" |
|
24 #include "clock_debug.h" |
|
25 |
|
26 // Literals |
|
27 |
|
28 // Constants |
|
29 const TInt KEvenNumber( 2 ); |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // CClockWorldItemProcessor::NewL |
|
33 // rest of the details are commented in the header |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 CClockWorldItemProcessor* CClockWorldItemProcessor::NewL( CClockWorldContainer* aContainer ) |
|
37 { |
|
38 __PRINTS( "CClockWorldItemProcessor::NewL - Entry" ); |
|
39 |
|
40 CClockWorldItemProcessor* self = new( ELeave ) CClockWorldItemProcessor(); |
|
41 |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aContainer ); |
|
44 |
|
45 CleanupStack::Pop( self ); |
|
46 |
|
47 __PRINTS( "CClockWorldItemProcessor::NewL - Exit" ); |
|
48 |
|
49 return self; |
|
50 |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CClockWorldItemProcessor::~CClockWorldItemProcessor |
|
55 // rest of the details are commented in the header |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 CClockWorldItemProcessor::~CClockWorldItemProcessor() |
|
59 { |
|
60 __PRINTS( "CClockWorldItemProcessor::~CClockWorldItemProcessor - Entry" ); |
|
61 |
|
62 Cancel(); |
|
63 |
|
64 __PRINTS( "CClockWorldItemProcessor::~CClockWorldItemProcessor - Exit" ); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CClockWorldItemProcessor::ProcessEachItem |
|
69 // rest of the details are commented in the header |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 TInt CClockWorldItemProcessor::ProcessEachItem( TInt aIndex ) |
|
73 { |
|
74 __PRINTS( "CClockWorldItemProcessor::ProcessEachItem - Entry" ); |
|
75 |
|
76 TInt retValue( KErrNotFound ); |
|
77 |
|
78 if( iContainer ) |
|
79 { |
|
80 retValue = iContainer->RedrawItem( aIndex ); |
|
81 } |
|
82 |
|
83 __PRINTS( "CClockWorldItemProcessor::ProcessEachItem - Exit" ); |
|
84 |
|
85 return retValue; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CClockWorldItemProcessor::RunL |
|
90 // rest of the details are commented in the header |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 void CClockWorldItemProcessor::RunL() |
|
94 { |
|
95 __PRINTS( "CClockWorldItemProcessor::RunL - Entry" ); |
|
96 |
|
97 // Call the redraw for even number lisitems first and then for the odd number lisitems |
|
98 // This gives a faster loading effect on the hardware |
|
99 |
|
100 TInt returnValue( KErrNone ); |
|
101 |
|
102 returnValue = ProcessEachItem( iDrawnListItem ); |
|
103 |
|
104 if( returnValue ) |
|
105 { |
|
106 iDrawnListItem = iDrawnListItem + KEvenNumber; |
|
107 } |
|
108 else if( KErrNone == iDrawnListItem % KEvenNumber ) |
|
109 { |
|
110 iDrawnListItem = KEvenNumber - 1; |
|
111 } |
|
112 else |
|
113 { |
|
114 Cancel(); |
|
115 |
|
116 __PRINTS( "CClockWorldItemProcessor::RunL - Exit" ); |
|
117 |
|
118 return; |
|
119 } |
|
120 |
|
121 DoAsyncCallback(); |
|
122 |
|
123 __PRINTS( "CClockWorldItemProcessor::RunL - Exit" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------- |
|
127 // CClockWorldItemProcessor::DoCancel |
|
128 // rest of the details are commented in the header |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 void CClockWorldItemProcessor::DoCancel() |
|
132 { |
|
133 __PRINTS( "CClockWorldItemProcessor::DoCancel - Entry" ); |
|
134 |
|
135 // No Implementation Yet. |
|
136 |
|
137 __PRINTS( "CClockWorldItemProcessor::DoCancel - Exit" ); |
|
138 } |
|
139 |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CClockWorldItemProcessor::CClockWorldItemProcessor |
|
143 // rest of the details are commented in the header |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 CClockWorldItemProcessor::CClockWorldItemProcessor() : CActive( CActive::EPriorityStandard ) |
|
147 { |
|
148 __PRINTS( "CClockWorldItemProcessor::CClockWorldItemProcessor - Entry" ); |
|
149 |
|
150 CActiveScheduler::Add( this ); |
|
151 DoAsyncCallback(); |
|
152 |
|
153 __PRINTS( "CClockWorldItemProcessor::CClockWorldItemProcessor - Exit" ); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // CClockWorldItemProcessor::ConstructL |
|
158 // rest of the details are commented in the header |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 void CClockWorldItemProcessor::ConstructL( CClockWorldContainer* aContainer ) |
|
162 { |
|
163 __PRINTS( "CClockWorldItemProcessor::ConstructL - Entry" ); |
|
164 |
|
165 iContainer = aContainer; |
|
166 iDrawnListItem = 0; |
|
167 |
|
168 __PRINTS( "CClockWorldItemProcessor::ConstructL - Exit" ); |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // CClockWorldItemProcessor::DoAsyncCallback |
|
173 // rest of the details are commented in the header |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CClockWorldItemProcessor::DoAsyncCallback() |
|
177 { |
|
178 __PRINTS( "CClockWorldItemProcessor::DoAsyncCallback - Entry" ); |
|
179 |
|
180 if( !IsActive() ) |
|
181 { |
|
182 if( IsAdded() ) |
|
183 { |
|
184 // Make sure this is the last Active Object in the list |
|
185 Deque(); |
|
186 CActiveScheduler::Add( this ); |
|
187 } |
|
188 TRequestStatus* status = &iStatus; |
|
189 User::RequestComplete( status, KErrNone ); |
|
190 SetActive(); |
|
191 } |
|
192 |
|
193 __PRINTS( "CClockWorldItemProcessor::DoAsyncCallback - Exit" ); |
|
194 } |
|
195 |
|
196 // End of file |