alarmui/src/AlmAlarmControl.cpp
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 23 fd30d51f876b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include "AlmAlarmControl.h"
    23 #include "AlmAlarmControl.h"
    24 #include "pim_trace.h"
    24 #include "pim_trace.h"
    25 #include "alarmutils.h"
    25 #include "alarmutils.h"
    26 #include <secondarydisplay/alarmuiSecondaryDisplay.h>
    26 // #include <secondarydisplay/alarmuiSecondaryDisplay.h>
    27 #include <bautils.h>
    27 #include <bautils.h>
    28 #include <StringLoader.h>
    28 #include <StringLoader.h>
    29 #include <pathinfo.h>
    29 #include <pathinfo.h>
    30 #include <featmgr.h>
    30 #include <featmgr.h>
    31 #include <aknnotewrappers.h>
    31 #include <aknnotewrappers.h>
    32 #include <coreapplicationuisdomainpskeys.h>
    32 #include <coreapplicationuisdomainpskeys.h>
    33 #include <alarmuidomainpskeys.h>
    33 // #include <alarmuidomainpskeys.h>
    34 #include <data_caging_path_literals.hrh>
    34 #include <data_caging_path_literals.hrh>
    35 
    35 
    36 #include <AlmAlert.rsg>
    36 #include <AlmAlert.rsg>
    37 #include "AlmAlert.hrh"
    37 #include "AlmAlert.hrh"
    38 #include "AlmAlert.pan"
    38 #include "AlmAlert.pan"
    39 
    39 
    40 #include <aknnotewrappers.h>
    40 #include <aknnotewrappers.h>
    41 #include <AknMediatorFacade.h>
    41 #include <AknMediatorFacade.h>
    42 
    42 #include "alarmalertwrapper.h" 
    43 #include <missedalarm.h>
    43 
       
    44 // #include <missedalarm.h>
    44 
    45 
    45 _LIT( KResourceFile, "AlmAlert.rsc" );
    46 _LIT( KResourceFile, "AlmAlert.rsc" );
    46 
    47 
    47 const TInt KAlarmPriority( 3095 );  // Priority for global note queue
    48 const TInt KAlarmPriority( 3095 );  // Priority for global note queue
    48 
    49 
   130     // stop observers when exiting from EStateWaitingInput state
   131     // stop observers when exiting from EStateWaitingInput state
   131     if( aOldState == EStateWaitingInput
   132     if( aOldState == EStateWaitingInput
   132         && iState != EStateWaitingInput )
   133         && iState != EStateWaitingInput )
   133     {
   134     {
   134         // stop the context/sensor observer.
   135         // stop the context/sensor observer.
   135         PIM_TRAPD_ASSERT( iAlarmUtils->StopCFObserverL(); )
   136         // PIM_TRAPD_ASSERT( iAlarmUtils->StopCFObserverL(); )
   136 
   137 
   137         // stop waiting for "end call" command from accessories
   138         // stop waiting for "end call" command from accessories
   138         iAlarmUtils->StopAccessoryObserver();
   139         iAlarmUtils->StopAccessoryObserver();
   139     }
   140     }
   140 
   141 
   189 
   190 
   190             // start waiting for "end call" command from accessories
   191             // start waiting for "end call" command from accessories
   191             iAlarmUtils->StartAccessoryObserver();
   192             iAlarmUtils->StartAccessoryObserver();
   192 
   193 
   193             // publish new alarm context value and wait for any actions
   194             // publish new alarm context value and wait for any actions
   194             PIM_TRAPD_ASSERT( iAlarmUtils->StartCFObserverL(); )
   195             // PIM_TRAPD_ASSERT( iAlarmUtils->StartCFObserverL(); )
   195             break;
   196             break;
   196         }
   197         }
   197 
   198 
   198         default:
   199         default:
   199             // fall through
   200             // fall through
   225 
   226 
   226     // Allow auto-snooze only while waiting user input
   227     // Allow auto-snooze only while waiting user input
   227     if( IsState( EStateWaitingInput ) )
   228     if( IsState( EStateWaitingInput ) )
   228         {
   229         {
   229         SetState( EStateAfterInput );
   230         SetState( EStateAfterInput );
   230 	 StopOrSnoozeAlarm();
   231         if( iAlarmUtils->IsCalendarAlarm() )
   231 	 DoCancelDialog();
   232             {    
       
   233             if( iAlarmUtils->IsCalendarAlarmViewer() )
       
   234                 {                
       
   235                 iAlarmUtils->SetCalendarAlarmViewer(EFalse);           
       
   236                 }
       
   237             else
       
   238                 {
       
   239                 TRAP_IGNORE( StoreMissedAlarmDataL() );
       
   240                 }
       
   241             iAlarmUtils->DoStopAlarm();             
       
   242             DoCancelDialog();
       
   243                    	             
       
   244             }
       
   245         else
       
   246             {        
       
   247             iAlarmUtils->TryToSnoozeActiveAlarm();
       
   248             DoCancelDialog();
       
   249             }
   232         }
   250         }
   233     TRACE_EXIT_POINT;
   251     TRACE_EXIT_POINT;
   234     }
   252     }
   235 
   253 
   236 // ---------------------------------------------------------
   254 // ---------------------------------------------------------
   238 // ---------------------------------------------------------
   256 // ---------------------------------------------------------
   239 //
   257 //
   240 void CAlmAlarmControl::DoCancelDialog()
   258 void CAlmAlarmControl::DoCancelDialog()
   241 {
   259 {
   242     TRACE_ENTRY_POINT;
   260     TRACE_ENTRY_POINT;
   243     if( iGlobalNoteId != KErrNotFound )
   261 
   244     {
   262     iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
   245         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
       
   246         iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
       
   247     }
       
   248     iAlarmUtils->StopAlarmSound();
   263     iAlarmUtils->StopAlarmSound();
   249     iAlarmUtils->CancelAutoSnooze();
   264     iAlarmUtils->CancelAutoSnooze();
   250     TRACE_EXIT_POINT;
   265     TRACE_EXIT_POINT;
   251 }
   266 }
   252 
   267 
   259     TRACE_ENTRY_POINT;
   274     TRACE_ENTRY_POINT;
   260     iAskWakeup = EFalse;
   275     iAskWakeup = EFalse;
   261     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   276     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   262     if( IsState( EStateBeforeAskingWakeup ) )
   277     if( IsState( EStateBeforeAskingWakeup ) )
   263     {
   278     {
   264         HBufC* label = NULL;
   279         // HBufC* label = NULL;
   265         TBuf<1> time;
   280         // TBuf<1> time;
   266         iAlarmUtils->GetWakeupLabelL( label );
   281         // iAlarmUtils->GetWakeupLabelL( label );
   267         CleanupStack::PushL( label );
   282         // CleanupStack::PushL( label );
   268 
   283 
   269 		if(!IsVisible())
   284 /*		if(!IsVisible())
   270 		{
   285 		{
   271 			MakeVisible(ETrue);
   286 			MakeVisible(ETrue);
   272 		}
   287 		}*/
   273         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   288         // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   274         iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   289         // iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   275 
   290         SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   276         CleanupStack::PopAndDestroy( label );
   291 		iAlarmUtils->NotifierDialogController()->showAlarmAlert( alarmInfo );
       
   292 
       
   293         // CleanupStack::PopAndDestroy( label );
   277 
   294 
   278         // shutdown automatically if user doesn't react within one minute
   295         // shutdown automatically if user doesn't react within one minute
   279         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   296         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   280     }
   297     }
   281     TRACE_EXIT_POINT;
   298     TRACE_EXIT_POINT;
   356 //
   373 //
   357 void CAlmAlarmControl::StoreMissedAlarmDataL()
   374 void CAlmAlarmControl::StoreMissedAlarmDataL()
   358     {
   375     {
   359 	//Get the Calendar instance values and         	  
   376 	//Get the Calendar instance values and         	  
   360 	//Store it in the missed alarm repository
   377 	//Store it in the missed alarm repository
   361 	
   378 	/*
   362 	RPointerArray<CMissedAlarm> missedAlarmList;
   379 	RPointerArray<CMissedAlarm> missedAlarmList;
   363 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   380 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   364 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   381 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   365 	TTime startTime = instanceTime.TimeLocalL();
   382 	TTime startTime = instanceTime.TimeLocalL();
   366 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   383 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   372 	missedAlarmStore->AddL(missedAlarmList);
   389 	missedAlarmStore->AddL(missedAlarmList);
   373 		
   390 		
   374 	CleanupStack::PopAndDestroy( missedAlarmStore );
   391 	CleanupStack::PopAndDestroy( missedAlarmStore );
   375 	CleanupStack::Pop( missedAlarm );
   392 	CleanupStack::Pop( missedAlarm );
   376 	missedAlarmList.ResetAndDestroy();
   393 	missedAlarmList.ResetAndDestroy();
   377     }
   394 	*/
   378 
   395     }
   379 
       
   380 // ---------------------------------------------------------
       
   381 // Checks for calendar type alarm needed to be stored as missed alarm   
       
   382 // Stops the alarm and enters to missed alarm table. If the calendar type
       
   383 // is clock, then snoozes the alarm.
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 void CAlmAlarmControl::StopOrSnoozeAlarm()
       
   387 	{
       
   388 	
       
   389 	TRACE_ENTRY_POINT;
       
   390 	if( iAlarmUtils->IsCalendarAlarm() )
       
   391 		{	 
       
   392 		if( iAlarmUtils->IsCalendarAlarmViewer() )
       
   393 			{				 
       
   394 			iAlarmUtils->SetCalendarAlarmViewer(EFalse);		   
       
   395 			}
       
   396 		else
       
   397 			{
       
   398 			TRAP_IGNORE( StoreMissedAlarmDataL() );
       
   399 			}
       
   400 		iAlarmUtils->DoStopAlarm(); 										 
       
   401 		}
       
   402 	else
       
   403 		{		 
       
   404 		iAlarmUtils->TryToSnoozeActiveAlarm();
       
   405 		}
       
   406     	TRACE_EXIT_POINT;
       
   407 	}
       
   408 
       
   409 // ===========================================================
   396 // ===========================================================
   410 // ================ INHERITED FUNCTIONS ======================
   397 // ================ INHERITED FUNCTIONS ======================
   411 
   398 
   412 // ---------------------------------------------------------
   399 // ---------------------------------------------------------
   413 // Symbian 2nd phase constructor
   400 // Symbian 2nd phase constructor
   430     
   417     
   431     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   418     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   432     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   419     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   433     
   420     
   434 
   421 
   435     iEikonEnv->EikAppUi()->AddToStackL(
   422     /*iEikonEnv->EikAppUi()->AddToStackL(
   436         this,
   423         this,
   437         ECoeStackPriorityAlert,
   424         ECoeStackPriorityAlert,
   438         ECoeStackFlagRefusesFocus );
   425         ECoeStackFlagRefusesFocus );
   439 
   426 */
   440 	MakeVisible(EFalse);
   427 	// MakeVisible(EFalse);
   441 	SetStopFromContext(EFalse);
   428 	SetStopFromContext(EFalse);
   442     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   429     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   443 
   430 
   444     // observe "hide alarm" commands (i.e. powerkey presses)
   431     // observe "hide alarm" commands (i.e. powerkey presses)
   445     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   432     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   446 
   433 
   447     // observe system state changes
   434     // observe system state changes
   448     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   435     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   449     //For Plasma accessory handling
   436     //For Plasma accessory handling
   450     _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   437     // _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   451 	_LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   438 	// _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   452 
   439 
       
   440 	/*
   453 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   441 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   454     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   442     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   455 
   443 
   456     //observe Plasma accessory stop key changes
   444     //observe Plasma accessory stop key changes
   457     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   445     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   458 
   446 
   459     //observe Plasma accessory snooze key changes
   447     //observe Plasma accessory snooze key changes
   460     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
   448     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
       
   449 	*/
   461     //observe SysAp backlight setting PS Key
   450     //observe SysAp backlight setting PS Key
   462 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   451 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   463     TRACE_EXIT_POINT;
   452     TRACE_EXIT_POINT;
   464 }
   453 }
   465 
   454 
   501 
   490 
   502                 // Only call this within ShowAlarm to prevent updating data too early/late.
   491                 // Only call this within ShowAlarm to prevent updating data too early/late.
   503                 // (e.g. updating snooze time before showing the snooze info note)
   492                 // (e.g. updating snooze time before showing the snooze info note)
   504                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   493                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   505 
   494 
   506                 HBufC* text = NULL;
   495                 // Get the alarm information
   507 
   496                 SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   508                 if( !err )
   497                 // Get the ringing type
   509                 {
   498                 alarmInfo->iIsSilent = iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone();
   510                     TRAP( err, iAlarmUtils->GetAlarmLabelL( text ); )
   499                 // Check if the alarm can be snoozed
   511                 }
   500                 alarmInfo->iCanSnooze = iAlarmUtils->CanSnooze();
   512             	// cleanup (release global data)
   501             
   513             	iAlarmUtils->UninitialiseAlarmData();
   502                 // cleanup (release global data)
   514                 if( !err )
   503                 iAlarmUtils->UninitialiseAlarmData();
   515                 {
   504                 /*if(!IsVisible())
   516                 	if(!IsVisible())
   505                 {
   517                 	{
   506                     MakeVisible(ETrue);
   518                 		MakeVisible(ETrue);
   507                 }
   519                 	}
   508                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   520                     iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   509 
   521 
   510                 // setup CBA for the global note
   522                     // setup CBA for the global note
   511                 TUint cba(0);  // See AknDialogController.h
   523                     TUint cba(0);  // See AknDialogController.h
   512                 // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms
   524                     // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms
   513                 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   525                     cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   514                 // disable silence key when ringing type is set to "silent" or if alarm sounds is set off
   526                     // disable silence key when ringing type is set to "silent" or if alarm sounds is set off
   515                 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   527                     cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   516                 // disable silence and snooze key if alarm can't be snoozed anymore
   528                     // disable silence and snooze key if alarm can't be snoozed anymore
   517                 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   529                     cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   518                 // show "Open" MSK for calendar alarms if the security lock is not active
   530                     // show "Open" MSK for calendar alarms if the security lock is not active
   519                 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   531                     cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   520 
   532 
   521                 // request alarm dialog
   533                     // request alarm dialog
   522                 TBuf<1> time;
   534                     TBuf<1> time;
   523                 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, timenot used ) );
   535                     TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, time/*not used*/ ) );
   524                 delete text; // only delete if GetAlarmLabelL call was successfull
   536                     delete text; // only delete if GetAlarmLabelL call was successfull
   525                 ASSERT( !err ); */     
   537                     ASSERT( !err );
   526                 iAlarmUtils->NotifierDialogController()->showAlarmAlert(alarmInfo);
   538                 }
   527                 iAlarmUtils->StartAutoSnoozeTimer();
       
   528                 iAlarmUtils->PlayAlarmSound();
       
   529                 SetState( EStateWaitingInput );
   539 
   530 
   540                 if( err ) // failed to fetch alarm data or show the notification
   531                 if( err ) // failed to fetch alarm data or show the notification
   541                 {
   532                 {
   542                     // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry.
   533                     // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry.
   543                     // (or if the DisplayAlarmL call fails)
   534                     // (or if the DisplayAlarmL call fails)
   544                     // -> stop and ignore the alarm
   535                     // -> stop and ignore the alarm
   545                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   536                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   546                 }
   537                 }
       
   538                 delete alarmInfo->iLocation;
       
   539                 delete alarmInfo->iSubject;
   547             }
   540             }
   548         }
   541         }
   549         break;
   542         break;
   550 
   543 
   551         default:
   544         default:
   748         if( noPowerKey ) // end key as power key >> snooze
   741         if( noPowerKey ) // end key as power key >> snooze
   749         {
   742         {
   750             // cancel the alarm
   743             // cancel the alarm
   751             if( iGlobalNoteId != KErrNotFound )
   744             if( iGlobalNoteId != KErrNotFound )
   752             {
   745             {
   753                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   746                 // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   754                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   747                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
       
   748                 iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
   755             }
   749             }
   756         }
   750         }
   757         else // stop
   751         else // stop
   758         {
   752         {
   759             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   753             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   769         {
   763         {
   770             ShowAlarm();
   764             ShowAlarm();
   771         }
   765         }
   772     }
   766     }
   773 
   767 
       
   768 	/*
   774     //For plasma support
   769     //For plasma support
   775     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   770     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   776     {
   771     {
   777         //Set the P&S to an uninitialized value
   772         //Set the P&S to an uninitialized value
   778     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   773     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   787     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   782     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   788     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   783     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   789 
   784 
   790     	ExternalSnoozeAlarm();
   785     	ExternalSnoozeAlarm();
   791     }
   786     }
       
   787 	*/
   792 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   788 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   793 	{
   789 	{
   794 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   790 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   795 		{
   791 		{
   796 			iAlarmUtils->SetBackLight(ETrue);
   792 			iAlarmUtils->SetBackLight(ETrue);
   871                 {
   867                 {
   872                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   868                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   873 	                    {
   869 	                    {
   874                         // Do not leave if calendar launch fails. Just continue as normally
   870                         // Do not leave if calendar launch fails. Just continue as normally
   875                         iAlarmUtils->StopAlarmSound();
   871                         iAlarmUtils->StopAlarmSound();
   876                         PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   872                         // PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   877                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   873                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   878 	                    }
   874 	                    }
   879                 }
   875                 }
   880                 break;
   876                 break;
   881 
   877 
  1014         case EStateWaitingShowRequest:
  1010         case EStateWaitingShowRequest:
  1015         case EStateWaitingDisplayRequest:
  1011         case EStateWaitingDisplayRequest:
  1016         case EStateWaitingInput:
  1012         case EStateWaitingInput:
  1017         {
  1013         {
  1018             SetState( EStateIdle );
  1014             SetState( EStateIdle );
  1019 	          DoCancelDialog();
  1015             DoCancelDialog();
  1020             StopOrSnoozeAlarm();
  1016             iAlarmUtils->TryToSnoozeActiveAlarm();
  1021         }
  1017         }
  1022         break;
  1018         break;
  1023 
  1019 
  1024         case EStateBeforeAskingWakeup:
  1020         case EStateBeforeAskingWakeup:
  1025         case EStateAskingWakeup:
  1021         case EStateAskingWakeup:
  1121 
  1117 
  1122             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1118             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1123             {
  1119             {
  1124                 // Normally pressing End Call key generates CancelDialog callback, but
  1120                 // Normally pressing End Call key generates CancelDialog callback, but
  1125                 // when we have an active call we don't get the CancelDialog...
  1121                 // when we have an active call we don't get the CancelDialog...
  1126                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1122                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1127                 TRACE_EXIT_POINT;
  1123                 TRACE_EXIT_POINT;
  1128                 return EKeyWasNotConsumed;
  1124                 return EKeyWasNotConsumed;
  1129             }
  1125             }
  1130 
  1126 
  1131             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1127             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1174 // ---------------------------------------------------------
  1170 // ---------------------------------------------------------
  1175 //
  1171 //
  1176 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1172 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1177 {
  1173 {
  1178     TRACE_ENTRY_POINT;
  1174     TRACE_ENTRY_POINT;
  1179 
  1175 /*
  1180     //Changes for MPIN-73VCR2
  1176     //Changes for MPIN-73VCR2
  1181    HBufC* stringHolder = NULL;
  1177    HBufC* stringHolder = NULL;
  1182    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1178    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1183    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1179    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1184 
  1180 
  1222     }
  1218     }
  1223     else
  1219     else
  1224     {
  1220     {
  1225         SetState( EStateIdle );
  1221         SetState( EStateIdle );
  1226     }
  1222     }
       
  1223 	*/
  1227     TRACE_EXIT_POINT;
  1224     TRACE_EXIT_POINT;
  1228 }
  1225 }
  1229 
  1226 
  1230 // ---------------------------------------------------------
  1227 // ---------------------------------------------------------
  1231 // Stops an active alarm.
  1228 // Stops an active alarm.
  1320 //
  1317 //
  1321  TBool CAlmAlarmControl::IsStopFromContext()
  1318  TBool CAlmAlarmControl::IsStopFromContext()
  1322  {
  1319  {
  1323  	return iStopFromContextFw;
  1320  	return iStopFromContextFw;
  1324  }
  1321  }
       
  1322  
       
  1323  void CAlmAlarmControl::alertCompleted(AlarmCommand command)
       
  1324  {
       
  1325      // cancel timers
       
  1326      iAlarmUtils->CancelAutoSnooze();
       
  1327      iAlarmUtils->StopAlarmSound();
       
  1328 
       
  1329      switch( iState )
       
  1330          {
       
  1331          /**
       
  1332           * EStateWaitingInput: normal case
       
  1333           * EStateWaitingDisplayRequest:
       
  1334           *     This happens only if the global note got handled before we got the DisplayDialogL call.
       
  1335           *     (e.g. note is dismissed if the cover is closed at the same time when alarm expires)
       
  1336           **/
       
  1337          case EStateWaitingInput:
       
  1338          case EStateWaitingDisplayRequest:
       
  1339              {
       
  1340              switch( command )
       
  1341                  {
       
  1342                  case AlarmStop:
       
  1343                      {
       
  1344                      SetState( EStateAfterInput );
       
  1345                      iAskWakeup = ETrue; // ask wakeup after all the alarms are handled
       
  1346                      iAlarmUtils->DoStopAlarm();  // stop
       
  1347                      break;
       
  1348                      }
       
  1349                  case AlarmSnooze:
       
  1350                      {
       
  1351                      SetState( EStateAfterInput );
       
  1352 
       
  1353                      SetState( EStateShowingSnoozeInfo );
       
  1354                      iAlarmUtils->TryToSnoozeActiveAlarm();
       
  1355                      if( IsState( EStateWaitingShowRequest ) )
       
  1356                          {
       
  1357                          ShowAlarm();
       
  1358                          }
       
  1359                      else
       
  1360                          {
       
  1361                          SetState( EStateIdle );
       
  1362                          }
       
  1363                      }
       
  1364                  }
       
  1365              }
       
  1366          break;
       
  1367          }  
       
  1368      TRACE_EXIT_POINT;
       
  1369  }
       
  1370  
       
  1371  void CAlmAlarmControl::alertDisplayed(AlarmCommand /*command*/)
       
  1372  {
       
  1373      TRACE_ENTRY_POINT;
       
  1374      switch( iState )
       
  1375      {
       
  1376          case EStateWaitingDisplayRequest:
       
  1377          {
       
  1378              iAlarmUtils->StartAutoSnoozeTimer();
       
  1379              iAlarmUtils->PlayAlarmSound();
       
  1380              iAlarmUtils->SetKeyGuard( EFalse );
       
  1381              SetState( EStateWaitingInput );
       
  1382              iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
       
  1383          }
       
  1384          break;
       
  1385 
       
  1386          case EStateBeforeAskingWakeup:
       
  1387          {
       
  1388              SetState( EStateAskingWakeup );
       
  1389          }
       
  1390          break;
       
  1391 
       
  1392          default:
       
  1393          {
       
  1394              // panic - invalid state!
       
  1395              Panic( EAlarmUIInvalidState | EAlarmUIDisplayDialog );
       
  1396          }
       
  1397      }
       
  1398  }
       
  1399  
       
  1400  void CAlmAlarmControl::alertCancelled(AlarmCommand /*command*/)
       
  1401  {
       
  1402      iAlarmUtils->StopAlarmSound();
       
  1403      iAlarmUtils->CancelAutoSnooze();
       
  1404  }
  1325 
  1405 
  1326 // End of File
  1406 // End of File