alarmui/src/alarmutils.cpp
changeset 89 b57382753122
parent 83 5aadd1120515
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
    13 *
    13 *
    14 * Description:   
    14 * Description:   
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // User includes.
    18 
       
    19 
       
    20 // INCLUDE FILES
    19 #include "alarmutils.h"
    21 #include "alarmutils.h"
       
    22 
    20 #include "AlmAlertVariant.hrh"
    23 #include "AlmAlertVariant.hrh"
    21 #include "pim_trace.h"
    24 #include "pim_trace.h"
       
    25 
    22 #include "AlmAlarmPlayer.h"
    26 #include "AlmAlarmPlayer.h"
    23 #include "AlmAlarmControl.h"
    27 #include "AlmAlarmControl.h"
    24 #include "AlmAlarmInfo.h"
    28 #include "AlmAlarmInfo.h"
    25 #include "AlarmService.h"
    29 #include "AlarmService.h"
    26 #include "alarmremconeventshandler.h"
    30 #include "alarmremconeventshandler.h"
    27 #ifdef RD_ALMALERT__SENSOR_SUPPORT
    31 #ifdef RD_ALMALERT__SENSOR_SUPPORT
    28 #include "alarmcontextfwsupport.h"
    32 #include "alarmcontextfwsupport.h"
    29 #endif // RD_ALMALERT__SENSOR_SUPPORT
    33 #endif // RD_ALMALERT__SENSOR_SUPPORT
    30 #include "alarmalertwrapper.h"
    34 
    31 
    35 #include <w32std.h>
    32 // System includes.
    36 #include <almconst.h>
    33 // #include <almconst.h>
       
    34 #include <eikenv.h>
    37 #include <eikenv.h>
    35 #include <AknCapServer.h>
    38 #include <AknCapServer.h>
    36 #include <e32property.h>
    39 #include <e32property.h>
    37 #include <centralrepository.h>
    40 #include <centralrepository.h>
    38 #include <MProfileEngine.h>
    41 #include <MProfileEngine.h>
    39 #include <MProfile.h>
    42 #include <MProfile.h>
    40 #include <MProfileTones.h>
    43 #include <MProfileTones.h>
    41 #include <ProfileEngineDomainConstants.h>
    44 #include <ProfileEngineDomainConstants.h>
    42 #include <sbdefs.h>
    45 #include <sbdefs.h>
    43 #include <coreapplicationuisdomainpskeys.h>
    46 #include <coreapplicationuisdomainpskeys.h>
       
    47 #include <clockdomaincrkeys.h>
       
    48 #include <CalendarInternalCRKeys.h>
    44 #include <wakeupalarm.h>
    49 #include <wakeupalarm.h>
    45 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms
    50 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms
    46 #include <AknUtils.h>
    51 #include <AknUtils.h>
       
    52 #include <hwrmpowerstatesdkpskeys.h>
       
    53 #include <startupdomainpskeys.h>
       
    54 
       
    55 
    47 #ifndef SYMBIAN_CALENDAR_V2
    56 #ifndef SYMBIAN_CALENDAR_V2
    48 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled
    57 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled
    49 #endif // SYMBIAN_CALENDAR_V2
    58 #endif // SYMBIAN_CALENDAR_V2
    50 #include <calsession.h>
    59 #include <calsession.h>
    51 #include <calentryview.h>
    60 #include <calentryview.h>
    52 #include <clockdomaincrkeys.h>
    61 #include <calenlauncher.h>  // for launching calendar entry view
    53 #include <calendardomaincrkeys.h>
    62 
    54 
    63 
    55 // Constants
    64 
       
    65 // CONSTANTS AND MACROS
    56 const TInt KAlmAlertMinSnooze( 100 );
    66 const TInt KAlmAlertMinSnooze( 100 );
    57 const TInt KAlmAlertMaxSnooze( 104 );
    67 const TInt KAlmAlertMaxSnooze( 104 );
    58 const TInt KDefaultSnoozeTime( 5 ); 
    68 
    59 const TUint KAlarmAutoHide( 60000000 );
    69 const TInt KDefaultSnoozeTime( 5 ); // 5 minutes
    60 const TUint KAlarmAutoHideCalendar( 30000000 );
    70 
    61 const TUint KKeyBlockTime( 500000 );
    71 const TUint KAlarmAutoHide( 60000000 );  // 60 s
    62 const TUint KShutdownTime( 1500000 );
    72 const TUint KAlarmAutoHideCalendar( 30000000 );  // 30 s
    63 const TUint KAlarmDelayTime( 1000000 );
    73 const TUint KKeyBlockTime( 500000 );  // 0.5 s
    64 const TUint KInactivityResetInterval( 1000000 );
    74 const TUint KShutdownTime( 1500000 ); // 1.5 s
       
    75 const TUint KAlarmDelayTime( 1000000 ); // 1.0 s
       
    76 const TUint KInactivityResetInterval( 1000000 ); // 1.0 s
       
    77 
    65 const TInt KMaxProfileVolume( 10 );
    78 const TInt KMaxProfileVolume( 10 );
    66 const TInt KNoVolume(0);
    79 const TInt KVolumeRampPeriod( 3000000 );  // 3 seconds
    67 const TInt KVolumeRampPeriod( 3000000 );
       
    68 const TUid KAlarmClockOne = { 0x101F793A };
       
    69 const TUid KCRUidProfileEngine = {0x101F8798};
       
    70 //const TUint32 KProEngActiveReminderTone     = 0x7E00001C;
       
    71 const TUint32 KProEngActiveClockAlarmTone  = 0x7E00001D;
       
    72 //const TUint32 KProEngActiveAlertVibra           = 0x7E00001E;
       
    73 const TUint32 KProEngSilenceMode = {0x80000202};
       
    74 const TUint32 KProEngActiveRingingType = {0x7E000002};
       
    75 const TUint32 KProEngActiveRingingVolume = {0x7E000008};
       
    76 
       
    77 // Literals
       
    78 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" );
    80 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" );
       
    81 
    79 
    82 
    80 // ==========================================================
    83 // ==========================================================
    81 // ================= MEMBER FUNCTIONS =======================
    84 // ================= MEMBER FUNCTIONS =======================
    82 
    85 
    83 
    86 
   107     User::LeaveIfError( iApaSession.Connect() );
   110     User::LeaveIfError( iApaSession.Connect() );
   108 
   111 
   109     iAlarmInfo = new( ELeave )CAlmAlarmInfo( this );
   112     iAlarmInfo = new( ELeave )CAlmAlarmInfo( this );
   110 
   113 
   111     // we can still work without profile engine
   114     // we can still work without profile engine
   112     // PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); )
   115     PIM_TRAPD_ASSERT( iProfileEng = CreateProfileEngineL(); )
   113 
   116 
   114     // iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL();
   117     iNotifierDialogController = ((CAknCapServer*)CEikonEnv::Static()->AppServer())->GlobalNoteControllerL();
   115     // iNotifierDialogController->SetNoteObserver( iAlarmControl );
   118     iNotifierDialogController->SetNoteObserver( iAlarmControl );
   116     iAlarmAlert = new AlarmAlert(iAlarmControl);
       
   117 
   119 
   118     // create timers
   120     // create timers
   119     iShutdownTimer   = CPeriodic::NewL( CActive::EPriorityStandard );
   121     iShutdownTimer   = CPeriodic::NewL( CActive::EPriorityStandard );
   120     iAutoSnoozeTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   122     iAutoSnoozeTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   121     iKeyBlockTimer   = CPeriodic::NewL( CActive::EPriorityStandard );
   123     iKeyBlockTimer   = CPeriodic::NewL( CActive::EPriorityStandard );
   153 // ---------------------------------------------------------
   155 // ---------------------------------------------------------
   154 //
   156 //
   155 CAlarmUtils::~CAlarmUtils()
   157 CAlarmUtils::~CAlarmUtils()
   156     {
   158     {
   157     TRACE_ENTRY_POINT;
   159     TRACE_ENTRY_POINT;
   158     /*if( iNotifierDialogController )
   160     if( iNotifierDialogController )
   159         {
   161         {
   160         iNotifierDialogController->SetNoteObserver( NULL );
   162         iNotifierDialogController->SetNoteObserver( NULL );
   161         }*/
       
   162     if( iAlarmAlert )
       
   163         {
       
   164         delete iAlarmAlert;
       
   165         iAlarmAlert = NULL;
       
   166         }
   163         }
   167 
   164 
   168     if( iShutdownTimer )
   165     if( iShutdownTimer )
   169         {
   166         {
   170         iShutdownTimer->Cancel();
   167         iShutdownTimer->Cancel();
   361 TBool CAlarmUtils::IsRingingTypeSilent() const
   358 TBool CAlarmUtils::IsRingingTypeSilent() const
   362     {
   359     {
   363     TRACE_ENTRY_POINT;
   360     TRACE_ENTRY_POINT;
   364     TBool isSilent( EFalse );
   361     TBool isSilent( EFalse );
   365 
   362 
   366     /*if( iProfileEng )
   363     if( iProfileEng )
   367         {
   364         {
   368         MProfile* profile = NULL;
   365         MProfile* profile = NULL;
   369         PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); )
   366         PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); )
   370 
   367 
   371         if( profile )
   368         if( profile )
   376                 isSilent = ETrue;  // Ringing Type = Silent or BeepOnce
   373                 isSilent = ETrue;  // Ringing Type = Silent or BeepOnce
   377                 }
   374                 }
   378             profile->Release();
   375             profile->Release();
   379             }
   376             }
   380         }
   377         }
   381     TRACE_EXIT_POINT;*/
   378     TRACE_EXIT_POINT;
   382     return isSilent;
   379     return isSilent;
   383     }
   380     }
   384 
   381 
   385 // ---------------------------------------------------------
   382 // ---------------------------------------------------------
   386 // Check if the used alarm tone is an "off" tone.
   383 // Check if the used alarm tone is an "off" tone.
   414 // -----------------------------------------------------------------------------
   411 // -----------------------------------------------------------------------------
   415 // Read alarm sound filenames from central repository.
   412 // Read alarm sound filenames from central repository.
   416 // -----------------------------------------------------------------------------
   413 // -----------------------------------------------------------------------------
   417 //
   414 //
   418 void CAlarmUtils::GetAlarmSoundFilenames()
   415 void CAlarmUtils::GetAlarmSoundFilenames()
   419 {
   416     {
   420 	TRACE_ENTRY_POINT;
   417     TRACE_ENTRY_POINT;
   421 	CRepository* profileRepository = NULL;
   418     CRepository* repository = NULL;
   422 	CRepository* repository = NULL;
   419 
   423 
   420     if( IsClockAlarm() )
   424 	if( IsClockAlarm() )
   421         {
   425 	{
   422         PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); )
   426 		PIM_TRAPD_ASSERT( repository = CRepository::NewL( TUid::Uid(KCRUidClockApp) ); ) 
   423 
   427 		PIM_TRAPD_ASSERT( profileRepository = CRepository::NewL( 
   424         if( repository )
   428 														KCRUidProfileEngine ); )
   425             {
   429 
   426             PIM_ASSERT( repository->Get( KClockAppSoundFile, iAlarmData.iAlarmTone ); )
   430 		if( repository )
   427             PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); )
   431 		{
   428             }
   432 			PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, 
   429         }
   433 											iAlarmData.iDefaultAlarmTone ); )
   430     else
   434 		}
   431         {
   435 		if( profileRepository )
   432         PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); )
   436 		{
   433 
   437 			// TODO: Need to use KProEngActiveClockAlarmTone once its released
   434         if( repository )
   438 			//PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone , iAlarmData.iAlarmTone); )
   435             {
   439 			PIM_ASSERT( repository->Get( KClockAppDefaultSoundFile, 
   436             PIM_ASSERT( repository->Get( KCalendarSoundFile, iAlarmData.iAlarmTone ); )
   440 													iAlarmData.iAlarmTone ); )
   437             PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, iAlarmData.iDefaultAlarmTone ); )
   441 		}
   438             }
   442 	}
   439         }
   443 	else
   440     delete repository;
   444 	{
   441     TRACE_EXIT_POINT;
   445 		PIM_TRAPD_ASSERT( repository =
   442     }
   446 				CRepository::NewL( TUid::Uid(KCRUidCalendar) ); )
       
   447 		PIM_TRAPD_ASSERT( profileRepository =
       
   448 				CRepository::NewL( KCRUidProfileEngine ); )
       
   449 
       
   450 		if( repository )
       
   451 		{
       
   452 			PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, 
       
   453 											iAlarmData.iDefaultAlarmTone ); )
       
   454 		}
       
   455 		if( profileRepository )
       
   456 		{
       
   457 			PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone, iAlarmData.iAlarmTone ); )
       
   458 		}
       
   459 	}
       
   460 	delete repository;
       
   461 	delete profileRepository;
       
   462 	TRACE_EXIT_POINT;
       
   463 }
       
   464 
   443 
   465 // -----------------------------------------------------------------------------
   444 // -----------------------------------------------------------------------------
   466 // Check if the alarm sound file is a KRngMimeType file.
   445 // Check if the alarm sound file is a KRngMimeType file.
   467 // -----------------------------------------------------------------------------
   446 // -----------------------------------------------------------------------------
   468 //
   447 //
   507     iAlarmData.iRepeatValue = KMdaAudioToneRepeatForever; // KMdaRepeatForever
   486     iAlarmData.iRepeatValue = KMdaAudioToneRepeatForever; // KMdaRepeatForever
   508     iAlarmData.iVolume = KMaxProfileVolume; // clock alarms always ramp to maximum volume
   487     iAlarmData.iVolume = KMaxProfileVolume; // clock alarms always ramp to maximum volume
   509     iAlarmData.iVolumeRampTime = iAlarmData.iVolume * KVolumeRampPeriod; // volume ramp only for clock alarms
   488     iAlarmData.iVolumeRampTime = iAlarmData.iVolume * KVolumeRampPeriod; // volume ramp only for clock alarms
   510 
   489 
   511     if( !IsClockAlarm() )
   490     if( !IsClockAlarm() )
   512     {
   491         {
   513         CRepository* repository = NULL;
   492         if( iProfileEng )
   514         PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidProfileEngine ); )
   493             {
   515     	
   494             MProfile* profile = NULL;
   516     	TInt ringType;
   495             PIM_TRAPD_ASSERT( profile = iProfileEng->ActiveProfileL(); )
   517     	repository->Get( KProEngActiveRingingType , ringType);
   496 
   518     	iAlarmData.iRingType = static_cast< TProfileRingingType >( ringType );
   497             if( profile )
   519     	
   498                 {
   520     	TBool silentMode;
   499                 const TProfileToneSettings& setting = profile->ProfileTones().ToneSettings();
   521     	TInt ringingVolume;
   500                 iAlarmData.iRingType = setting.iRingingType;
   522     	repository->Get( KProEngSilenceMode, silentMode);
   501 
   523     	if(silentMode)
   502                 // calendar alarms: if profile is "silent" -> set volume to zero
   524     	    {
   503                 iAlarmData.iVolume = (iAlarmData.iRingType == EProfileRingingTypeSilent ? 0 : setting.iRingingVolume);
   525     	    ringingVolume = KNoVolume;
   504 
   526     	    }
   505                 profile->Release();
   527     	else
   506                 }
   528     	    {
   507             }
   529 			// It seems the wrong key has been associated with calendar alarm tone
   508 
   530 			// settings. It would be changed once it's rectified by profile team.
   509         if( iAlarmData.iRingType == EProfileRingingTypeRingingOnce )
   531     	    repository->Get( KProEngActiveRingingVolume , ringingVolume );
   510             {
   532     	    }
   511             iAlarmData.iRepeatValue = 1;
   533     	
   512             }
   534     	iAlarmData.iVolume = ringingVolume;
   513         iAlarmData.iVolumeRampTime = 0;
   535     	
   514         }
   536     	iAlarmData.iVolumeRampTime = 0;
       
   537     } else {
       
   538     	TInt volumeOn = iAlarmData.iAlarm.ClientData2();
       
   539     	if (!volumeOn) {
       
   540     		iAlarmData.iRingType = EProfileRingingTypeSilent;
       
   541     		iAlarmData.iVolume = KNoVolume;
       
   542     	}
       
   543     }
       
   544     TRACE_EXIT_POINT;
   515     TRACE_EXIT_POINT;
   545     }
   516     }
   546 
   517 
   547 // -----------------------------------------------------------------------------
   518 // -----------------------------------------------------------------------------
   548 // 
   519 // 
   652     switch( iAlarmData.iAlarmType )
   623     switch( iAlarmData.iAlarmType )
   653         {
   624         {
   654         case EAlarmTypeClock:
   625         case EAlarmTypeClock:
   655             {
   626             {
   656             CRepository* repository = NULL;
   627             CRepository* repository = NULL;
   657             PIM_TRAPD_ASSERT( repository = CRepository::NewL( TUid::Uid(KCRUidClockApp) ); )
   628             PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidClockApp ); )
   658 
   629 
   659             if( repository )
   630             if( repository )
   660                 {
   631                 {
   661                 repository->Get( KClockAppSnoozeTime, iAlarmData.iSnoozeTime );
   632                 repository->Get( KClockAppSnoozeTime, iAlarmData.iSnoozeTime );
   662                 delete repository;
   633                 delete repository;
   665             }
   636             }
   666 
   637 
   667         case EAlarmTypeCalendar:
   638         case EAlarmTypeCalendar:
   668             {
   639             {
   669             CRepository* repository = NULL;
   640             CRepository* repository = NULL;
   670             PIM_TRAPD_ASSERT( repository =
   641             PIM_TRAPD_ASSERT( repository = CRepository::NewL( KCRUidCalendar ); )
   671             		CRepository::NewL( TUid::Uid(KCRUidCalendar) ); )
       
   672 
   642 
   673             if( repository )
   643             if( repository )
   674                 {
   644                 {
   675                 repository->Get( KCalendarSnoozeTime, iAlarmData.iSnoozeTime );
   645                 repository->Get( KCalendarSnoozeTime, iAlarmData.iSnoozeTime );
   676                 delete repository;
   646                 delete repository;
   760 
   730 
   761 // -----------------------------------------------------------------------------
   731 // -----------------------------------------------------------------------------
   762 // 
   732 // 
   763 // -----------------------------------------------------------------------------
   733 // -----------------------------------------------------------------------------
   764 //
   734 //
   765 AlarmAlert* CAlarmUtils::NotifierDialogController()
   735 CNotifierDialogController* CAlarmUtils::NotifierDialogController()
   766     {
   736     {
   767     TRACE_ENTRY_POINT;
   737     TRACE_ENTRY_POINT;
   768     TRACE_EXIT_POINT;
   738     TRACE_EXIT_POINT;
   769     // return iNotifierDialogController;
   739     return iNotifierDialogController;
   770     return iAlarmAlert;
       
   771     }
   740     }
   772 
   741 
   773 // ---------------------------------------------------------
   742 // ---------------------------------------------------------
   774 // Checks if the alarm server has more expired alarms ready 
   743 // Checks if the alarm server has more expired alarms ready 
   775 // to be shown.
   744 // to be shown.
   993 // ---------------------------------------------------------
   962 // ---------------------------------------------------------
   994 //
   963 //
   995 void CAlarmUtils::DeviceShutdown()
   964 void CAlarmUtils::DeviceShutdown()
   996     {
   965     {
   997     TRACE_ENTRY_POINT;
   966     TRACE_ENTRY_POINT;
   998     iShutdownTimer->Cancel();
   967     
   999     if( StarterConnect() )
   968     // charging state added for the err EMDN-835CW2.
  1000         {
   969     TInt chargingState;
  1001         iStarter.Shutdown();
   970     RProperty::Get( KPSUidHWRMPowerState, KHWRMChargingStatus , chargingState );
  1002         iStarter.Close();
   971     
  1003         }    
   972     if( IsDeviceInAlarmState() && ( chargingState == EChargingStatusNotConnected ) )
       
   973         {       
       
   974         iShutdownTimer->Cancel();
       
   975         if( StarterConnect() )
       
   976             {
       
   977             iStarter.Shutdown();
       
   978             iStarter.Close();
       
   979             }    
       
   980         }
  1004     TRACE_EXIT_POINT;
   981     TRACE_EXIT_POINT;
  1005     }
   982     }
  1006 
   983 
  1007 // ---------------------------------------------------------
   984 // ---------------------------------------------------------
  1008 // 
   985 // 
  1146 // ---------------------------------------------------------
  1123 // ---------------------------------------------------------
  1147 //
  1124 //
  1148 void CAlarmUtils::StartAccessoryObserver()
  1125 void CAlarmUtils::StartAccessoryObserver()
  1149     {
  1126     {
  1150     TRACE_ENTRY_POINT;    
  1127     TRACE_ENTRY_POINT;    
  1151     // PIM_TRAPD_ASSERT( iRemConHandler->StartL(); )    
  1128     PIM_TRAPD_ASSERT( iRemConHandler->StartL(); )    
  1152     TRACE_EXIT_POINT;
  1129     TRACE_EXIT_POINT;
  1153     }
  1130     }
  1154 
  1131 
  1155 // ---------------------------------------------------------
  1132 // ---------------------------------------------------------
  1156 // 
  1133 // 
  1279 
  1256 
  1280 // ---------------------------------------------------------
  1257 // ---------------------------------------------------------
  1281 // Callback function for the auto snooze timer
  1258 // Callback function for the auto snooze timer
  1282 // ---------------------------------------------------------
  1259 // ---------------------------------------------------------
  1283 //
  1260 //
  1284 TInt CAlarmUtils::SnoozeInfoCallBack(TAny* /*aPtr*/)
  1261 TInt CAlarmUtils::SnoozeInfoCallBack(TAny* aPtr)
  1285     {
  1262     {
  1286     TRACE_ENTRY_POINT;
  1263     TRACE_ENTRY_POINT;
  1287     // PIM_TRAPD_ASSERT( static_cast<CAlmAlarmControl*>( aPtr )->ShowSnoozeInfoNoteL(); )
  1264     PIM_TRAPD_ASSERT( static_cast<CAlmAlarmControl*>( aPtr )->ShowSnoozeInfoNoteL(); )
  1288     TRACE_EXIT_POINT;
  1265     TRACE_EXIT_POINT;
  1289     return 0;
  1266     return 0;
  1290     }
  1267     }
  1291 
  1268 
  1292 // ---------------------------------------------------------
  1269 // ---------------------------------------------------------
  1647 void CAlarmUtils::StartCalendarL()
  1624 void CAlarmUtils::StartCalendarL()
  1648     {
  1625     {
  1649     TRACE_ENTRY_POINT;
  1626     TRACE_ENTRY_POINT;
  1650     
  1627     
  1651     iCalendarAlarmViewer = ETrue;
  1628     iCalendarAlarmViewer = ETrue;
  1652     /*
  1629     
  1653     CalenLauncher::ViewEntryL( iAlarmData.iLocalUid,
  1630     CalenLauncher::ViewEntryL( iAlarmData.iLocalUid,
  1654                                iAlarmData.iInstanceTime, iAlarmData.iCalFileName,
  1631                                iAlarmData.iInstanceTime, iAlarmData.iCalFileName,
  1655                                CanSnooze() ? CalenLauncher::EAlarmViewer : 
  1632                                CanSnooze() ? CalenLauncher::EAlarmViewer : 
  1656                                              CalenLauncher::EAlarmViewerNoSnooze );
  1633                                              CalenLauncher::EAlarmViewerNoSnooze );
  1657 											 */
       
  1658     TRACE_EXIT_POINT;
  1634     TRACE_EXIT_POINT;
  1659     }
  1635     }
  1660 
  1636 
  1661 // ---------------------------------------------------------
  1637 // ---------------------------------------------------------
  1662 // Check if the security lock is active.
  1638 // Check if the security lock is active.
  1664 //
  1640 //
  1665 TBool CAlarmUtils::IsSecurityLockActive()
  1641 TBool CAlarmUtils::IsSecurityLockActive()
  1666     {
  1642     {
  1667     TRACE_ENTRY_POINT;
  1643     TRACE_ENTRY_POINT;
  1668     TInt keyVal( 0 );
  1644     TInt keyVal( 0 );
       
  1645     TInt currentBootupQueriesStatus(0);
  1669     TBool retVal( EFalse );
  1646     TBool retVal( EFalse );
  1670 
  1647 
  1671     PIM_ASSERT( RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, keyVal ); )
  1648     PIM_ASSERT( RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, keyVal ); )
  1672     if( keyVal > EAutolockOff )
  1649     PIM_ASSERT(RProperty::Get(KPSUidStartup,KPSStartupUiPhase,currentBootupQueriesStatus ); )
       
  1650     
       
  1651     if( (keyVal > EAutolockOff) || (currentBootupQueriesStatus != EStartupUiPhaseAllDone ) )
  1673         {
  1652         {
  1674         retVal = ETrue;
  1653         retVal = ETrue;
  1675         }
  1654         }
  1676     TRACE_EXIT_POINT;
  1655     TRACE_EXIT_POINT;
  1677     return retVal;
  1656     return retVal;
  1693 TBool CAlarmUtils::IsCalendarAlarmViewer()
  1672 TBool CAlarmUtils::IsCalendarAlarmViewer()
  1694     {
  1673     {
  1695     return iCalendarAlarmViewer;
  1674     return iCalendarAlarmViewer;
  1696     }
  1675     }
  1697 
  1676 
  1698 SAlarmInfo* CAlarmUtils::GetAlarmInfo()
  1677 // ---------------------------------------------------------
  1699     {
  1678 // Silence the notifying alarm 
  1700     return iAlarmInfo->GetAlarmInfo(iAlarmData.iAlarm,
  1679 // ---------------------------------------------------------
  1701                                     iAlarmData.iAlarmType);
  1680 //
  1702     }
  1681 void CAlarmUtils::DoSilence()
  1703 
  1682     {
       
  1683     TRACE_ENTRY_POINT;
       
  1684     
       
  1685     // silence only if snoozing is possible
       
  1686     // this way user must hear the last "call"
       
  1687     if( CanSnooze() )
       
  1688         {
       
  1689         TBool silenced( EFalse );
       
  1690         if( IsCalendarAlarm() )
       
  1691             {
       
  1692             // do silencing only if alarm is being played and silencing possible
       
  1693             if( iAlarmPlayer && !( IsRingingTypeSilent() || IsOffTone() ) )
       
  1694                 {
       
  1695                 silenced = ETrue;
       
  1696                 delete iAlarmPlayer;
       
  1697                 iAlarmPlayer = NULL;
       
  1698                 SetBackLight( EFalse );
       
  1699                 // calendar alarm needs extra handling due to having stop - silence
       
  1700                 //simulate right softkey pressing
       
  1701                 RWsSession wsSession=CCoeEnv::Static()->WsSession();
       
  1702                 TKeyEvent keyEvent;
       
  1703                 keyEvent.iCode = EKeyCBA2;  
       
  1704                 keyEvent.iScanCode = EStdKeyDevice1;
       
  1705                 keyEvent.iModifiers = 0;
       
  1706                 keyEvent.iRepeats = 0;
       
  1707                 wsSession.SimulateKeyEvent( keyEvent );
       
  1708                 wsSession.Flush();
       
  1709                 }
       
  1710             }
       
  1711         // clockalarm
       
  1712         else
       
  1713             {
       
  1714             silenced = ETrue;
       
  1715             delete iAlarmPlayer;
       
  1716             iAlarmPlayer = NULL;
       
  1717             SetBackLight( EFalse );
       
  1718             StartAutoSnoozeTimer();
       
  1719             }
       
  1720     
       
  1721         #if defined( RD_ALMALERT__SENSOR_SUPPORT )
       
  1722         // notify the result through the context framework
       
  1723         if( iCFSupport && silenced )
       
  1724             {
       
  1725             PIM_TRAPD_ASSERT( iCFSupport->PublishAlarmResultL( EResultAlarmSilenced ); )
       
  1726             }
       
  1727         #endif // RD_ALMALERT__SENSOR_SUPPORT
       
  1728         }
       
  1729     TRACE_EXIT_POINT;     
       
  1730     }
       
  1731 
       
  1732 // ---------------------------------------------------------
       
  1733 // Check if the alarm is duplicate calendar alarm
       
  1734 // Rest of the details in header file
       
  1735 // ---------------------------------------------------------
       
  1736 //
       
  1737 TBool CAlarmUtils::CheckForDuplicateAlarm()
       
  1738     {
       
  1739     TRACE_ENTRY_POINT;
       
  1740     TBool ret = EFalse;
       
  1741     if(IsCalendarAlarm())
       
  1742         {
       
  1743         TTime currAlarmOrigExpTime = iAlarmData.iAlarm.OriginalExpiryTime();
       
  1744 
       
  1745         if(currAlarmOrigExpTime == iPrevAlarmOriginalExpiryTime && iPrevLocalUid == iAlarmData.iLocalUid 
       
  1746 			&& !iPrevCalFileName.CompareF(iAlarmData.iCalFileName) )
       
  1747             {    
       
  1748             TInt& count = iAlarmData.iAlarm.ClientData1();
       
  1749             if( !(count >= KAlmAlertMinSnooze && 
       
  1750                 count <= KAlmAlertMaxSnooze ))
       
  1751                 {
       
  1752                 ret = ETrue;
       
  1753                 }
       
  1754             }
       
  1755         }
       
  1756     TRACE_EXIT_POINT;
       
  1757     return ret;
       
  1758     }
       
  1759 
       
  1760 
       
  1761 // ---------------------------------------------------------
       
  1762 // Store details of current alarm for future comparison when next calendar alarm comes.
       
  1763 // Rest of the details in header file
       
  1764 // ---------------------------------------------------------
       
  1765 //
       
  1766 void CAlarmUtils::StoreCurrentCalendarAlarmData()
       
  1767 	{
       
  1768 	TRACE_ENTRY_POINT;
       
  1769 	iPrevLocalUid					= iAlarmData.iLocalUid;  
       
  1770     iPrevCalFileName 				= iAlarmData.iCalFileName;
       
  1771 	iPrevAlarmOriginalExpiryTime 	= iAlarmData.iAlarm.OriginalExpiryTime();
       
  1772 	TRACE_EXIT_POINT;
       
  1773 	}
       
  1774 	
  1704 // End of File
  1775 // End of File