alarmui/src/AlmAlarmControl.cpp
branchRCL_3
changeset 29 12af337248b1
parent 18 d68a4b5d5885
child 30 bd7edf625bdd
equal deleted inserted replaced
28:96907930389d 29:12af337248b1
    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 
   174                 * (try to prevent accidental key presses from going through the key or security lock)
   175                 * (try to prevent accidental key presses from going through the key or security lock)
   175                 */
   176                 */
   176                 iAlarmUtils->StartKeyBlocker();
   177                 iAlarmUtils->StartKeyBlocker();
   177 
   178 
   178                 // reset the key guard
   179                 // reset the key guard
   179                 iAlarmUtils->SetKeyGuard( ETrue );
   180                 //iAlarmUtils->SetKeyGuard( ETrue );
   180             }
   181             }
   181 
   182 
   182             break;
   183             break;
   183         }
   184         }
   184 
   185 
   224     iAlarmUtils->CancelAutoSnooze();
   225     iAlarmUtils->CancelAutoSnooze();
   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         iAlarmUtils->TryToSnoozeActiveAlarm();
   231 	 DoCancelDialog();
   232         DoCancelDialog();        
   232         }
   233         }
   233     TRACE_EXIT_POINT;
   234     TRACE_EXIT_POINT;
   234     }
   235     }
   235 
   236 
   236 // ---------------------------------------------------------
   237 // ---------------------------------------------------------
   238 // ---------------------------------------------------------
   239 // ---------------------------------------------------------
   239 //
   240 //
   240 void CAlmAlarmControl::DoCancelDialog()
   241 void CAlmAlarmControl::DoCancelDialog()
   241 {
   242 {
   242     TRACE_ENTRY_POINT;
   243     TRACE_ENTRY_POINT;
   243     if( iGlobalNoteId != KErrNotFound )
   244     /*if( iGlobalNoteId != KErrNotFound )
   244     {
   245     {
   245         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   246         // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   246         iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   247         // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   247     }
   248         iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
       
   249     }*/
       
   250     iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
   248     iAlarmUtils->StopAlarmSound();
   251     iAlarmUtils->StopAlarmSound();
   249     iAlarmUtils->CancelAutoSnooze();
   252     iAlarmUtils->CancelAutoSnooze();
   250     TRACE_EXIT_POINT;
   253     TRACE_EXIT_POINT;
   251 }
   254 }
   252 
   255 
   259     TRACE_ENTRY_POINT;
   262     TRACE_ENTRY_POINT;
   260     iAskWakeup = EFalse;
   263     iAskWakeup = EFalse;
   261     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   264     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   262     if( IsState( EStateBeforeAskingWakeup ) )
   265     if( IsState( EStateBeforeAskingWakeup ) )
   263     {
   266     {
   264         HBufC* label = NULL;
   267         // HBufC* label = NULL;
   265         TBuf<1> time;
   268         // TBuf<1> time;
   266         iAlarmUtils->GetWakeupLabelL( label );
   269         // iAlarmUtils->GetWakeupLabelL( label );
   267         CleanupStack::PushL( label );
   270         // CleanupStack::PushL( label );
   268 
   271 
   269 		if(!IsVisible())
   272 /*		if(!IsVisible())
   270 		{
   273 		{
   271 			MakeVisible(ETrue);
   274 			MakeVisible(ETrue);
   272 		}
   275 		}*/
   273         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   276         // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   274         iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   277         // iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   275 
   278         SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   276         CleanupStack::PopAndDestroy( label );
   279 		iAlarmUtils->NotifierDialogController()->showAlarmAlert( alarmInfo );
       
   280 
       
   281         // CleanupStack::PopAndDestroy( label );
   277 
   282 
   278         // shutdown automatically if user doesn't react within one minute
   283         // shutdown automatically if user doesn't react within one minute
   279         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   284         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   280     }
   285     }
   281     TRACE_EXIT_POINT;
   286     TRACE_EXIT_POINT;
   356 //
   361 //
   357 void CAlmAlarmControl::StoreMissedAlarmDataL()
   362 void CAlmAlarmControl::StoreMissedAlarmDataL()
   358     {
   363     {
   359 	//Get the Calendar instance values and         	  
   364 	//Get the Calendar instance values and         	  
   360 	//Store it in the missed alarm repository
   365 	//Store it in the missed alarm repository
   361 	
   366 	/*
   362 	RPointerArray<CMissedAlarm> missedAlarmList;
   367 	RPointerArray<CMissedAlarm> missedAlarmList;
   363 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   368 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   364 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   369 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   365 	TTime startTime = instanceTime.TimeLocalL();
   370 	TTime startTime = instanceTime.TimeLocalL();
   366 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   371 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   372 	missedAlarmStore->AddL(missedAlarmList);
   377 	missedAlarmStore->AddL(missedAlarmList);
   373 		
   378 		
   374 	CleanupStack::PopAndDestroy( missedAlarmStore );
   379 	CleanupStack::PopAndDestroy( missedAlarmStore );
   375 	CleanupStack::Pop( missedAlarm );
   380 	CleanupStack::Pop( missedAlarm );
   376 	missedAlarmList.ResetAndDestroy();
   381 	missedAlarmList.ResetAndDestroy();
   377     }
   382 	*/
   378 
   383     }
   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 // ===========================================================
   384 // ===========================================================
   410 // ================ INHERITED FUNCTIONS ======================
   385 // ================ INHERITED FUNCTIONS ======================
   411 
   386 
   412 // ---------------------------------------------------------
   387 // ---------------------------------------------------------
   413 // Symbian 2nd phase constructor
   388 // Symbian 2nd phase constructor
   430     
   405     
   431     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   406     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   432     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   407     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   433     
   408     
   434 
   409 
   435     iEikonEnv->EikAppUi()->AddToStackL(
   410     /*iEikonEnv->EikAppUi()->AddToStackL(
   436         this,
   411         this,
   437         ECoeStackPriorityAlert,
   412         ECoeStackPriorityAlert,
   438         ECoeStackFlagRefusesFocus );
   413         ECoeStackFlagRefusesFocus );
   439 
   414 */
   440 	MakeVisible(EFalse);
   415 	// MakeVisible(EFalse);
   441 	SetStopFromContext(EFalse);
   416 	SetStopFromContext(EFalse);
   442     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   417     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   443 
   418 
   444     // observe "hide alarm" commands (i.e. powerkey presses)
   419     // observe "hide alarm" commands (i.e. powerkey presses)
   445     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   420     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   446 
   421 
   447     // observe system state changes
   422     // observe system state changes
   448     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   423     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   449     //For Plasma accessory handling
   424     //For Plasma accessory handling
   450     _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   425     // _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   451 	_LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   426 	// _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   452 
   427 
       
   428 	/*
   453 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   429 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   454     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   430     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   455 
   431 
   456     //observe Plasma accessory stop key changes
   432     //observe Plasma accessory stop key changes
   457     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   433     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   458 
   434 
   459     //observe Plasma accessory snooze key changes
   435     //observe Plasma accessory snooze key changes
   460     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
   436     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
       
   437 	*/
   461     //observe SysAp backlight setting PS Key
   438     //observe SysAp backlight setting PS Key
   462 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   439 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   463     TRACE_EXIT_POINT;
   440     TRACE_EXIT_POINT;
   464 }
   441 }
   465 
   442 
   501 
   478 
   502                 // Only call this within ShowAlarm to prevent updating data too early/late.
   479                 // Only call this within ShowAlarm to prevent updating data too early/late.
   503                 // (e.g. updating snooze time before showing the snooze info note)
   480                 // (e.g. updating snooze time before showing the snooze info note)
   504                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   481                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   505 
   482 
   506                 HBufC* text = NULL;
   483                 // Get the alarm information
   507 
   484                 SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   508                 if( !err )
   485                 // Get the ringing type
   509                 {
   486                 alarmInfo->iIsSilent = iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone();
   510                     TRAP( err, iAlarmUtils->GetAlarmLabelL( text ); )
   487                 // Check if the alarm can be snoozed
   511                 }
   488                 alarmInfo->iCanSnooze = iAlarmUtils->CanSnooze();
   512             	// cleanup (release global data)
   489             
   513             	iAlarmUtils->UninitialiseAlarmData();
   490                 // cleanup (release global data)
   514                 if( !err )
   491                 iAlarmUtils->UninitialiseAlarmData();
   515                 {
   492                 /*if(!IsVisible())
   516                 	if(!IsVisible())
   493                 {
   517                 	{
   494                     MakeVisible(ETrue);
   518                 		MakeVisible(ETrue);
   495                 }
   519                 	}
   496                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   520                     iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   497 
   521 
   498                 // setup CBA for the global note
   522                     // setup CBA for the global note
   499                 TUint cba(0);  // See AknDialogController.h
   523                     TUint cba(0);  // See AknDialogController.h
   500                 // 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
   501                 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   525                     cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   502                 // 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
   503                 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   527                     cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   504                 // 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
   505                 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   529                     cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   506                 // 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
   507                 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   531                     cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   508 
   532 
   509                 // request alarm dialog
   533                     // request alarm dialog
   510                 TBuf<1> time;
   534                     TBuf<1> time;
   511                 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, timenot used ) );
   535                     TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, time/*not used*/ ) );
   512                 delete text; // only delete if GetAlarmLabelL call was successfull
   536                     delete text; // only delete if GetAlarmLabelL call was successfull
   513                 ASSERT( !err ); */     
   537                     ASSERT( !err );
   514                 iAlarmUtils->NotifierDialogController()->showAlarmAlert(alarmInfo);
   538                 }
   515                 //iAlarmUtils->StartAutoSnoozeTimer();
       
   516                 //iAlarmUtils->PlayAlarmSound();
       
   517                 //SetState( EStateWaitingInput );
   539 
   518 
   540                 if( err ) // failed to fetch alarm data or show the notification
   519                 if( err ) // failed to fetch alarm data or show the notification
   541                 {
   520                 {
   542                     // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry.
   521                     // 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)
   522                     // (or if the DisplayAlarmL call fails)
   544                     // -> stop and ignore the alarm
   523                     // -> stop and ignore the alarm
   545                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   524                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   546                 }
   525                 }
       
   526                 delete alarmInfo->iLocation;
       
   527                 delete alarmInfo->iSubject;
   547             }
   528             }
   548         }
   529         }
   549         break;
   530         break;
   550 
   531 
   551         default:
   532         default:
   748         if( noPowerKey ) // end key as power key >> snooze
   729         if( noPowerKey ) // end key as power key >> snooze
   749         {
   730         {
   750             // cancel the alarm
   731             // cancel the alarm
   751             if( iGlobalNoteId != KErrNotFound )
   732             if( iGlobalNoteId != KErrNotFound )
   752             {
   733             {
   753                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   734                 // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   754                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   735                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
       
   736                 iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
   755             }
   737             }
   756         }
   738         }
   757         else // stop
   739         else // stop
   758         {
   740         {
   759             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   741             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   769         {
   751         {
   770             ShowAlarm();
   752             ShowAlarm();
   771         }
   753         }
   772     }
   754     }
   773 
   755 
       
   756 	/*
   774     //For plasma support
   757     //For plasma support
   775     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   758     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   776     {
   759     {
   777         //Set the P&S to an uninitialized value
   760         //Set the P&S to an uninitialized value
   778     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   761     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   787     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   770     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   788     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   771     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   789 
   772 
   790     	ExternalSnoozeAlarm();
   773     	ExternalSnoozeAlarm();
   791     }
   774     }
       
   775 	*/
   792 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   776 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   793 	{
   777 	{
   794 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   778 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   795 		{
   779 		{
   796 			iAlarmUtils->SetBackLight(ETrue);
   780 			iAlarmUtils->SetBackLight(ETrue);
   871                 {
   855                 {
   872                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   856                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   873 	                    {
   857 	                    {
   874                         // Do not leave if calendar launch fails. Just continue as normally
   858                         // Do not leave if calendar launch fails. Just continue as normally
   875                         iAlarmUtils->StopAlarmSound();
   859                         iAlarmUtils->StopAlarmSound();
   876                         PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   860                         // PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   877                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   861                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   878 	                    }
   862 	                    }
   879                 }
   863                 }
   880                 break;
   864                 break;
   881 
   865 
   959     {
   943     {
   960         case EStateWaitingDisplayRequest:
   944         case EStateWaitingDisplayRequest:
   961         {
   945         {
   962             iAlarmUtils->StartAutoSnoozeTimer();
   946             iAlarmUtils->StartAutoSnoozeTimer();
   963             iAlarmUtils->PlayAlarmSound();
   947             iAlarmUtils->PlayAlarmSound();
   964             iAlarmUtils->SetKeyGuard( EFalse );
   948             //iAlarmUtils->SetKeyGuard( EFalse );
   965             SetState( EStateWaitingInput );
   949             SetState( EStateWaitingInput );
   966             iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
   950             iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
   967         }
   951         }
   968         break;
   952         break;
   969 
   953 
  1014         case EStateWaitingShowRequest:
   998         case EStateWaitingShowRequest:
  1015         case EStateWaitingDisplayRequest:
   999         case EStateWaitingDisplayRequest:
  1016         case EStateWaitingInput:
  1000         case EStateWaitingInput:
  1017         {
  1001         {
  1018             SetState( EStateIdle );
  1002             SetState( EStateIdle );
  1019 	          DoCancelDialog();
  1003             DoCancelDialog();
  1020             StopOrSnoozeAlarm();
  1004             iAlarmUtils->TryToSnoozeActiveAlarm();
  1021         }
  1005         }
  1022         break;
  1006         break;
  1023 
  1007 
  1024         case EStateBeforeAskingWakeup:
  1008         case EStateBeforeAskingWakeup:
  1025         case EStateAskingWakeup:
  1009         case EStateAskingWakeup:
  1121 
  1105 
  1122             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1106             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1123             {
  1107             {
  1124                 // Normally pressing End Call key generates CancelDialog callback, but
  1108                 // Normally pressing End Call key generates CancelDialog callback, but
  1125                 // when we have an active call we don't get the CancelDialog...
  1109                 // when we have an active call we don't get the CancelDialog...
  1126                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1110                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1127                 TRACE_EXIT_POINT;
  1111                 TRACE_EXIT_POINT;
  1128                 return EKeyWasNotConsumed;
  1112                 return EKeyWasNotConsumed;
  1129             }
  1113             }
  1130 
  1114 
  1131             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1115             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1174 // ---------------------------------------------------------
  1158 // ---------------------------------------------------------
  1175 //
  1159 //
  1176 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1160 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1177 {
  1161 {
  1178     TRACE_ENTRY_POINT;
  1162     TRACE_ENTRY_POINT;
  1179 
  1163 /*
  1180     //Changes for MPIN-73VCR2
  1164     //Changes for MPIN-73VCR2
  1181    HBufC* stringHolder = NULL;
  1165    HBufC* stringHolder = NULL;
  1182    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1166    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1183    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1167    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1184 
  1168 
  1222     }
  1206     }
  1223     else
  1207     else
  1224     {
  1208     {
  1225         SetState( EStateIdle );
  1209         SetState( EStateIdle );
  1226     }
  1210     }
       
  1211 	*/
  1227     TRACE_EXIT_POINT;
  1212     TRACE_EXIT_POINT;
  1228 }
  1213 }
  1229 
  1214 
  1230 // ---------------------------------------------------------
  1215 // ---------------------------------------------------------
  1231 // Stops an active alarm.
  1216 // Stops an active alarm.
  1320 //
  1305 //
  1321  TBool CAlmAlarmControl::IsStopFromContext()
  1306  TBool CAlmAlarmControl::IsStopFromContext()
  1322  {
  1307  {
  1323  	return iStopFromContextFw;
  1308  	return iStopFromContextFw;
  1324  }
  1309  }
  1325 
  1310  
  1326  CAlarmUtils* CAlmAlarmControl::AlarmUtils() const
  1311  void CAlmAlarmControl::alertCompleted(AlarmCommand command)
       
  1312  {
       
  1313      //iAlarmUtils->CancelShutdown();
       
  1314      iAlarmUtils->StopAlarmSound();
       
  1315 
       
  1316      switch( iState )
       
  1317          {
       
  1318          /**
       
  1319           * EStateWaitingInput: normal case
       
  1320           * EStateWaitingDisplayRequest:
       
  1321           *     This happens only if the global note got handled before we got the DisplayDialogL call.
       
  1322           *     (e.g. note is dismissed if the cover is closed at the same time when alarm expires)
       
  1323           **/
       
  1324          case EStateWaitingInput:
       
  1325          case EStateWaitingDisplayRequest:
       
  1326              {
       
  1327              switch( command )
       
  1328                  {
       
  1329                  case AlarmStop:
       
  1330                      {
       
  1331                      SetState( EStateAfterInput );
       
  1332 					 // cancel timers
       
  1333 					 iAlarmUtils->CancelAutoSnooze();
       
  1334                      iAskWakeup = ETrue; // ask wakeup after all the alarms are handled
       
  1335                      iAlarmUtils->DoStopAlarm();  // stop
       
  1336                      break;
       
  1337                      }
       
  1338                  case AlarmSnooze:
       
  1339                      {
       
  1340                      // cancel timers
       
  1341 					 iAlarmUtils->CancelAutoSnooze();
       
  1342 					 SetState( EStateAfterInput );
       
  1343 
       
  1344                      SetState( EStateShowingSnoozeInfo );
       
  1345                      iAlarmUtils->TryToSnoozeActiveAlarm();
       
  1346                      if( IsState( EStateWaitingShowRequest ) )
       
  1347                          {
       
  1348                          ShowAlarm();
       
  1349                          }
       
  1350                      else
       
  1351                          {
       
  1352                          SetState( EStateIdle );
       
  1353                          }
       
  1354                      }
       
  1355                  }
       
  1356              }
       
  1357          break;
       
  1358          }  
       
  1359      TRACE_EXIT_POINT;
       
  1360  }
       
  1361  
       
  1362  void CAlmAlarmControl::alertDisplayed(AlarmCommand /*command*/)
       
  1363  {
       
  1364      TRACE_ENTRY_POINT;
       
  1365      switch( iState )
  1327      {
  1366      {
  1328      return iAlarmUtils;
  1367          case EStateWaitingDisplayRequest:
       
  1368          {
       
  1369              iAlarmUtils->StartAutoSnoozeTimer();
       
  1370              iAlarmUtils->PlayAlarmSound();
       
  1371              //iAlarmUtils->SetKeyGuard( EFalse );
       
  1372              SetState( EStateWaitingInput );
       
  1373              iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
       
  1374          }
       
  1375          break;
       
  1376 
       
  1377          case EStateBeforeAskingWakeup:
       
  1378          {
       
  1379              SetState( EStateAskingWakeup );
       
  1380          }
       
  1381          break;
       
  1382 
       
  1383          default:
       
  1384          {
       
  1385              // panic - invalid state!
       
  1386              Panic( EAlarmUIInvalidState | EAlarmUIDisplayDialog );
       
  1387          }
  1329      }
  1388      }
  1330  // End of File
  1389  }
  1331  
  1390  
       
  1391  void CAlmAlarmControl::alertCancelled(AlarmCommand /*command*/)
       
  1392  {
       
  1393      iAlarmUtils->StopAlarmSound();
       
  1394      iAlarmUtils->CancelAutoSnooze();
       
  1395  }
       
  1396 
       
  1397 // End of File