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