diff -r 5aadd1120515 -r b57382753122 alarmui/src/alarmutils.cpp --- a/alarmui/src/alarmutils.cpp Fri Oct 15 12:10:36 2010 +0530 +++ b/alarmui/src/alarmutils.cpp Wed Nov 03 17:12:22 2010 +0530 @@ -15,10 +15,14 @@ * */ -// User includes. + + +// INCLUDE FILES #include "alarmutils.h" + #include "AlmAlertVariant.hrh" #include "pim_trace.h" + #include "AlmAlarmPlayer.h" #include "AlmAlarmControl.h" #include "AlmAlarmInfo.h" @@ -27,10 +31,9 @@ #ifdef RD_ALMALERT__SENSOR_SUPPORT #include "alarmcontextfwsupport.h" #endif // RD_ALMALERT__SENSOR_SUPPORT -#include "alarmalertwrapper.h" -// System includes. -// #include +#include +#include #include #include #include @@ -41,41 +44,41 @@ #include #include #include +#include +#include #include #include // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms #include +#include +#include + + #ifndef SYMBIAN_CALENDAR_V2 #include // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled #endif // SYMBIAN_CALENDAR_V2 #include #include -#include -#include +#include // for launching calendar entry view + -// Constants + +// CONSTANTS AND MACROS const TInt KAlmAlertMinSnooze( 100 ); const TInt KAlmAlertMaxSnooze( 104 ); -const TInt KDefaultSnoozeTime( 5 ); -const TUint KAlarmAutoHide( 60000000 ); -const TUint KAlarmAutoHideCalendar( 30000000 ); -const TUint KKeyBlockTime( 500000 ); -const TUint KShutdownTime( 1500000 ); -const TUint KAlarmDelayTime( 1000000 ); -const TUint KInactivityResetInterval( 1000000 ); + +const TInt KDefaultSnoozeTime( 5 ); // 5 minutes + +const TUint KAlarmAutoHide( 60000000 ); // 60 s +const TUint KAlarmAutoHideCalendar( 30000000 ); // 30 s +const TUint KKeyBlockTime( 500000 ); // 0.5 s +const TUint KShutdownTime( 1500000 ); // 1.5 s +const TUint KAlarmDelayTime( 1000000 ); // 1.0 s +const TUint KInactivityResetInterval( 1000000 ); // 1.0 s + const TInt KMaxProfileVolume( 10 ); -const TInt KNoVolume(0); -const TInt KVolumeRampPeriod( 3000000 ); -const TUid KAlarmClockOne = { 0x101F793A }; -const TUid KCRUidProfileEngine = {0x101F8798}; -//const TUint32 KProEngActiveReminderTone = 0x7E00001C; -const TUint32 KProEngActiveClockAlarmTone = 0x7E00001D; -//const TUint32 KProEngActiveAlertVibra = 0x7E00001E; -const TUint32 KProEngSilenceMode = {0x80000202}; -const TUint32 KProEngActiveRingingType = {0x7E000002}; -const TUint32 KProEngActiveRingingVolume = {0x7E000008}; +const TInt KVolumeRampPeriod( 3000000 ); // 3 seconds +_LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" ); -// Literals -_LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" ); // ========================================================== // ================= MEMBER FUNCTIONS ======================= @@ -109,11 +112,10 @@ iAlarmInfo = new( ELeave )CAlmAlarmInfo( this ); // we can still work without profile engine - // PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); ) + PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); ) - // iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL(); - // iNotifierDialogController->SetNoteObserver( iAlarmControl ); - iAlarmAlert = new AlarmAlert(iAlarmControl); + iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL(); + iNotifierDialogController->SetNoteObserver( iAlarmControl ); // create timers iShutdownTimer = CPeriodic::NewL( CActive::EPriorityStandard ); @@ -155,14 +157,9 @@ CAlarmUtils::~CAlarmUtils() { TRACE_ENTRY_POINT; - /*if( iNotifierDialogController ) + if( iNotifierDialogController ) { iNotifierDialogController->SetNoteObserver( NULL ); - }*/ - if( iAlarmAlert ) - { - delete iAlarmAlert; - iAlarmAlert = NULL; } if( iShutdownTimer ) @@ -363,7 +360,7 @@ TRACE_ENTRY_POINT; TBool isSilent( EFalse ); - /*if( iProfileEng ) + if( iProfileEng ) { MProfile* profile = NULL; PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); ) @@ -378,7 +375,7 @@ profile->Release(); } } - TRACE_EXIT_POINT;*/ + TRACE_EXIT_POINT; return isSilent; } @@ -416,51 +413,33 @@ // ----------------------------------------------------------------------------- // void CAlarmUtils::GetAlarmSoundFilenames() -{ - TRACE_ENTRY_POINT; - CRepository* profileRepository = NULL; - CRepository* repository = NULL; + { + TRACE_ENTRY_POINT; + CRepository* repository = NULL; - if( IsClockAlarm() ) - { - PIM_TRAPD_ASSERT( repository = CRepository::NewL( TUid::Uid(KCRUidClockApp) ); ) - PIM_TRAPD_ASSERT( profileRepository = CRepository::NewL( - KCRUidProfileEngine ); ) + if( IsClockAlarm() ) + { + PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); ) - if( repository ) - { - PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, - iAlarmData.iDefaultAlarmTone ); ) - } - if( profileRepository ) - { - // TODO: Need to use KProEngActiveClockAlarmTone once its released - //PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone , iAlarmData.iAlarmTone); ) - PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, - iAlarmData.iAlarmTone ); ) - } - } - else - { - PIM_TRAPD_ASSERT( repository = - CRepository::NewL( TUid::Uid(KCRUidCalendar) ); ) - PIM_TRAPD_ASSERT( profileRepository = - CRepository::NewL( KCRUidProfileEngine ); ) + if( repository ) + { + PIM_ASSERT( repository->Get( KClockAppSoundFile, iAlarmData.iAlarmTone ); ) + PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); ) + } + } + else + { + PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); ) - if( repository ) - { - PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, - iAlarmData.iDefaultAlarmTone ); ) - } - if( profileRepository ) - { - PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone, iAlarmData.iAlarmTone ); ) - } - } - delete repository; - delete profileRepository; - TRACE_EXIT_POINT; -} + if( repository ) + { + PIM_ASSERT( repository->Get( KCalendarSoundFile, iAlarmData.iAlarmTone ); ) + PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); ) + } + } + delete repository; + TRACE_EXIT_POINT; + } // ----------------------------------------------------------------------------- // Check if the alarm sound file is a KRngMimeType file. @@ -509,38 +488,30 @@ iAlarmData.iVolumeRampTime = iAlarmData.iVolume * KVolumeRampPeriod; // volume ramp only for clock alarms if( !IsClockAlarm() ) - { - CRepository* repository = NULL; - PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidProfileEngine ); ) - - TInt ringType; - repository->Get( KProEngActiveRingingType , ringType); - iAlarmData.iRingType = static_cast< TProfileRingingType >( ringType ); - - TBool silentMode; - TInt ringingVolume; - repository->Get( KProEngSilenceMode, silentMode); - if(silentMode) - { - ringingVolume = KNoVolume; - } - else - { - // It seems the wrong key has been associated with calendar alarm tone - // settings. It would be changed once it's rectified by profile team. - repository->Get( KProEngActiveRingingVolume , ringingVolume ); - } - - iAlarmData.iVolume = ringingVolume; - - iAlarmData.iVolumeRampTime = 0; - } else { - TInt volumeOn = iAlarmData.iAlarm.ClientData2(); - if (!volumeOn) { - iAlarmData.iRingType = EProfileRingingTypeSilent; - iAlarmData.iVolume = KNoVolume; - } - } + { + if( iProfileEng ) + { + MProfile* profile = NULL; + PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); ) + + if( profile ) + { + const TProfileToneSettings& setting = profile->ProfileTones().ToneSettings(); + iAlarmData.iRingType = setting.iRingingType; + + // calendar alarms: if profile is "silent" -> set volume to zero + iAlarmData.iVolume = (iAlarmData.iRingType == EProfileRingingTypeSilent ? 0 : setting.iRingingVolume); + + profile->Release(); + } + } + + if( iAlarmData.iRingType == EProfileRingingTypeRingingOnce ) + { + iAlarmData.iRepeatValue = 1; + } + iAlarmData.iVolumeRampTime = 0; + } TRACE_EXIT_POINT; } @@ -654,7 +625,7 @@ case EAlarmTypeClock: { CRepository* repository = NULL; - PIM_TRAPD_ASSERT( repository = CRepository::NewL( TUid::Uid(KCRUidClockApp) ); ) + PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); ) if( repository ) { @@ -667,8 +638,7 @@ case EAlarmTypeCalendar: { CRepository* repository = NULL; - PIM_TRAPD_ASSERT( repository = - CRepository::NewL( TUid::Uid(KCRUidCalendar) ); ) + PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); ) if( repository ) { @@ -762,12 +732,11 @@ // // ----------------------------------------------------------------------------- // -AlarmAlert* CAlarmUtils::NotifierDialogController() +CNotifierDialogController* CAlarmUtils::NotifierDialogController() { TRACE_ENTRY_POINT; TRACE_EXIT_POINT; - // return iNotifierDialogController; - return iAlarmAlert; + return iNotifierDialogController; } // --------------------------------------------------------- @@ -995,12 +964,20 @@ void CAlarmUtils::DeviceShutdown() { TRACE_ENTRY_POINT; - iShutdownTimer->Cancel(); - if( StarterConnect() ) - { - iStarter.Shutdown(); - iStarter.Close(); - } + + // charging state added for the err EMDN-835CW2. + TInt chargingState; + RProperty::Get( KPSUidHWRMPowerState, KHWRMChargingStatus , chargingState ); + + if( IsDeviceInAlarmState() && ( chargingState == EChargingStatusNotConnected ) ) + { + iShutdownTimer->Cancel(); + if( StarterConnect() ) + { + iStarter.Shutdown(); + iStarter.Close(); + } + } TRACE_EXIT_POINT; } @@ -1148,7 +1125,7 @@ void CAlarmUtils::StartAccessoryObserver() { TRACE_ENTRY_POINT; - // PIM_TRAPD_ASSERT( iRemConHandler->StartL(); ) + PIM_TRAPD_ASSERT( iRemConHandler->StartL(); ) TRACE_EXIT_POINT; } @@ -1281,10 +1258,10 @@ // Callback function for the auto snooze timer // --------------------------------------------------------- // -TInt CAlarmUtils::SnoozeInfoCallBack(TAny* /*aPtr*/) +TInt CAlarmUtils::SnoozeInfoCallBack(TAny* aPtr) { TRACE_ENTRY_POINT; - // PIM_TRAPD_ASSERT( static_cast( aPtr )->ShowSnoozeInfoNoteL(); ) + PIM_TRAPD_ASSERT( static_cast( aPtr )->ShowSnoozeInfoNoteL(); ) TRACE_EXIT_POINT; return 0; } @@ -1649,12 +1626,11 @@ TRACE_ENTRY_POINT; iCalendarAlarmViewer = ETrue; - /* + CalenLauncher::ViewEntryL( iAlarmData.iLocalUid, iAlarmData.iInstanceTime, iAlarmData.iCalFileName, CanSnooze() ? CalenLauncher::EAlarmViewer : CalenLauncher::EAlarmViewerNoSnooze ); - */ TRACE_EXIT_POINT; } @@ -1666,10 +1642,13 @@ { TRACE_ENTRY_POINT; TInt keyVal( 0 ); + TInt currentBootupQueriesStatus(0); TBool retVal( EFalse ); PIM_ASSERT( RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, keyVal ); ) - if( keyVal > EAutolockOff ) + PIM_ASSERT(RProperty::Get(KPSUidStartup,KPSStartupUiPhase,currentBootupQueriesStatus ); ) + + if( (keyVal > EAutolockOff) || (currentBootupQueriesStatus != EStartupUiPhaseAllDone ) ) { retVal = ETrue; } @@ -1695,10 +1674,102 @@ return iCalendarAlarmViewer; } -SAlarmInfo* CAlarmUtils::GetAlarmInfo() +// --------------------------------------------------------- +// Silence the notifying alarm +// --------------------------------------------------------- +// +void CAlarmUtils::DoSilence() { - return iAlarmInfo->GetAlarmInfo(iAlarmData.iAlarm, - iAlarmData.iAlarmType); + TRACE_ENTRY_POINT; + + // silence only if snoozing is possible + // this way user must hear the last "call" + if( CanSnooze() ) + { + TBool silenced( EFalse ); + if( IsCalendarAlarm() ) + { + // do silencing only if alarm is being played and silencing possible + if( iAlarmPlayer && !( IsRingingTypeSilent() || IsOffTone() ) ) + { + silenced = ETrue; + delete iAlarmPlayer; + iAlarmPlayer = NULL; + SetBackLight( EFalse ); + // calendar alarm needs extra handling due to having stop - silence + //simulate right softkey pressing + RWsSession wsSession=CCoeEnv::Static()->WsSession(); + TKeyEvent keyEvent; + keyEvent.iCode = EKeyCBA2; + keyEvent.iScanCode = EStdKeyDevice1; + keyEvent.iModifiers = 0; + keyEvent.iRepeats = 0; + wsSession.SimulateKeyEvent( keyEvent ); + wsSession.Flush(); + } + } + // clockalarm + else + { + silenced = ETrue; + delete iAlarmPlayer; + iAlarmPlayer = NULL; + SetBackLight( EFalse ); + StartAutoSnoozeTimer(); + } + + #if defined( RD_ALMALERT__SENSOR_SUPPORT ) + // notify the result through the context framework + if( iCFSupport && silenced ) + { + PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmSilenced ); ) + } + #endif // RD_ALMALERT__SENSOR_SUPPORT + } + TRACE_EXIT_POINT; } +// --------------------------------------------------------- +// Check if the alarm is duplicate calendar alarm +// Rest of the details in header file +// --------------------------------------------------------- +// +TBool CAlarmUtils::CheckForDuplicateAlarm() + { + TRACE_ENTRY_POINT; + TBool ret = EFalse; + if(IsCalendarAlarm()) + { + TTime currAlarmOrigExpTime = iAlarmData.iAlarm.OriginalExpiryTime(); + + if(currAlarmOrigExpTime == iPrevAlarmOriginalExpiryTime && iPrevLocalUid == iAlarmData.iLocalUid + && !iPrevCalFileName.CompareF(iAlarmData.iCalFileName) ) + { + TInt& count = iAlarmData.iAlarm.ClientData1(); + if( !(count >= KAlmAlertMinSnooze && + count <= KAlmAlertMaxSnooze )) + { + ret = ETrue; + } + } + } + TRACE_EXIT_POINT; + return ret; + } + + +// --------------------------------------------------------- +// Store details of current alarm for future comparison when next calendar alarm comes. +// Rest of the details in header file +// --------------------------------------------------------- +// +void CAlarmUtils::StoreCurrentCalendarAlarmData() + { + TRACE_ENTRY_POINT; + iPrevLocalUid = iAlarmData.iLocalUid; + iPrevCalFileName = iAlarmData.iCalFileName; + iPrevAlarmOriginalExpiryTime = iAlarmData.iAlarm.OriginalExpiryTime(); + TRACE_EXIT_POINT; + } + // End of File