alarmui/src/alarmutils.cpp
changeset 57 bb2d3e476f29
parent 45 b6db4fd4947b
child 83 5aadd1120515
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    13 *
    13 *
    14 * Description:   
    14 * Description:   
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 // User includes.
    19 
       
    20 // INCLUDE FILES
       
    21 #include "alarmutils.h"
    19 #include "alarmutils.h"
    22 
       
    23 #include "AlmAlertVariant.hrh"
    20 #include "AlmAlertVariant.hrh"
    24 #include "pim_trace.h"
    21 #include "pim_trace.h"
    25 
       
    26 #include "AlmAlarmPlayer.h"
    22 #include "AlmAlarmPlayer.h"
    27 #include "AlmAlarmControl.h"
    23 #include "AlmAlarmControl.h"
    28 #include "AlmAlarmInfo.h"
    24 #include "AlmAlarmInfo.h"
    29 #include "AlarmService.h"
    25 #include "AlarmService.h"
    30 #include "alarmremconeventshandler.h"
    26 #include "alarmremconeventshandler.h"
    31 #ifdef RD_ALMALERT__SENSOR_SUPPORT
    27 #ifdef RD_ALMALERT__SENSOR_SUPPORT
    32 #include "alarmcontextfwsupport.h"
    28 #include "alarmcontextfwsupport.h"
    33 #endif // RD_ALMALERT__SENSOR_SUPPORT
    29 #endif // RD_ALMALERT__SENSOR_SUPPORT
    34 
       
    35 #include "alarmalertwrapper.h"
    30 #include "alarmalertwrapper.h"
    36 
    31 
       
    32 // System includes.
    37 // #include <almconst.h>
    33 // #include <almconst.h>
    38 #include <eikenv.h>
    34 #include <eikenv.h>
    39 #include <AknCapServer.h>
    35 #include <AknCapServer.h>
    40 #include <e32property.h>
    36 #include <e32property.h>
    41 #include <centralrepository.h>
    37 #include <centralrepository.h>
    43 #include <MProfile.h>
    39 #include <MProfile.h>
    44 #include <MProfileTones.h>
    40 #include <MProfileTones.h>
    45 #include <ProfileEngineDomainConstants.h>
    41 #include <ProfileEngineDomainConstants.h>
    46 #include <sbdefs.h>
    42 #include <sbdefs.h>
    47 #include <coreapplicationuisdomainpskeys.h>
    43 #include <coreapplicationuisdomainpskeys.h>
    48 // #include <clockdomaincrkeys.h>
       
    49 // #include <CalendarInternalCRKeys.h>
       
    50 #include <wakeupalarm.h>
    44 #include <wakeupalarm.h>
    51 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms
    45 #include <calalarm.h> // KUidAgendaModelAlarmCategory - the alarm category id for calendar alarms
    52 #include <AknUtils.h>
    46 #include <AknUtils.h>
    53 
       
    54 #ifndef SYMBIAN_CALENDAR_V2
    47 #ifndef SYMBIAN_CALENDAR_V2
    55 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled
    48 #include <agmalarm.h> // deprecated, use CalAlarm.h when SYMBIAN_CALENDAR_V2 flag is enabled
    56 #endif // SYMBIAN_CALENDAR_V2
    49 #endif // SYMBIAN_CALENDAR_V2
    57 #include <calsession.h>
    50 #include <calsession.h>
    58 #include <calentryview.h>
    51 #include <calentryview.h>
    59 #include <clockdomaincrkeys.h>
    52 #include <clockdomaincrkeys.h>
    60 #include <calendardomaincrkeys.h>
    53 #include <calendardomaincrkeys.h>
    61 // #include <calenlauncher.h>  // for launching calendar entry view
    54 
    62 
    55 // Constants
    63 
       
    64 
       
    65 // CONSTANTS AND MACROS
       
    66 const TInt KAlmAlertMinSnooze( 100 );
    56 const TInt KAlmAlertMinSnooze( 100 );
    67 const TInt KAlmAlertMaxSnooze( 104 );
    57 const TInt KAlmAlertMaxSnooze( 104 );
    68 
    58 const TInt KDefaultSnoozeTime( 5 ); 
    69 const TInt KDefaultSnoozeTime( 5 ); // 5 minutes
    59 const TUint KAlarmAutoHide( 60000000 );
    70 
    60 const TUint KAlarmAutoHideCalendar( 30000000 );
    71 const TUint KAlarmAutoHide( 60000000 );  // 60 s
    61 const TUint KKeyBlockTime( 500000 );
    72 const TUint KAlarmAutoHideCalendar( 30000000 );  // 30 s
    62 const TUint KShutdownTime( 1500000 );
    73 const TUint KKeyBlockTime( 500000 );  // 0.5 s
    63 const TUint KAlarmDelayTime( 1000000 );
    74 const TUint KShutdownTime( 1500000 ); // 1.5 s
    64 const TUint KInactivityResetInterval( 1000000 );
    75 const TUint KAlarmDelayTime( 1000000 ); // 1.0 s
       
    76 const TUint KInactivityResetInterval( 1000000 ); // 1.0 s
       
    77 
       
    78 const TInt KMaxProfileVolume( 10 );
    65 const TInt KMaxProfileVolume( 10 );
    79 const TInt KVolumeRampPeriod( 3000000 );  // 3 seconds
    66 const TInt KNoVolume(0);
    80 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" );
    67 const TInt KVolumeRampPeriod( 3000000 );
    81 //const TUint32 KCalendarSoundFile = 0x00000004;
       
    82 //const TUint32 KClockAppSoundFile = 0x00000000;
       
    83 const TUid KAlarmClockOne = { 0x101F793A };
    68 const TUid KAlarmClockOne = { 0x101F793A };
    84 
       
    85 const TUid KCRUidProfileEngine = {0x101F8798};
    69 const TUid KCRUidProfileEngine = {0x101F8798};
    86 //const TUint32 KProEngActiveReminderTone     = 0x7E00001C;
    70 //const TUint32 KProEngActiveReminderTone     = 0x7E00001C;
    87 //const TUint32 KProEngActiveClockAlarmTone  = 0x7E00001D;
    71 const TUint32 KProEngActiveClockAlarmTone  = 0x7E00001D;
    88 //const TUint32 KProEngActiveAlertVibra           = 0x7E00001E;
    72 //const TUint32 KProEngActiveAlertVibra           = 0x7E00001E;
    89 const TUint32 KProEngActiveRingingType = 0x7E000002;
    73 const TUint32 KProEngSilenceMode = {0x80000202};
    90 const TUint32 KProEngActiveRingingVolume = 0x7E000008;
    74 const TUint32 KProEngActiveRingingType = {0x7E000002};
    91 
    75 const TUint32 KProEngActiveRingingVolume = {0x7E000008};
       
    76 
       
    77 // Literals
       
    78 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" );
    92 
    79 
    93 // ==========================================================
    80 // ==========================================================
    94 // ================= MEMBER FUNCTIONS =======================
    81 // ================= MEMBER FUNCTIONS =======================
    95 
    82 
    96 
    83 
   465 			PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, 
   452 			PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile, 
   466 											iAlarmData.iDefaultAlarmTone ); )
   453 											iAlarmData.iDefaultAlarmTone ); )
   467 		}
   454 		}
   468 		if( profileRepository )
   455 		if( profileRepository )
   469 		{
   456 		{
   470 			// TODO: Need to use KProEngActiveReminderTone once its released
   457 			PIM_ASSERT( profileRepository->Get( KProEngActiveClockAlarmTone, iAlarmData.iAlarmTone ); )
   471 			//PIM_ASSERT( profileRepository->Get( KProEngActiveReminderTone, iAlarmData.iAlarmTone ); )
       
   472 			PIM_ASSERT( repository->Get( KCalendarDefaultSoundFile,
       
   473 													iAlarmData.iAlarmTone ); )
       
   474 		}
   458 		}
   475 	}
   459 	}
   476 	delete repository;
   460 	delete repository;
   477 	delete profileRepository;
   461 	delete profileRepository;
   478 	TRACE_EXIT_POINT;
   462 	TRACE_EXIT_POINT;
   531     	
   515     	
   532     	TInt ringType;
   516     	TInt ringType;
   533     	repository->Get( KProEngActiveRingingType , ringType);
   517     	repository->Get( KProEngActiveRingingType , ringType);
   534     	iAlarmData.iRingType = static_cast< TProfileRingingType >( ringType );
   518     	iAlarmData.iRingType = static_cast< TProfileRingingType >( ringType );
   535     	
   519     	
       
   520     	TBool silentMode;
   536     	TInt ringingVolume;
   521     	TInt ringingVolume;
   537     	repository->Get( KProEngActiveRingingVolume , ringingVolume);
   522     	repository->Get( KProEngSilenceMode, silentMode);
       
   523     	if(silentMode)
       
   524     	    {
       
   525     	    ringingVolume = KNoVolume;
       
   526     	    }
       
   527     	else
       
   528     	    {
       
   529 			// It seems the wrong key has been associated with calendar alarm tone
       
   530 			// settings. It would be changed once it's rectified by profile team.
       
   531     	    repository->Get( KProEngActiveRingingVolume , ringingVolume );
       
   532     	    }
       
   533     	
   538     	iAlarmData.iVolume = ringingVolume;
   534     	iAlarmData.iVolume = ringingVolume;
   539     	
   535     	
   540     	iAlarmData.iVolumeRampTime = 0;
   536     	iAlarmData.iVolumeRampTime = 0;
   541     } else {
   537     } else {
   542     	TInt volumeOn = iAlarmData.iAlarm.ClientData2();
   538     	TInt volumeOn = iAlarmData.iAlarm.ClientData2();
   543     	if (!volumeOn) {
   539     	if (!volumeOn) {
   544     		iAlarmData.iRingType = EProfileRingingTypeSilent;
   540     		iAlarmData.iRingType = EProfileRingingTypeSilent;
   545     		iAlarmData.iVolume = 0;
   541     		iAlarmData.iVolume = KNoVolume;
   546     	}
   542     	}
   547     }
   543     }
   548     TRACE_EXIT_POINT;
   544     TRACE_EXIT_POINT;
   549     }
   545     }
   550 
   546