14 * Description: Calendar notifier |
14 * Description: Calendar notifier |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 //system includes |
20 #include <aknappui.h> // iavkonappui macro |
|
21 #include <bacntf.h> // cenvironmentchangenotifier |
|
22 #include <coemain.h> // eactiveprioritylogona |
|
23 #include <centralrepository.h> // crepository |
|
24 #include <ErrorUI.h> // cerrorui |
|
25 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS // new |
|
26 #include <asshdalarm.h> |
|
27 #else // new |
|
28 #include <asshdalarm.h> |
|
29 #include <ASShdAlarmCal.h> |
|
30 #endif // new |
|
31 #include <e32property.h> |
20 #include <e32property.h> |
32 #include <calfilechangenotification.h> |
21 #include <bacntf.h> // CEnvironmentChangeNotifier |
33 #include <calenecomwatcher.h> |
22 #include <coemain.h> // EActivePriorityLogonA |
34 #include <calenglobaldata.h> |
23 |
35 #include <calenconstants.h> |
24 //user includes |
36 #include <calencontext.h> |
|
37 #include <calsession.h> |
|
38 #include <calcalendarinfo.h> |
|
39 #include <calenmulticaluids.hrh> |
|
40 |
|
41 #include "calendarui_debug.h" |
25 #include "calendarui_debug.h" |
42 #include "calennotifier.h" // CCalenNotifier |
26 #include "calennotifier.h" // CalenNotifier |
43 #include "CalendarPrivateCRKeys.h" // Central Repository keys |
|
44 #include "calensetting.h" |
|
45 #include "calenstatemachine.h" |
27 #include "calenstatemachine.h" |
46 #include "calencontroller.h" |
|
47 |
28 |
48 const TInt KHashLength = 64; |
29 const TInt KHashLength = 64; |
49 const TInt KBuffLength = 24; |
30 |
50 |
31 // ---------------------------------------------------------------------------- |
51 // ---------------------------------------------------------------------------- |
32 // CalenNotifier::CalenNotifier |
52 // CCalenNotifier::CCalenNotifier |
|
53 // C++ default constructor. |
33 // C++ default constructor. |
54 // (other items were commented in a header). |
34 // (other items were commented in a header). |
55 // ---------------------------------------------------------------------------- |
35 // ---------------------------------------------------------------------------- |
56 // |
36 // |
57 CCalenNotifier::CCalenNotifier( CCalenController& aController ) |
37 CalenNotifier::CalenNotifier( CCalenStateMachine& aStateMachine ) |
58 : iController( aController ) |
38 : iStateMachine( aStateMachine ) |
59 { |
39 { |
60 TRACE_ENTRY_POINT; |
40 TRACE_ENTRY_POINT; |
61 TRACE_EXIT_POINT; |
41 TRACE_EXIT_POINT; |
62 } |
42 } |
63 |
43 |
64 // ---------------------------------------------------------------------------- |
44 // ---------------------------------------------------------------------------- |
65 // CCalenNotifier::~CCalenNotifier |
45 // CalenNotifier::~CalenNotifier |
66 // Destructor. |
46 // Destructor. |
67 // (other items were commented in a header). |
47 // (other items were commented in a header). |
68 // ---------------------------------------------------------------------------- |
48 // ---------------------------------------------------------------------------- |
69 // |
49 // |
70 CCalenNotifier::~CCalenNotifier() |
50 CalenNotifier::~CalenNotifier() |
71 { |
51 { |
72 TRACE_ENTRY_POINT; |
52 TRACE_ENTRY_POINT; |
73 |
53 |
74 // Stop database change notifications. |
|
75 delete iDbChangeNotifier; |
|
76 |
|
77 // Stop ECom change notifications |
|
78 delete iEComWatcher; |
|
79 |
|
80 // Release the global data |
|
81 if( iGlobalData ) |
|
82 { |
|
83 iGlobalData->Release(); |
|
84 } |
|
85 |
|
86 if( iSetting ) |
|
87 { |
|
88 iSetting->Release(); |
|
89 } |
|
90 |
|
91 // Stop environment change notifications |
|
92 if( iEnvChangeNotifier ) |
|
93 { |
|
94 iEnvChangeNotifier->Cancel(); |
|
95 delete iEnvChangeNotifier; |
|
96 } |
|
97 |
|
98 // Stop settings change notifications |
|
99 delete iCenRepChangeNotifier; |
|
100 delete iRepository; |
|
101 |
|
102 // Reset the handler array. |
54 // Reset the handler array. |
103 // Before we reset , close hashset for each handler |
55 // Before we reset , close hashset for each handler |
104 for(TInt i = 0 ; i < iHandlers.Count() ; i++) |
56 for(TInt i = 0 ; i < iHandlers.Count() ; i++) |
105 { |
57 { |
106 iHandlers[i].iHashSet.Close(); |
58 iHandlers[i].iHashSet.Close(); |
107 } |
59 } |
108 |
60 |
109 iHandlers.Reset(); |
61 iHandlers.Reset(); |
110 iBroadcastQueue.Reset(); |
62 iBroadcastQueue.Reset(); |
111 |
63 |
112 // stop listening for calendar file change notifications |
64 // Stop environment change notifications |
113 iGlobalData->CalSessionL().StopFileChangeNotification(); |
65 if( iEnvChangeNotifier ) |
114 |
66 { |
115 iAsyncCallback->Cancel(); |
67 iEnvChangeNotifier->Cancel(); |
116 delete iAsyncCallback; |
68 delete iEnvChangeNotifier; |
117 |
69 } |
118 delete iFilnameDeleted; |
70 |
119 |
71 TRACE_EXIT_POINT; |
120 TRACE_EXIT_POINT; |
72 } |
121 } |
73 |
122 |
74 // ---------------------------------------------------------------------------- |
123 // ---------------------------------------------------------------------------- |
75 // CalenNotifier::ConstructL |
124 // CCalenNotifier::ConstructL |
|
125 // Symbian 2nd phase of construction. |
76 // Symbian 2nd phase of construction. |
126 // (other items were commented in a header). |
77 // (other items were commented in a header). |
127 // ---------------------------------------------------------------------------- |
78 // ---------------------------------------------------------------------------- |
128 // |
79 // |
129 void CCalenNotifier::ConstructL() |
80 void CalenNotifier::ConstructL() |
130 { |
81 { |
131 TRACE_ENTRY_POINT; |
82 TRACE_ENTRY_POINT; |
132 |
|
133 // Get the global data |
|
134 iGlobalData = CCalenGlobalData::InstanceL(); |
|
135 |
|
136 // Get the setting singleton. We update it when settings change. |
|
137 iSetting = CCalenSetting::InstanceL(); |
|
138 |
83 |
139 // Register for system environment changes |
84 // Register for system environment changes |
140 TCallBack envCallback( EnvChangeCallbackL, this ); |
85 TCallBack envCallback( EnvChangeCallbackL, this ); |
141 iEnvChangeNotifier = |
86 iEnvChangeNotifier = |
142 CEnvironmentChangeNotifier::NewL( EActivePriorityLogonA, envCallback ); |
87 CEnvironmentChangeNotifier::NewL( EActivePriorityLogonA, envCallback ); |
143 iEnvChangeNotifier->Start(); |
88 iEnvChangeNotifier->Start(); |
144 |
89 |
145 // Register for changes to Calendar settings from the Central Repository |
90 iIgnoreFirstLocaleChange = ETrue; |
146 iRepository = CRepository::NewL( KCRUidCalendar ); |
91 |
147 iCenRepChangeNotifier = CCenRepNotifyHandler::NewL( *this, *iRepository ); |
92 TRACE_EXIT_POINT; |
148 iCenRepChangeNotifier->StartListeningL(); |
93 } |
149 |
94 |
150 // Register for changes to our database session |
95 // ---------------------------------------------------------------------------- |
151 iDbChangeNotifier = CCalenDbChangeNotifier::NewL( *iGlobalData ); |
96 // CalenNotifier::RegisterForNotificationsL |
152 iDbChangeNotifier->RegisterObserverL( *this ); |
|
153 |
|
154 // Register for changes to the ECom registry |
|
155 iEComWatcher = CCalenEComWatcher::NewL( *this ); |
|
156 |
|
157 iIgnoreFirstLocaleChange = ETrue; |
|
158 |
|
159 // start listening for calendar file change notifications |
|
160 iGlobalData->CalSessionL().StartFileChangeNotificationL(*this); |
|
161 |
|
162 TCallBack callback(CCalenNotifier::AsyncRemoveCalendarL,this); |
|
163 iAsyncCallback = new(ELeave) CAsyncCallBack(callback,CActive::EPriorityStandard); |
|
164 |
|
165 iFilnameDeleted = NULL; |
|
166 |
|
167 TRACE_EXIT_POINT; |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CCalenNotifier::RegisterForNotificationsL |
|
172 // Adds the passed handler to the handler array. |
97 // Adds the passed handler to the handler array. |
173 // (other items were commented in a header). |
98 // (other items were commented in a header). |
174 // ---------------------------------------------------------------------------- |
99 // ---------------------------------------------------------------------------- |
175 // |
100 // |
176 void CCalenNotifier::RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
101 void CalenNotifier::RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
177 TCalenNotification aNotification) |
102 TCalenNotification aNotification) |
178 { |
103 { |
179 TRACE_ENTRY_POINT; |
104 TRACE_ENTRY_POINT; |
180 |
105 |
181 TNotificationHandler handler; |
106 TNotificationHandler handler; |
276 |
201 |
277 TRACE_EXIT_POINT; |
202 TRACE_EXIT_POINT; |
278 } |
203 } |
279 |
204 |
280 // ---------------------------------------------------------------------------- |
205 // ---------------------------------------------------------------------------- |
|
206 // CalenNotifier::ContextChanged |
|
207 // From MCalenContextChangeObserver. Called when the context changes. |
|
208 // (other items were commented in a header). |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CalenNotifier::ContextChanged() |
|
212 { |
|
213 TRACE_ENTRY_POINT; |
|
214 |
|
215 BroadcastNotification( ECalenNotifyContextChanged ); |
|
216 |
|
217 TRACE_EXIT_POINT; |
|
218 } |
|
219 |
|
220 // ---------------------------------------------------------------------------- |
281 // CCalenNotifier::EnvChangeCallbackL |
221 // CCalenNotifier::EnvChangeCallbackL |
282 // CEnvironmentChangeNotifier callback. Calendar is only interested in: |
222 // CEnvironmentChangeNotifier callback. Calendar is only interested in: |
283 // EChangesLocale - System locale changed |
223 // EChangesLocale - System locale changed |
284 // EChangesMidnightCrossover - System time passed midnight |
224 // EChangesMidnightCrossover - System time passed midnight |
285 // EChangesSystemTime - System time changed |
225 // EChangesSystemTime - System time changed |
286 // (other items were commented in a header). |
226 // (other items were commented in a header). |
287 // ---------------------------------------------------------------------------- |
227 // ---------------------------------------------------------------------------- |
288 // |
228 // |
289 TInt CCalenNotifier::EnvChangeCallbackL( TAny* aThisPtr ) |
229 TInt CalenNotifier::EnvChangeCallbackL( TAny* aThisPtr ) |
290 { |
230 { |
291 TRACE_ENTRY_POINT; |
231 TRACE_ENTRY_POINT; |
292 |
232 |
293 /* CCalenNotifier* thisPtr = static_cast<CCalenNotifier*>( aThisPtr ); |
|
294 |
|
295 if( thisPtr->iEnvChangeNotifier->Change() & EChangesMidnightCrossover ) |
|
296 { |
|
297 thisPtr->BroadcastNotification( ECalenNotifySystemTimeChanged ); |
|
298 } |
|
299 |
|
300 if( thisPtr->iEnvChangeNotifier->Change() & EChangesLocale ) |
|
301 { |
|
302 thisPtr->BroadcastNotification( ECalenNotifySystemLocaleChanged ); |
|
303 } |
|
304 |
|
305 if( thisPtr->iEnvChangeNotifier->Change() & EChangesSystemTime ) |
|
306 { |
|
307 thisPtr->BroadcastNotification( ECalenNotifySystemTimeChanged ); |
|
308 }*/ |
|
309 |
|
310 TRACE_EXIT_POINT; |
233 TRACE_EXIT_POINT; |
311 // Return value for functions used as TCallBack objects should be EFalse |
234 // Return value for functions used as TCallBack objects should be EFalse |
312 // unless the function is intended to be called again from a timer. |
235 // unless the function is intended to be called again from a timer. |
313 // return EFalse; |
236 // return EFalse; |
314 return static_cast<CCalenNotifier*>(aThisPtr)->DoEnvChange(); |
237 return static_cast<CalenNotifier*>(aThisPtr)->DoEnvChange(); |
315 } |
238 } |
316 |
239 |
317 // ---------------------------------------------------------------------------- |
240 // ---------------------------------------------------------------------------- |
318 // CCalenNotifier::DoEnvChange |
241 // CCalenNotifier::DoEnvChange |
319 // EnvChangeCallbackL calls this function |
242 // EnvChangeCallbackL calls this function |
320 // ---------------------------------------------------------------------------- |
243 // ---------------------------------------------------------------------------- |
321 // |
244 // |
322 TInt CCalenNotifier::DoEnvChange() |
245 TInt CalenNotifier::DoEnvChange() |
323 { |
246 { |
324 TRACE_ENTRY_POINT; |
247 TRACE_ENTRY_POINT; |
325 |
248 |
326 if( ((iEnvChangeNotifier->Change() & EChangesMidnightCrossover) |
249 if( ((iEnvChangeNotifier->Change() & EChangesMidnightCrossover) |
327 || (iEnvChangeNotifier->Change() & EChangesSystemTime)) |
250 || (iEnvChangeNotifier->Change() & EChangesSystemTime)) |
328 && !iIgnoreFirstLocaleChange ) |
251 && !iIgnoreFirstLocaleChange ) |
329 { |
252 { |
330 BroadcastNotification( ECalenNotifySystemTimeChanged ); |
253 BroadcastNotification( ECalenNotifySystemTimeChanged ); |
331 } |
254 } |
332 else if( (iEnvChangeNotifier->Change() & EChangesLocale) |
255 else if( (iEnvChangeNotifier->Change() & EChangesLocale) |
333 && !iIgnoreFirstLocaleChange ) |
256 && !iIgnoreFirstLocaleChange ) |
334 { |
257 { |
335 BroadcastNotification( ECalenNotifySystemLocaleChanged ); |
258 BroadcastNotification( ECalenNotifySystemLocaleChanged ); |
336 } |
259 } |
337 else |
260 else |
338 { |
261 { |
339 iIgnoreFirstLocaleChange = EFalse; |
262 iIgnoreFirstLocaleChange = EFalse; |
340 } |
263 } |
341 |
264 |
342 TRACE_EXIT_POINT; |
265 TRACE_EXIT_POINT; |
343 return EFalse ; |
266 return EFalse ; |
344 } |
267 } |
345 // ---------------------------------------------------------------------------- |
268 |
346 // CCalenNotifier::HandleNotifyGeneric |
269 // ---------------------------------------------------------------------------- |
347 // From MCenRepNotifyHandlerCallback |
270 // CalenNotifier::BroadcastNotification |
348 // Generic notification that one of our central repository keys has changed |
|
349 // If any keys change we broadcast a settings changed notification |
|
350 // (other items were commented in a header). |
|
351 // ---------------------------------------------------------------------------- |
|
352 // |
|
353 void CCalenNotifier::HandleNotifyGeneric( TUint32 /*aId*/ ) |
|
354 { |
|
355 TRACE_ENTRY_POINT; |
|
356 |
|
357 PIM_TRAPD_HANDLE( iSetting->LoadL() ); |
|
358 BroadcastNotification( ECalenNotifySettingsChanged ); |
|
359 |
|
360 // Use another trap to make sure we start listening again, regardless |
|
361 // of whether the previous function left or not. |
|
362 PIM_TRAPD_HANDLE( iCenRepChangeNotifier->StartListeningL() ); |
|
363 |
|
364 TRACE_EXIT_POINT; |
|
365 } |
|
366 |
|
367 // ---------------------------------------------------------------------------- |
|
368 // CCalenNotifier::HandleNotifyError |
|
369 // Cenrep watcher error callback |
|
370 // (other items were commented in a header). |
|
371 // ---------------------------------------------------------------------------- |
|
372 // |
|
373 void CCalenNotifier::HandleNotifyError( TUint32 /*aId*/, |
|
374 TInt /*aError*/, |
|
375 CCenRepNotifyHandler* /*aHandler*/ ) |
|
376 { |
|
377 TRACE_ENTRY_POINT; |
|
378 |
|
379 PIM_TRAPD_HANDLE( iCenRepChangeNotifier->StartListeningL() ); |
|
380 |
|
381 TRACE_EXIT_POINT; |
|
382 } |
|
383 |
|
384 // ---------------------------------------------------------------------------- |
|
385 // CCalenNotifier::HandleDBChangeL |
|
386 // From MCalenDBChangeObserver |
|
387 // Notification that an external CCalSession has modified the database we are |
|
388 // using in some way. This notification is limited to a maximum of one per |
|
389 // second. This is to avoid multiple notifications when performing large sync |
|
390 // operations |
|
391 // (other items were commented in a header). |
|
392 // ---------------------------------------------------------------------------- |
|
393 // |
|
394 void CCalenNotifier::HandleDBChangeL() |
|
395 { |
|
396 TRACE_ENTRY_POINT; |
|
397 |
|
398 BroadcastNotification( ECalenNotifyExternalDatabaseChanged ); |
|
399 |
|
400 TRACE_EXIT_POINT; |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // CCalenNotifier::ContextChanged |
|
405 // From MCalenContextChangeObserver. Called when the context changes. |
|
406 // (other items were commented in a header). |
|
407 // ---------------------------------------------------------------------------- |
|
408 // |
|
409 void CCalenNotifier::ContextChanged() |
|
410 { |
|
411 TRACE_ENTRY_POINT; |
|
412 |
|
413 BroadcastNotification( ECalenNotifyContextChanged ); |
|
414 |
|
415 TRACE_EXIT_POINT; |
|
416 } |
|
417 |
|
418 // ---------------------------------------------------------------------------- |
|
419 // CCalenNotifier::EComChanged |
|
420 // From MCalenEComChangeObserver. Called when the ECom registry changes |
|
421 // (install/uninstall). |
|
422 // ---------------------------------------------------------------------------- |
|
423 // |
|
424 void CCalenNotifier::EComChanged() |
|
425 { |
|
426 TRACE_ENTRY_POINT; |
|
427 |
|
428 if(!iController.IsFasterAppFlagEnabled()) |
|
429 { |
|
430 BroadcastNotification( ECalenNotifyEComRegistryChanged ); |
|
431 } |
|
432 |
|
433 TRACE_EXIT_POINT; |
|
434 } |
|
435 |
|
436 // ---------------------------------------------------------------------------- |
|
437 // CCalenNotifier::DeferSettingsNotifications |
|
438 // After calling this function, any settings changed notifications |
|
439 // will not be broadcast until after ResumeSettingsNotifications |
|
440 // has been called. |
|
441 // (other items were commented in a header). |
|
442 // ---------------------------------------------------------------------------- |
|
443 // |
|
444 void CCalenNotifier::DeferSettingsNotifications() |
|
445 { |
|
446 TRACE_ENTRY_POINT; |
|
447 |
|
448 iIsSettingsBroadcastDeferred = ETrue; |
|
449 |
|
450 TRACE_EXIT_POINT; |
|
451 } |
|
452 |
|
453 // ---------------------------------------------------------------------------- |
|
454 // CCalenNotifier::ResumeSettingsNotifications |
|
455 // Resumes settings notifications after they have been paused |
|
456 // with DeferSettingsNotifications. |
|
457 // (other items were commented in a header). |
|
458 // ---------------------------------------------------------------------------- |
|
459 // |
|
460 void CCalenNotifier::ResumeSettingsNotifications() |
|
461 { |
|
462 TRACE_ENTRY_POINT; |
|
463 |
|
464 iIsSettingsBroadcastDeferred = EFalse; |
|
465 |
|
466 if( iSettingsNeedsBroadcast ) |
|
467 { |
|
468 iSettingsNeedsBroadcast = EFalse; |
|
469 BroadcastNotification( ECalenNotifySettingsChanged ); |
|
470 } |
|
471 |
|
472 if( iLocaleNeedsBroadcast ) |
|
473 { |
|
474 iLocaleNeedsBroadcast = EFalse; |
|
475 BroadcastNotification( ECalenNotifySystemLocaleChanged ); |
|
476 } |
|
477 |
|
478 TRACE_EXIT_POINT; |
|
479 } |
|
480 |
|
481 // ---------------------------------------------------------------------------- |
|
482 // CCalenNotifier::BroadcastNotification |
|
483 // Issues a notification to all registered handlers |
271 // Issues a notification to all registered handlers |
484 // (other items were commented in a header). |
272 // (other items were commented in a header). |
485 // ---------------------------------------------------------------------------- |
273 // ---------------------------------------------------------------------------- |
486 // |
274 // |
487 void CCalenNotifier::BroadcastNotification( TCalenNotification aNotification ) |
275 void CalenNotifier::BroadcastNotification( TCalenNotification aNotification ) |
488 { |
276 { |
489 TRACE_ENTRY_POINT; |
277 TRACE_ENTRY_POINT; |
490 |
278 |
491 // Someone has told us to broadcast, or one of our notifiers completed. |
279 // Someone has told us to broadcast, or one of our notifiers completed. |
492 // We run it past the state machine and that may or may not call the |
280 // We run it past the state machine and that may or may not call the |
493 // function to really do the broadcast. |
281 // function to really do the broadcast. |
494 iController.StateMachine().HandleNotification( aNotification ); |
282 iStateMachine.HandleNotification( aNotification ); |
495 |
283 |
496 TRACE_EXIT_POINT; |
284 TRACE_EXIT_POINT; |
497 } |
285 } |
498 |
286 |
499 // ---------------------------------------------------------------------------- |
287 // ---------------------------------------------------------------------------- |
500 // CCalenNotifier::BroadcastApprovedNotification |
288 // CalenNotifier::BroadcastApprovedNotification |
501 // Issues a notification to all registered handlers |
289 // Issues a notification to all registered handlers |
502 // (other items were commented in a header). |
290 // (other items were commented in a header). |
503 // ---------------------------------------------------------------------------- |
291 // ---------------------------------------------------------------------------- |
504 // |
292 // |
505 void CCalenNotifier::BroadcastApprovedNotification( TCalenNotification aNotification ) |
293 void CalenNotifier::BroadcastApprovedNotification( TCalenNotification aNotification ) |
506 { |
294 { |
507 TRACE_ENTRY_POINT; |
295 TRACE_ENTRY_POINT; |
508 /*if ( aNotification == ECalenNotifySettingsChanged |
296 |
509 && iIsSettingsBroadcastDeferred ) |
297 iBroadcastQueue.Append( aNotification ); |
510 { |
298 |
511 iSettingsNeedsBroadcast = ETrue; |
299 if( !iBroadcastActive ) |
512 } |
300 { |
513 else if ( aNotification == ECalenNotifySystemLocaleChanged |
301 iBroadcastActive = ETrue; |
514 && iIsSettingsBroadcastDeferred) |
302 while( iBroadcastQueue.Count() ) |
515 { |
303 { |
516 iLocaleNeedsBroadcast = ETrue; |
304 TCalenNotification notification = iBroadcastQueue[0]; |
517 } |
305 DoBroadcast( notification ); |
518 else*/ |
306 iBroadcastQueue.Remove( 0 ); |
519 { |
307 } |
520 iBroadcastQueue.Append( aNotification ); |
308 iBroadcastActive = EFalse; |
521 |
309 } |
522 if( !iBroadcastActive ) |
310 |
523 { |
311 TRACE_EXIT_POINT; |
524 iBroadcastActive = ETrue; |
312 } |
525 while( iBroadcastQueue.Count() ) |
313 |
526 { |
314 // ---------------------------------------------------------------------------- |
527 TCalenNotification notification = iBroadcastQueue[0]; |
315 // CalenNotifier::DoBroadcast |
528 DoBroadcast( notification ); |
|
529 iBroadcastQueue.Remove( 0 ); |
|
530 } |
|
531 iBroadcastActive = EFalse; |
|
532 } |
|
533 } |
|
534 |
|
535 TRACE_EXIT_POINT; |
|
536 } |
|
537 |
|
538 // ---------------------------------------------------------------------------- |
|
539 // CCalenNotifier::DoBroadcast |
|
540 // Issues a notification to all registered handlers |
316 // Issues a notification to all registered handlers |
541 // (other items were commented in a header). |
317 // (other items were commented in a header). |
542 // ---------------------------------------------------------------------------- |
318 // ---------------------------------------------------------------------------- |
543 // |
319 // |
544 void CCalenNotifier::DoBroadcast( TCalenNotification aNotification ) |
320 void CalenNotifier::DoBroadcast( TCalenNotification aNotification ) |
545 { |
321 { |
546 TRACE_ENTRY_POINT; |
322 TRACE_ENTRY_POINT; |
547 |
323 |
548 for( TInt x = 0; x < iHandlers.Count(); ++x ) |
324 for( TInt x = 0; x < iHandlers.Count(); ++x ) |
549 { |
325 { |
565 |
341 |
566 TRACE_EXIT_POINT; |
342 TRACE_EXIT_POINT; |
567 } |
343 } |
568 |
344 |
569 // ---------------------------------------------------------------------------- |
345 // ---------------------------------------------------------------------------- |
570 // CCalenNotifier::Progress |
346 // CalenNotifier::TNotificationHandler() |
571 // From MCalProgressCallback. Intentionally empty. |
|
572 // (other items were commented in a header). |
|
573 // ---------------------------------------------------------------------------- |
|
574 // |
|
575 void CCalenNotifier::Progress( TInt /*aPercentageCompleted*/ ) |
|
576 { |
|
577 TRACE_ENTRY_POINT; |
|
578 TRACE_EXIT_POINT; |
|
579 } |
|
580 |
|
581 // ---------------------------------------------------------------------------- |
|
582 // CCalenNotifier::NotifyProgress |
|
583 // From MCalProgressCallback. Don't notify us about progress updates. |
|
584 // (other items were commented in a header). |
|
585 // ---------------------------------------------------------------------------- |
|
586 // |
|
587 TBool CCalenNotifier::NotifyProgress() |
|
588 { |
|
589 TRACE_ENTRY_POINT; |
|
590 |
|
591 BroadcastNotification( ECalenNotifyViewCreationStarted ); |
|
592 |
|
593 TRACE_EXIT_POINT; |
|
594 return EFalse; |
|
595 } |
|
596 |
|
597 // ---------------------------------------------------------------------------- |
|
598 // CCalenNotifier::Completed |
|
599 // From MCalProgressCallback. |
|
600 // Notifies observer of completion |
|
601 // (other items were commented in a header). |
|
602 // ---------------------------------------------------------------------------- |
|
603 // |
|
604 void CCalenNotifier::Completed( TInt aStatus ) |
|
605 { |
|
606 TRACE_ENTRY_POINT; |
|
607 |
|
608 if( aStatus == KErrNone ) |
|
609 { |
|
610 BroadcastNotification( ECalenNotifyEntryInstanceViewCreated ); |
|
611 } |
|
612 else |
|
613 { |
|
614 BroadcastNotification( ECalenNotifyEntryInstanceViewCreationFailed ); |
|
615 // The view creation has failed, hence the calendar |
|
616 // application needs to close gracefully |
|
617 // 1) Display error note. |
|
618 |
|
619 CErrorUI* errorUi; |
|
620 TRAPD(error,errorUi = CErrorUI::NewLC(); |
|
621 if(error!=KErrNone) |
|
622 { |
|
623 // do avoid warning |
|
624 } |
|
625 errorUi->ShowGlobalErrorNoteL( aStatus ); |
|
626 CleanupStack::PopAndDestroy( errorUi ); |
|
627 ); |
|
628 |
|
629 // Exit application |
|
630 iAvkonAppUi->Exit(); |
|
631 } |
|
632 |
|
633 TRACE_EXIT_POINT; |
|
634 } |
|
635 |
|
636 // ---------------------------------------------------------------------------- |
|
637 // CCalenNotifier::SystemTimeChangedL |
|
638 // Check if the system time changed since Calendar was last launched |
|
639 // If the system time did change, we need to notify the user that alarms may |
|
640 // have been missed. |
|
641 // (other items were commented in a header). |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 TInt CCalenNotifier::SystemTimeChangedL() |
|
645 { |
|
646 TRACE_ENTRY_POINT; |
|
647 |
|
648 TBool timeZoneChanged(EFalse); |
|
649 |
|
650 TPckgBuf<TMissedAlarmPubSubData> alarmPkgVarBuf; |
|
651 TInt errorVal = RProperty::Get( KAlarmServerPubSubCategory, |
|
652 KMissingAlarmPubSubKey, alarmPkgVarBuf); |
|
653 |
|
654 if(errorVal != KErrNone) |
|
655 { |
|
656 // Error in accessing the P&S key. |
|
657 // Alarm server defines this key when first time SystemTime Changes after bootup. |
|
658 // But Calendar may try to access this before it is defined by Alarm server. |
|
659 // So better not leaving based on errorVal |
|
660 return timeZoneChanged; |
|
661 } |
|
662 |
|
663 // read the latest timechange from agenda Server Time Stamp |
|
664 TTime timeOfChangeUtc = alarmPkgVarBuf().iTimeOfChangeUtc; |
|
665 //timeOfChangeUtc.RoundUpToNextMinute(); |
|
666 iTimeOfChangeUtcReal = I64REAL(timeOfChangeUtc.Int64()); |
|
667 |
|
668 // read the persistent time stamp from CalendarInternalCRKeys |
|
669 TReal previousTimeOfChange = 1.0; |
|
670 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
671 CleanupStack::PushL( repository ); |
|
672 errorVal = repository->Get( KCalendarPersistentTime, previousTimeOfChange ); |
|
673 User::LeaveIfError( errorVal ); |
|
674 |
|
675 TInt tzChangedOrAlarmsMissed(0); |
|
676 // compare the times. If the time set in the PubSub key by the Alarm Server is |
|
677 // greater than the last time we looked at it, we will show 1 of the 2 info notes |
|
678 // to the user. |
|
679 if (iTimeOfChangeUtcReal != previousTimeOfChange) |
|
680 { |
|
681 // Agenda Server set this value to tell what has happened since |
|
682 // the time change |
|
683 tzChangedOrAlarmsMissed = alarmPkgVarBuf().iValue; |
|
684 } |
|
685 CleanupStack::PopAndDestroy( repository ); |
|
686 |
|
687 TRACE_EXIT_POINT; |
|
688 return tzChangedOrAlarmsMissed; |
|
689 } |
|
690 |
|
691 // ---------------------------------------------------------------------------- |
|
692 // CCalenNotifier::UpdateSytemTimeChangeInfoL |
|
693 // Update cenrep with latest system time change info |
|
694 // (other items were commented in a header). |
|
695 // ---------------------------------------------------------------------------- |
|
696 // |
|
697 void CCalenNotifier::UpdateSytemTimeChangeInfoL() |
|
698 { |
|
699 TRACE_ENTRY_POINT; |
|
700 |
|
701 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
702 CleanupStack::PushL( repository ); |
|
703 |
|
704 // Update the persistent time stamp to the time stamp |
|
705 // indicated by the agenda server |
|
706 TInt errorVal = repository->Set( KCalendarPersistentTime, iTimeOfChangeUtcReal); |
|
707 User::LeaveIfError( errorVal ); |
|
708 CleanupStack::PopAndDestroy( repository ); |
|
709 |
|
710 TRACE_EXIT_POINT; |
|
711 } |
|
712 |
|
713 // ---------------------------------------------------------------------------- |
|
714 // CCalenNotifier::TNotificationHandler() |
|
715 // TNotificationHandler contructor |
347 // TNotificationHandler contructor |
716 // ---------------------------------------------------------------------------- |
348 // ---------------------------------------------------------------------------- |
717 CCalenNotifier::TNotificationHandler::TNotificationHandler() : |
349 CalenNotifier::TNotificationHandler::TNotificationHandler() : |
718 iHashSet(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
350 iHashSet(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
719 { |
351 { |
720 TRACE_ENTRY_POINT; |
352 TRACE_ENTRY_POINT; |
721 TRACE_EXIT_POINT; |
353 TRACE_EXIT_POINT; |
722 } |
354 } |
723 |
355 |
724 // ---------------------------------------------------------------------------- |
|
725 // CCalenNotifier::CalendarInfoChangeNotificationL() |
|
726 // Handle calendar file change notifications |
|
727 // ---------------------------------------------------------------------------- |
|
728 void CCalenNotifier::CalendarInfoChangeNotificationL( |
|
729 RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries) |
|
730 { |
|
731 TRACE_ENTRY_POINT; |
|
732 |
|
733 // get the file change count |
|
734 TInt calenInfoChangeCount = aCalendarInfoChangeEntries.Count(); |
|
735 |
|
736 for(TInt index = 0;index < calenInfoChangeCount;index++) |
|
737 { |
|
738 //get the context and set the calendar filename which triggered the |
|
739 // notification |
|
740 MCalenContext &context = iController.Services().Context(); |
|
741 context.SetCalendarFileNameL( |
|
742 aCalendarInfoChangeEntries[index]->FileNameL()); |
|
743 |
|
744 MCalFileChangeObserver::TChangeType changeType = |
|
745 aCalendarInfoChangeEntries[index]->ChangeType(); |
|
746 switch(changeType) |
|
747 { |
|
748 case MCalFileChangeObserver::ECalendarFileCreated: |
|
749 case MCalFileChangeObserver::ECalendarInfoCreated: |
|
750 { |
|
751 BroadcastNotification(ECalenNotifyCalendarInfoCreated); |
|
752 } |
|
753 break; |
|
754 case MCalFileChangeObserver::ECalendarFileDeleted: |
|
755 { |
|
756 BroadcastNotification(ECalenNotifyCalendarFileDeleted); |
|
757 } |
|
758 break; |
|
759 case MCalFileChangeObserver::ECalendarInfoUpdated: |
|
760 case MCalFileChangeObserver::ECalendarInfoDeleted: |
|
761 { |
|
762 TFileName calFileName = aCalendarInfoChangeEntries[index]->FileNameL(); |
|
763 CCalSession& session = iGlobalData->CalSessionL( calFileName ); |
|
764 |
|
765 CCalCalendarInfo* calendarInfo = session.CalendarInfoL(); |
|
766 CleanupStack::PushL(calendarInfo); |
|
767 |
|
768 TBuf8<KBuffLength> keyBuff; |
|
769 keyBuff.AppendNum(EMarkAsDelete); |
|
770 |
|
771 TBool markAsdelete; |
|
772 TPckgC<TBool> pkgMarkAsDelete(markAsdelete); |
|
773 TRAPD(err,pkgMarkAsDelete.Set(calendarInfo->PropertyValueL(keyBuff))); |
|
774 markAsdelete = pkgMarkAsDelete(); |
|
775 |
|
776 CleanupStack::PopAndDestroy(calendarInfo); |
|
777 |
|
778 if (err == KErrNone && markAsdelete) |
|
779 { |
|
780 //BroadcastNotification(ECalenNotifyCloseDialog); |
|
781 BroadcastNotification(ECalenNotifyDeleteInstanceView); |
|
782 BroadcastNotification(ECalenNotifyCalendarFileDeleted); |
|
783 iFilnameDeleted = aCalendarInfoChangeEntries[index]->FileNameL().AllocL(); |
|
784 iAsyncCallback->CallBack(); |
|
785 } |
|
786 else |
|
787 { |
|
788 BroadcastNotification(ECalenNotifyCalendarInfoUpdated); |
|
789 } |
|
790 } |
|
791 break; |
|
792 default: |
|
793 break; |
|
794 } |
|
795 } |
|
796 |
|
797 TRACE_EXIT_POINT; |
|
798 } |
|
799 |
|
800 // ---------------------------------------------------------------------------- |
|
801 // CCalenNotifier::AsyncRemoveCalendarL(TAny* aThisPtr) |
|
802 // ---------------------------------------------------------------------------- |
|
803 TInt CCalenNotifier::AsyncRemoveCalendarL(TAny* aThisPtr) |
|
804 { |
|
805 TRACE_ENTRY_POINT |
|
806 static_cast<CCalenNotifier*>(aThisPtr)->AsyncRemoveCalendarL(); |
|
807 TRACE_EXIT_POINT |
|
808 return 0; |
|
809 } |
|
810 |
|
811 // ---------------------------------------------------------------------------- |
|
812 // CCalenNotifier::AsyncRemoveCalendarL() |
|
813 // |
|
814 void CCalenNotifier::AsyncRemoveCalendarL() |
|
815 { |
|
816 TRACE_ENTRY_POINT |
|
817 iGlobalData->RemoveCalendarL(iFilnameDeleted->Des()); |
|
818 delete iFilnameDeleted; |
|
819 iFilnameDeleted = NULL; |
|
820 TRACE_EXIT_POINT |
|
821 } |
|
822 // End of file |
356 // End of file |