|
1 /* |
|
2 * Copyright (c) 2007 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: Calendar view populator active object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <calencontext.h> |
|
21 |
|
22 //debug |
|
23 #include "calendarui_debug.h" |
|
24 #include "calenviewpopulator.h" |
|
25 #include "calencontroller.h" |
|
26 #include "calenglobaldata.h" |
|
27 #include "calennotifier.h" |
|
28 |
|
29 // ---------------------------------------------------------------------------- |
|
30 // CCalenViewPopulator::NewL |
|
31 // 1st phase of construction |
|
32 // (other items were commented in a header). |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CCalenViewPopulator* CCalenViewPopulator::NewL( CCalenController& aController ) |
|
36 { |
|
37 TRACE_ENTRY_POINT; |
|
38 |
|
39 CCalenViewPopulator* self = new( ELeave ) CCalenViewPopulator( aController ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 |
|
44 TRACE_EXIT_POINT; |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CCalenViewPopulator::CCalenViewPopulator |
|
50 // C++ constructor. |
|
51 // (other items were commented in a header). |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CCalenViewPopulator::CCalenViewPopulator( CCalenController& aController ) |
|
55 : CActive( EPriorityStandard ), |
|
56 iController( aController ), |
|
57 iNeedsInstanceView( EFalse ), |
|
58 iNeedsEntryView( EFalse ) |
|
59 { |
|
60 TRACE_ENTRY_POINT; |
|
61 |
|
62 CActiveScheduler::Add( this ); |
|
63 |
|
64 TRACE_EXIT_POINT; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CCalenViewPopulator::ConstructL |
|
69 // 2nd phase of construction. |
|
70 // (other items were commented in a header). |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 void CCalenViewPopulator::ConstructL() |
|
74 { |
|
75 TRACE_ENTRY_POINT; |
|
76 |
|
77 iController.RegisterForNotificationsL( this, ECalenNotifyEntryInstanceViewCreated ); |
|
78 iGlobalData = CCalenGlobalData::InstanceL(); |
|
79 |
|
80 TRACE_EXIT_POINT; |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CCalenViewPopulator::~CCalenViewPopulator |
|
85 // Destructor. |
|
86 // (other items were commented in a header). |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 CCalenViewPopulator::~CCalenViewPopulator() |
|
90 { |
|
91 TRACE_ENTRY_POINT; |
|
92 |
|
93 Cancel(); |
|
94 iController.CancelNotifications( this ); |
|
95 |
|
96 if( iGlobalData ) |
|
97 { |
|
98 iGlobalData->Release(); |
|
99 } |
|
100 |
|
101 TRACE_EXIT_POINT; |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------------------------- |
|
105 // CCalenViewPopulator::DoCancel |
|
106 // From CActive. Do nothing. |
|
107 // (other items were commented in a header). |
|
108 // ---------------------------------------------------------------------------- |
|
109 // |
|
110 void CCalenViewPopulator::DoCancel() |
|
111 { |
|
112 TRACE_ENTRY_POINT; |
|
113 |
|
114 iStatus = KErrCancel; |
|
115 |
|
116 TRACE_EXIT_POINT; |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CCalenViewPopulator::RunL |
|
121 // From CActive. |
|
122 // (other items were commented in a header). |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 void CCalenViewPopulator::RunL() |
|
126 { |
|
127 TRACE_ENTRY_POINT; |
|
128 |
|
129 ASSERT( iPopulatingView ); |
|
130 iPopulationStep = iPopulatingView->ActiveStepL(); |
|
131 |
|
132 switch( iPopulationStep ) |
|
133 { |
|
134 case CCalenView::EKeepGoing: |
|
135 { |
|
136 SetActive(); |
|
137 TRequestStatus* status = &iStatus; |
|
138 User::RequestComplete( status, KErrNone ); |
|
139 } |
|
140 break; |
|
141 case CCalenView::EWaitForInstanceView: |
|
142 { |
|
143 RArray<TInt> colIdArray; |
|
144 iController.GetActiveCollectionidsL(colIdArray); |
|
145 if(colIdArray.Count() > 0) |
|
146 { |
|
147 if( iGlobalData->InstanceViewL(colIdArray) ) |
|
148 { |
|
149 SetActive(); |
|
150 TRequestStatus* status = &iStatus; |
|
151 User::RequestComplete( status, KErrNone ); |
|
152 } |
|
153 else |
|
154 { |
|
155 iNeedsInstanceView = ETrue; |
|
156 // Wait for notification. |
|
157 } |
|
158 } |
|
159 else |
|
160 { |
|
161 if( iGlobalData->InstanceViewL() ) |
|
162 { |
|
163 SetActive(); |
|
164 TRequestStatus* status = &iStatus; |
|
165 User::RequestComplete( status, KErrNone ); |
|
166 } |
|
167 else |
|
168 { |
|
169 iNeedsInstanceView = ETrue; |
|
170 // Wait for notification. |
|
171 } |
|
172 } |
|
173 colIdArray.Reset(); |
|
174 } |
|
175 break; |
|
176 case CCalenView::EWaitForEntryView: |
|
177 { |
|
178 if( iGlobalData->EntryViewL() ) |
|
179 { |
|
180 SetActive(); |
|
181 TRequestStatus* status = &iStatus; |
|
182 User::RequestComplete( status, KErrNone ); |
|
183 } |
|
184 else |
|
185 { |
|
186 iNeedsEntryView = ETrue; |
|
187 // Wait for notification. |
|
188 } |
|
189 } |
|
190 break; |
|
191 case CCalenView::EDone: |
|
192 { |
|
193 iPopulatingView = NULL; |
|
194 iController.Notifier().BroadcastNotification( ECalenNotifyViewPopulationComplete ); |
|
195 } |
|
196 break; |
|
197 default: |
|
198 ASSERT( EFalse ); |
|
199 break; |
|
200 } |
|
201 |
|
202 TRACE_EXIT_POINT; |
|
203 } |
|
204 |
|
205 // ---------------------------------------------------------------------------- |
|
206 // CCalenViewPopulator::BeginPopulationL |
|
207 // Starts populating the given view. |
|
208 // (other items were commented in a header). |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CCalenViewPopulator::BeginPopulationL( CCalenView* aView ) |
|
212 { |
|
213 TRACE_ENTRY_POINT; |
|
214 |
|
215 ASSERT( !iPopulatingView ); |
|
216 iPopulatingView = aView; |
|
217 iPopulatingView->CancelPopulation(); |
|
218 iPopulationStep = CCalenView::EKeepGoing; |
|
219 SetActive(); |
|
220 TRequestStatus* status = &iStatus; |
|
221 User::RequestComplete( status, KErrNone ); |
|
222 |
|
223 TRACE_EXIT_POINT; |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CCalenViewPopulator::InterruptPopulationL |
|
228 // Stops current population. |
|
229 // (other items were commented in a header). |
|
230 // ---------------------------------------------------------------------------- |
|
231 // |
|
232 void CCalenViewPopulator::InterruptPopulationL() |
|
233 { |
|
234 TRACE_ENTRY_POINT; |
|
235 |
|
236 if( iPopulatingView ) |
|
237 { |
|
238 Cancel(); |
|
239 // This doesn't go in DoCancel because the active object might not be |
|
240 // active during population (i.e. when waiting for instance/entryview). |
|
241 iPopulatingView->CancelPopulation(); |
|
242 iPopulatingView = NULL; |
|
243 } |
|
244 |
|
245 TRACE_EXIT_POINT; |
|
246 } |
|
247 |
|
248 // ---------------------------------------------------------------------------- |
|
249 // CCalenViewPopulator::HandleECalenNotifyViewCreatedL |
|
250 // Leaving function that handles ECalenNotifyViewCreated |
|
251 // (other items were commented in a header). |
|
252 // ---------------------------------------------------------------------------- |
|
253 // |
|
254 void CCalenViewPopulator::HandleECalenNotifyViewCreatedL() |
|
255 { |
|
256 TRACE_ENTRY_POINT; |
|
257 |
|
258 RArray<TInt> colIdArray; |
|
259 iController.GetActiveCollectionidsL(colIdArray); |
|
260 |
|
261 if( iPopulatingView ) |
|
262 {//When commandline is compatiable with new globaldata functionalities, the collectionid |
|
263 // to EntryView can be given |
|
264 if( ( iNeedsEntryView && iGlobalData->EntryViewL(/*iGlobalData->Context().InstanceId().iColId*/) ) || |
|
265 ( iNeedsInstanceView && iGlobalData->InstanceViewL(colIdArray) ) ) |
|
266 { |
|
267 SetActive(); |
|
268 TRequestStatus* status = &iStatus; |
|
269 User::RequestComplete( status, KErrNone ); |
|
270 } |
|
271 } |
|
272 |
|
273 if( iGlobalData->EntryViewL(/*iGlobalData->Context().InstanceId().iColId*/) |
|
274 && iGlobalData->InstanceViewL(colIdArray) ) |
|
275 { |
|
276 iController.CancelNotifications( this ); |
|
277 } |
|
278 |
|
279 colIdArray.Reset(); |
|
280 |
|
281 TRACE_EXIT_POINT; |
|
282 } |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // CCalenViewPopulator::HandleNotification |
|
286 // Calls back when the entry view or instance view has been created. |
|
287 // (other items were commented in a header). |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 void CCalenViewPopulator::HandleNotification(const TCalenNotification aNotification ) |
|
291 { |
|
292 TRACE_ENTRY_POINT; |
|
293 |
|
294 if ( aNotification == ECalenNotifyEntryInstanceViewCreated ) |
|
295 { |
|
296 PIM_TRAPD_HANDLE( HandleECalenNotifyViewCreatedL() ); |
|
297 } |
|
298 |
|
299 TRACE_EXIT_POINT; |
|
300 } |
|
301 |
|
302 // End of file |