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