30 #include "alarmremconeventshandler.h" |
30 #include "alarmremconeventshandler.h" |
31 #ifdef RD_ALMALERT__SENSOR_SUPPORT |
31 #ifdef RD_ALMALERT__SENSOR_SUPPORT |
32 #include "alarmcontextfwsupport.h" |
32 #include "alarmcontextfwsupport.h" |
33 #endif // RD_ALMALERT__SENSOR_SUPPORT |
33 #endif // RD_ALMALERT__SENSOR_SUPPORT |
34 |
34 |
35 #include <almconst.h> |
35 #include "alarmalertwrapper.h" |
|
36 |
|
37 // #include <almconst.h> |
36 #include <eikenv.h> |
38 #include <eikenv.h> |
37 #include <AknCapServer.h> |
39 #include <AknCapServer.h> |
38 #include <e32property.h> |
40 #include <e32property.h> |
39 #include <centralrepository.h> |
41 #include <centralrepository.h> |
40 #include <MProfileEngine.h> |
42 #include <MProfileEngine.h> |
41 #include <MProfile.h> |
43 #include <MProfile.h> |
42 #include <MProfileTones.h> |
44 #include <MProfileTones.h> |
43 #include <ProfileEngineDomainConstants.h> |
45 #include <ProfileEngineDomainConstants.h> |
44 #include <sbdefs.h> |
46 #include <sbdefs.h> |
45 #include <coreapplicationuisdomainpskeys.h> |
47 #include <coreapplicationuisdomainpskeys.h> |
46 #include <clockdomaincrkeys.h> |
48 // #include <clockdomaincrkeys.h> |
47 #include <CalendarInternalCRKeys.h> |
49 // #include <CalendarInternalCRKeys.h> |
48 #include <wakeupalarm.h> |
50 #include <wakeupalarm.h> |
49 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms |
51 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms |
50 #include <AknUtils.h> |
52 #include <AknUtils.h> |
51 |
53 |
52 #ifndef SYMBIAN_CALENDAR_V2 |
54 #ifndef SYMBIAN_CALENDAR_V2 |
53 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled |
55 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled |
54 #endif // SYMBIAN_CALENDAR_V2 |
56 #endif // SYMBIAN_CALENDAR_V2 |
55 #include <calsession.h> |
57 #include <calsession.h> |
56 #include <calentryview.h> |
58 #include <calentryview.h> |
57 #include <calenlauncher.h> // for launching calendar entry view |
59 // #include <calenlauncher.h> // for launching calendar entry view |
58 |
60 |
59 |
61 |
60 |
62 |
61 // CONSTANTS AND MACROS |
63 // CONSTANTS AND MACROS |
62 const TInt KAlmAlertMinSnooze( 100 ); |
64 const TInt KAlmAlertMinSnooze( 100 ); |
72 const TUint KInactivityResetInterval( 1000000 ); // 1.0 s |
74 const TUint KInactivityResetInterval( 1000000 ); // 1.0 s |
73 |
75 |
74 const TInt KMaxProfileVolume( 10 ); |
76 const TInt KMaxProfileVolume( 10 ); |
75 const TInt KVolumeRampPeriod( 3000000 ); // 3 seconds |
77 const TInt KVolumeRampPeriod( 3000000 ); // 3 seconds |
76 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" ); |
78 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" ); |
|
79 const TUid KCRUidCalendar = {0x101F874B}; |
|
80 //const TUint32 KCalendarSoundFile = 0x00000004; |
|
81 const TUint32 KCalendarDefaultSoundFile = 0x00000005; |
|
82 const TUint32 KCalendarSnoozeTime = 0x00000007; |
|
83 const TUid KCRUidClockApp = {0x101F874D}; |
|
84 //const TUint32 KClockAppSoundFile = 0x00000000; |
|
85 const TUint32 KClockAppDefaultSoundFile = 0x00000001; |
|
86 const TUint32 KClockAppSnoozeTime = 0x00000002; |
|
87 const TUid KAlarmClockOne = { 0x101F793A }; |
|
88 |
|
89 const TUid KCRUidProfileEngine = {0x101F8798}; |
|
90 //const TUint32 KProEngActiveReminderTone = 0x7E00001C; |
|
91 //const TUint32 KProEngActiveClockAlarmTone = 0x7E00001D; |
|
92 //const TUint32 KProEngActiveAlertVibra = 0x7E00001E; |
|
93 const TUint32 KProEngActiveRingingType = 0x7E000002; |
|
94 const TUint32 KProEngActiveRingingVolume = 0x7E000008; |
77 |
95 |
78 |
96 |
79 // ========================================================== |
97 // ========================================================== |
80 // ================= MEMBER FUNCTIONS ======================= |
98 // ================= MEMBER FUNCTIONS ======================= |
81 |
99 |
106 User::LeaveIfError( iApaSession.Connect() ); |
124 User::LeaveIfError( iApaSession.Connect() ); |
107 |
125 |
108 iAlarmInfo = new( ELeave )CAlmAlarmInfo( this ); |
126 iAlarmInfo = new( ELeave )CAlmAlarmInfo( this ); |
109 |
127 |
110 // we can still work without profile engine |
128 // we can still work without profile engine |
111 PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); ) |
129 // PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); ) |
112 |
130 |
113 iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL(); |
131 // iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL(); |
114 iNotifierDialogController->SetNoteObserver( iAlarmControl ); |
132 // iNotifierDialogController->SetNoteObserver( iAlarmControl ); |
|
133 iAlarmAlert = new AlarmAlert(iAlarmControl); |
115 |
134 |
116 // create timers |
135 // create timers |
117 iShutdownTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
136 iShutdownTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
118 iAutoSnoozeTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
137 iAutoSnoozeTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
119 iKeyBlockTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
138 iKeyBlockTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
267 #if defined( RD_ALMALERT__SENSOR_SUPPORT ) |
291 #if defined( RD_ALMALERT__SENSOR_SUPPORT ) |
268 // notify the result through the context framework |
292 // notify the result through the context framework |
269 // only set the context if the player was really active |
293 // only set the context if the player was really active |
270 if( iAlarmPlayer && iCFSupport ) |
294 if( iAlarmPlayer && iCFSupport ) |
271 { |
295 { |
272 PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmSilenced ); ) |
296 // PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmSilenced ); ) |
273 } |
297 } |
274 #endif // RD_ALMALERT__SENSOR_SUPPORT |
298 #endif // RD_ALMALERT__SENSOR_SUPPORT |
275 delete iAlarmPlayer; |
299 delete iAlarmPlayer; |
276 iAlarmPlayer = NULL; |
300 iAlarmPlayer = NULL; |
277 SetBackLight( EFalse ); |
301 SetBackLight( EFalse ); |
407 // ----------------------------------------------------------------------------- |
431 // ----------------------------------------------------------------------------- |
408 // Read alarm sound filenames from central repository. |
432 // Read alarm sound filenames from central repository. |
409 // ----------------------------------------------------------------------------- |
433 // ----------------------------------------------------------------------------- |
410 // |
434 // |
411 void CAlarmUtils::GetAlarmSoundFilenames() |
435 void CAlarmUtils::GetAlarmSoundFilenames() |
412 { |
436 { |
413 TRACE_ENTRY_POINT; |
437 TRACE_ENTRY_POINT; |
414 CRepository* repository = NULL; |
438 CRepository* profileRepository = NULL; |
415 |
439 CRepository* repository = NULL; |
416 if( IsClockAlarm() ) |
440 |
417 { |
441 if( IsClockAlarm() ) |
418 PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); ) |
442 { |
419 |
443 PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); ) |
420 if( repository ) |
444 PIM_TRAPD_ASSERT( profileRepository = CRepository::NewL( |
421 { |
445 KCRUidProfileEngine ); ) |
422 PIM_ASSERT( repository->Get( KClockAppSoundFile, iAlarmData.iAlarmTone ); ) |
446 |
423 PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); ) |
447 if( repository ) |
424 } |
448 { |
425 } |
449 PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, |
426 else |
450 iAlarmData.iDefaultAlarmTone ); ) |
427 { |
451 } |
428 PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); ) |
452 if( profileRepository ) |
429 |
453 { |
430 if( repository ) |
454 // TODO: Need to use KProEngActiveClockAlarmTone once its released |
431 { |
455 //PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone , iAlarmData.iAlarmTone); ) |
432 PIM_ASSERT( repository->Get( KCalendarSoundFile, iAlarmData.iAlarmTone ); ) |
456 PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, |
433 PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); ) |
457 iAlarmData.iAlarmTone ); ) |
434 } |
458 } |
435 } |
459 } |
436 delete repository; |
460 else |
437 TRACE_EXIT_POINT; |
461 { |
438 } |
462 PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); ) |
|
463 PIM_TRAPD_ASSERT( profileRepository = CRepository::NewL( KCRUidProfileEngine ); ) |
|
464 |
|
465 if( repository ) |
|
466 { |
|
467 PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, |
|
468 iAlarmData.iDefaultAlarmTone ); ) |
|
469 } |
|
470 if( profileRepository ) |
|
471 { |
|
472 // TODO: Need to use KProEngActiveReminderTone once its released |
|
473 //PIM_ASSERT( profileRepository->Get( KProEngActiveReminderTone, iAlarmData.iAlarmTone ); ) |
|
474 PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, |
|
475 iAlarmData.iAlarmTone ); ) |
|
476 } |
|
477 } |
|
478 delete repository; |
|
479 delete profileRepository; |
|
480 TRACE_EXIT_POINT; |
|
481 } |
439 |
482 |
440 // ----------------------------------------------------------------------------- |
483 // ----------------------------------------------------------------------------- |
441 // Check if the alarm sound file is a KRngMimeType file. |
484 // Check if the alarm sound file is a KRngMimeType file. |
442 // ----------------------------------------------------------------------------- |
485 // ----------------------------------------------------------------------------- |
443 // |
486 // |
482 iAlarmData.iRepeatValue = KMdaAudioToneRepeatForever; // KMdaRepeatForever |
525 iAlarmData.iRepeatValue = KMdaAudioToneRepeatForever; // KMdaRepeatForever |
483 iAlarmData.iVolume = KMaxProfileVolume; // clock alarms always ramp to maximum volume |
526 iAlarmData.iVolume = KMaxProfileVolume; // clock alarms always ramp to maximum volume |
484 iAlarmData.iVolumeRampTime = iAlarmData.iVolume * KVolumeRampPeriod; // volume ramp only for clock alarms |
527 iAlarmData.iVolumeRampTime = iAlarmData.iVolume * KVolumeRampPeriod; // volume ramp only for clock alarms |
485 |
528 |
486 if( !IsClockAlarm() ) |
529 if( !IsClockAlarm() ) |
487 { |
530 { |
488 if( iProfileEng ) |
531 CRepository* repository = NULL; |
489 { |
532 PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidProfileEngine ); ) |
490 MProfile* profile = NULL; |
533 |
491 PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); ) |
534 TInt ringType; |
492 |
535 repository->Get( KProEngActiveRingingType , ringType); |
493 if( profile ) |
536 iAlarmData.iRingType = static_cast< TProfileRingingType >( ringType ); |
494 { |
537 |
495 const TProfileToneSettings& setting = profile->ProfileTones().ToneSettings(); |
538 TInt ringingVolume; |
496 iAlarmData.iRingType = setting.iRingingType; |
539 repository->Get( KProEngActiveRingingVolume , ringingVolume); |
497 |
540 iAlarmData.iVolume = ringingVolume; |
498 // calendar alarms: if profile is "silent" -> set volume to zero |
541 |
499 iAlarmData.iVolume = (iAlarmData.iRingType == EProfileRingingTypeSilent ? 0 : setting.iRingingVolume); |
542 iAlarmData.iVolumeRampTime = 0; |
500 |
543 } |
501 profile->Release(); |
|
502 } |
|
503 } |
|
504 |
|
505 if( iAlarmData.iRingType == EProfileRingingTypeRingingOnce ) |
|
506 { |
|
507 iAlarmData.iRepeatValue = 1; |
|
508 } |
|
509 iAlarmData.iVolumeRampTime = 0; |
|
510 } |
|
511 TRACE_EXIT_POINT; |
544 TRACE_EXIT_POINT; |
512 } |
545 } |
513 |
546 |
514 // ----------------------------------------------------------------------------- |
547 // ----------------------------------------------------------------------------- |
515 // |
548 // |
726 |
759 |
727 // ----------------------------------------------------------------------------- |
760 // ----------------------------------------------------------------------------- |
728 // |
761 // |
729 // ----------------------------------------------------------------------------- |
762 // ----------------------------------------------------------------------------- |
730 // |
763 // |
731 CNotifierDialogController* CAlarmUtils::NotifierDialogController() |
764 AlarmAlert* CAlarmUtils::NotifierDialogController() |
732 { |
765 { |
733 TRACE_ENTRY_POINT; |
766 TRACE_ENTRY_POINT; |
734 TRACE_EXIT_POINT; |
767 TRACE_EXIT_POINT; |
735 return iNotifierDialogController; |
768 // return iNotifierDialogController; |
|
769 return iAlarmAlert; |
736 } |
770 } |
737 |
771 |
738 // --------------------------------------------------------- |
772 // --------------------------------------------------------- |
739 // Checks if the alarm server has more expired alarms ready |
773 // Checks if the alarm server has more expired alarms ready |
740 // to be shown. |
774 // to be shown. |
817 // notify the result through the context framework |
851 // notify the result through the context framework |
818 if( iCFSupport ) |
852 if( iCFSupport ) |
819 { |
853 { |
820 if(!iAlarmControl->IsStopFromContext() && IsCalendarAlarm()) |
854 if(!iAlarmControl->IsStopFromContext() && IsCalendarAlarm()) |
821 { |
855 { |
822 PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmStoppedAndExit );) |
856 // PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmStoppedAndExit );) |
823 iAlarmControl->SetStopFromContext(EFalse); |
857 // iAlarmControl->SetStopFromContext(EFalse); |
824 } |
858 } |
825 else |
859 else |
826 { |
860 { |
827 PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmStopped );) |
861 // PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmStopped );) |
828 iAlarmControl->SetStopFromContext(EFalse); |
862 // iAlarmControl->SetStopFromContext(EFalse); |
829 } |
863 } |
830 } |
864 } |
831 #endif // RD_ALMALERT__SENSOR_SUPPORT |
865 #endif // RD_ALMALERT__SENSOR_SUPPORT |
832 TRACE_EXIT_POINT; |
866 TRACE_EXIT_POINT; |
833 } |
867 } |
1244 |
1278 |
1245 // --------------------------------------------------------- |
1279 // --------------------------------------------------------- |
1246 // Callback function for the auto snooze timer |
1280 // Callback function for the auto snooze timer |
1247 // --------------------------------------------------------- |
1281 // --------------------------------------------------------- |
1248 // |
1282 // |
1249 TInt CAlarmUtils::SnoozeInfoCallBack(TAny* aPtr) |
1283 TInt CAlarmUtils::SnoozeInfoCallBack(TAny* /*aPtr*/) |
1250 { |
1284 { |
1251 TRACE_ENTRY_POINT; |
1285 TRACE_ENTRY_POINT; |
1252 PIM_TRAPD_ASSERT( static_cast<CAlmAlarmControl*>( aPtr )->ShowSnoozeInfoNoteL(); ) |
1286 // PIM_TRAPD_ASSERT( static_cast<CAlmAlarmControl*>( aPtr )->ShowSnoozeInfoNoteL(); ) |
1253 TRACE_EXIT_POINT; |
1287 TRACE_EXIT_POINT; |
1254 return 0; |
1288 return 0; |
1255 } |
1289 } |
1256 |
1290 |
1257 // --------------------------------------------------------- |
1291 // --------------------------------------------------------- |
1612 void CAlarmUtils::StartCalendarL() |
1646 void CAlarmUtils::StartCalendarL() |
1613 { |
1647 { |
1614 TRACE_ENTRY_POINT; |
1648 TRACE_ENTRY_POINT; |
1615 |
1649 |
1616 iCalendarAlarmViewer = ETrue; |
1650 iCalendarAlarmViewer = ETrue; |
1617 |
1651 /* |
1618 CalenLauncher::ViewEntryL( iAlarmData.iLocalUid, |
1652 CalenLauncher::ViewEntryL( iAlarmData.iLocalUid, |
1619 iAlarmData.iInstanceTime, iAlarmData.iCalFileName, |
1653 iAlarmData.iInstanceTime, iAlarmData.iCalFileName, |
1620 CanSnooze() ? CalenLauncher::EAlarmViewer : |
1654 CanSnooze() ? CalenLauncher::EAlarmViewer : |
1621 CalenLauncher::EAlarmViewerNoSnooze ); |
1655 CalenLauncher::EAlarmViewerNoSnooze ); |
|
1656 */ |
1622 TRACE_EXIT_POINT; |
1657 TRACE_EXIT_POINT; |
1623 } |
1658 } |
1624 |
1659 |
1625 // --------------------------------------------------------- |
1660 // --------------------------------------------------------- |
1626 // Check if the security lock is active. |
1661 // Check if the security lock is active. |