alarmui/src/AlmAlarmControl.cpp
changeset 89 b57382753122
parent 45 b6db4fd4947b
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
    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 
    50 const TUint KAlarmAutoShutdown( 60000000 );  // 60 s
    49 const TUint KAlarmAutoShutdown( 60000000 );  // 60 s
    51 const TUint KShutdownTime( 1500000 ); // 1.5 s
    50 const TUint KShutdownTime( 1500000 ); // 1.5 s
       
    51 
       
    52 const TInt KErrDuplicateAlarm( -1001 ); // error code
       
    53 
    52 
    54 
    53 // ==========================================================
    55 // ==========================================================
    54 // ================= MEMBER FUNCTIONS =======================
    56 // ================= MEMBER FUNCTIONS =======================
    55 
    57 
    56 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
   175                 * (try to prevent accidental key presses from going through the key or security lock)
   177                 * (try to prevent accidental key presses from going through the key or security lock)
   176                 */
   178                 */
   177                 iAlarmUtils->StartKeyBlocker();
   179                 iAlarmUtils->StartKeyBlocker();
   178 
   180 
   179                 // reset the key guard
   181                 // reset the key guard
   180                 //iAlarmUtils->SetKeyGuard( ETrue );
   182                 iAlarmUtils->SetKeyGuard( ETrue );
   181             }
   183             }
   182 
   184 
   183             break;
   185             break;
   184         }
   186         }
   185 
   187 
   225     iAlarmUtils->CancelAutoSnooze();
   227     iAlarmUtils->CancelAutoSnooze();
   226 
   228 
   227     // Allow auto-snooze only while waiting user input
   229     // Allow auto-snooze only while waiting user input
   228     if( IsState( EStateWaitingInput ) )
   230     if( IsState( EStateWaitingInput ) )
   229         {
   231         {
   230         SetState( EStateAfterInput );       
   232         SetState( EStateAfterInput );
   231         iAlarmUtils->TryToSnoozeActiveAlarm();
   233 	 StopOrSnoozeAlarm();
   232         DoCancelDialog();        
   234 	 DoCancelDialog();
   233         }
   235         }
   234     TRACE_EXIT_POINT;
   236     TRACE_EXIT_POINT;
   235     }
   237     }
   236 
   238 
   237 // ---------------------------------------------------------
   239 // ---------------------------------------------------------
   239 // ---------------------------------------------------------
   241 // ---------------------------------------------------------
   240 //
   242 //
   241 void CAlmAlarmControl::DoCancelDialog()
   243 void CAlmAlarmControl::DoCancelDialog()
   242 {
   244 {
   243     TRACE_ENTRY_POINT;
   245     TRACE_ENTRY_POINT;
   244     /*if( iGlobalNoteId != KErrNotFound )
   246     if( iGlobalNoteId != KErrNotFound )
   245     {
   247     {
   246         // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   248         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   247         // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   249         iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   248         iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
   250     }
   249     }*/
       
   250     iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
       
   251     iAlarmUtils->StopAlarmSound();
   251     iAlarmUtils->StopAlarmSound();
   252     iAlarmUtils->CancelAutoSnooze();
   252     iAlarmUtils->CancelAutoSnooze();
   253     TRACE_EXIT_POINT;
   253     TRACE_EXIT_POINT;
   254 }
   254 }
   255 
   255 
   262     TRACE_ENTRY_POINT;
   262     TRACE_ENTRY_POINT;
   263     iAskWakeup = EFalse;
   263     iAskWakeup = EFalse;
   264     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   264     ASSERT( IsState( EStateBeforeAskingWakeup ) );
   265     if( IsState( EStateBeforeAskingWakeup ) )
   265     if( IsState( EStateBeforeAskingWakeup ) )
   266     {
   266     {
   267         // HBufC* label = NULL;
   267         HBufC* label = NULL;
   268         // TBuf<1> time;
   268         TBuf<1> time;
   269         // iAlarmUtils->GetWakeupLabelL( label );
   269         iAlarmUtils->GetWakeupLabelL( label );
   270         // CleanupStack::PushL( label );
   270         CleanupStack::PushL( label );
   271 
   271 
   272 /*		if(!IsVisible())
   272 		if(!IsVisible())
   273 		{
   273 		{
   274 			MakeVisible(ETrue);
   274 			MakeVisible(ETrue);
   275 		}*/
   275 		}
   276         // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   276         iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   277         // iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   277         iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ );
   278         SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   278 
   279 		iAlarmUtils->NotifierDialogController()->showAlarmAlert( alarmInfo );
   279         CleanupStack::PopAndDestroy( label );
   280 
       
   281         // CleanupStack::PopAndDestroy( label );
       
   282 
   280 
   283         // shutdown automatically if user doesn't react within one minute
   281         // shutdown automatically if user doesn't react within one minute
   284         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   282         iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown );
   285     }
   283     }
   286     TRACE_EXIT_POINT;
   284     TRACE_EXIT_POINT;
   361 //
   359 //
   362 void CAlmAlarmControl::StoreMissedAlarmDataL()
   360 void CAlmAlarmControl::StoreMissedAlarmDataL()
   363     {
   361     {
   364 	//Get the Calendar instance values and         	  
   362 	//Get the Calendar instance values and         	  
   365 	//Store it in the missed alarm repository
   363 	//Store it in the missed alarm repository
   366 	/*
   364 	
   367 	RPointerArray<CMissedAlarm> missedAlarmList;
   365 	RPointerArray<CMissedAlarm> missedAlarmList;
   368 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   366 	TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid;
   369 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   367 	TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime;
   370 	TTime startTime = instanceTime.TimeLocalL();
   368 	TTime startTime = instanceTime.TimeLocalL();
   371 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   369 	CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime,
   377 	missedAlarmStore->AddL(missedAlarmList);
   375 	missedAlarmStore->AddL(missedAlarmList);
   378 		
   376 		
   379 	CleanupStack::PopAndDestroy( missedAlarmStore );
   377 	CleanupStack::PopAndDestroy( missedAlarmStore );
   380 	CleanupStack::Pop( missedAlarm );
   378 	CleanupStack::Pop( missedAlarm );
   381 	missedAlarmList.ResetAndDestroy();
   379 	missedAlarmList.ResetAndDestroy();
   382 	*/
   380     }
   383     }
   381 
       
   382 
       
   383 // ---------------------------------------------------------
       
   384 // Checks for calendar type alarm needed to be stored as missed alarm   
       
   385 // Stops the alarm and enters to missed alarm table. If the calendar type
       
   386 // is clock, then snoozes the alarm.
       
   387 // ---------------------------------------------------------
       
   388 //
       
   389 void CAlmAlarmControl::StopOrSnoozeAlarm()
       
   390 	{
       
   391 	
       
   392 	TRACE_ENTRY_POINT;
       
   393 	if( iAlarmUtils->IsCalendarAlarm() )
       
   394 		{	 
       
   395 		if( iAlarmUtils->IsCalendarAlarmViewer() )
       
   396 			{				 
       
   397 			iAlarmUtils->SetCalendarAlarmViewer(EFalse);		   
       
   398 			}
       
   399 		else
       
   400 			{
       
   401 			TRAP_IGNORE( StoreMissedAlarmDataL() );
       
   402 			}
       
   403 		iAlarmUtils->DoStopAlarm(); 										 
       
   404 		}
       
   405 	else
       
   406 		{		 
       
   407 		iAlarmUtils->TryToSnoozeActiveAlarm();
       
   408 		}
       
   409     	TRACE_EXIT_POINT;
       
   410 	}
       
   411 
   384 // ===========================================================
   412 // ===========================================================
   385 // ================ INHERITED FUNCTIONS ======================
   413 // ================ INHERITED FUNCTIONS ======================
   386 
   414 
   387 // ---------------------------------------------------------
   415 // ---------------------------------------------------------
   388 // Symbian 2nd phase constructor
   416 // Symbian 2nd phase constructor
   405     
   433     
   406     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   434     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile );
   407     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   435     iResOffset = iEikonEnv->AddResourceFileL( resFile );
   408     
   436     
   409 
   437 
   410     /*iEikonEnv->EikAppUi()->AddToStackL(
   438     iEikonEnv->EikAppUi()->AddToStackL(
   411         this,
   439         this,
   412         ECoeStackPriorityAlert,
   440         ECoeStackPriorityAlert,
   413         ECoeStackFlagRefusesFocus );
   441         ECoeStackFlagRefusesFocus );
   414 */
   442 
   415 	// MakeVisible(EFalse);
   443 	MakeVisible(EFalse);
   416 	SetStopFromContext(EFalse);
   444 	SetStopFromContext(EFalse);
   417     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   445     iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor );
   418 
   446 
   419     // observe "hide alarm" commands (i.e. powerkey presses)
   447     // observe "hide alarm" commands (i.e. powerkey presses)
   420     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   448     iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm );
   421 
   449 
   422     // observe system state changes
   450     // observe system state changes
   423     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   451     iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState );
   424     //For Plasma accessory handling
   452     //For Plasma accessory handling
   425     // _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   453     _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy );
   426 	// _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   454 	_LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData );
   427 
   455 
   428 	/*
       
   429 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   456 	RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   430     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   457     RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy );
   431 
   458 
   432     //observe Plasma accessory stop key changes
   459     //observe Plasma accessory stop key changes
   433     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   460     iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey);
   434 
   461 
   435     //observe Plasma accessory snooze key changes
   462     //observe Plasma accessory snooze key changes
   436     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
   463     iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey);
   437 	*/
       
   438     //observe SysAp backlight setting PS Key
   464     //observe SysAp backlight setting PS Key
   439 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   465 	iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive);
   440     TRACE_EXIT_POINT;
   466     TRACE_EXIT_POINT;
   441 }
   467 }
   442 
   468 
   478 
   504 
   479                 // Only call this within ShowAlarm to prevent updating data too early/late.
   505                 // Only call this within ShowAlarm to prevent updating data too early/late.
   480                 // (e.g. updating snooze time before showing the snooze info note)
   506                 // (e.g. updating snooze time before showing the snooze info note)
   481                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   507                 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); )
   482 
   508 
   483                 // Get the alarm information
   509                 HBufC* text = NULL;
   484                 SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo();
   510 
   485                 // Get the ringing type
   511 				if(!err && iAlarmUtils->CheckForDuplicateAlarm())
   486                 alarmInfo->iIsSilent = iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone();
   512 					{
   487                 // Check if the alarm can be snoozed
   513 					err = KErrDuplicateAlarm;
   488                 alarmInfo->iCanSnooze = iAlarmUtils->CanSnooze();
   514 					}
   489             
   515 				
   490                 // cleanup (release global data)
   516                 if( !err )
   491                 iAlarmUtils->UninitialiseAlarmData();
   517                 {
   492                 /*if(!IsVisible())
   518                     TRAP( err, iAlarmUtils->GetAlarmLabelL( text ); )
   493                 {
   519                 }
   494                     MakeVisible(ETrue);
   520             	// cleanup (release global data)
   495                 }
   521             	iAlarmUtils->UninitialiseAlarmData();
   496                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   522                 if( !err )
   497 
   523                 {
   498                 // setup CBA for the global note
   524                 	if(!IsVisible())
   499                 TUint cba(0);  // See AknDialogController.h
   525                 	{
   500                 // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms
   526                 		MakeVisible(ETrue);
   501                 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   527                 	}
   502                 // disable silence key when ringing type is set to "silent" or if alarm sounds is set off
   528                     iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   503                 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   529 
   504                 // disable silence and snooze key if alarm can't be snoozed anymore
   530                     // setup CBA for the global note
   505                 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   531                     TUint cba(0);  // See AknDialogController.h
   506                 // show "Open" MSK for calendar alarms if the security lock is not active
   532                     // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms
   507                 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   533                     cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm;
   508 
   534                     // disable silence key when ringing type is set to "silent" or if alarm sounds is set off
   509                 // request alarm dialog
   535                     cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0;
   510                 TBuf<1> time;
   536                     // disable silence and snooze key if alarm can't be snoozed anymore
   511                 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, timenot used ) );
   537                     cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence;
   512                 delete text; // only delete if GetAlarmLabelL call was successfull
   538                     // show "Open" MSK for calendar alarms if the security lock is not active
   513                 ASSERT( !err ); */     
   539                     cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0;
   514                 iAlarmUtils->NotifierDialogController()->showAlarmAlert(alarmInfo);
   540 					                  
   515                 //iAlarmUtils->StartAutoSnoozeTimer();
   541 					if(iAlarmUtils->IsCalendarAlarm())
   516                 //iAlarmUtils->PlayAlarmSound();
   542                         {
   517                 //SetState( EStateWaitingInput );
   543                     	iAlarmUtils->StoreCurrentCalendarAlarmData();
       
   544 						}
       
   545                     // request alarm dialog
       
   546                     TBuf<1> time;
       
   547                     TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, time/*not used*/ ) );
       
   548                     delete text; // only delete if GetAlarmLabelL call was successfull
       
   549                     ASSERT( !err );
       
   550                 }
   518 
   551 
   519                 if( err ) // failed to fetch alarm data or show the notification
   552                 if( err ) // failed to fetch alarm data or show the notification
   520                 {
   553                 {
   521                     // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry.
   554                     // 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)
   555                     // (or if the DisplayAlarmL call fails)
   523                     // -> stop and ignore the alarm
   556                     // -> stop and ignore the alarm
   524                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   557                     HandleInterruptAlarm( EReasonKSysApHideAlarm );
   525                 }
   558                 }
   526                 delete alarmInfo->iLocation;
       
   527                 delete alarmInfo->iSubject;
       
   528             }
   559             }
   529         }
   560         }
   530         break;
   561         break;
   531 
   562 
   532         default:
   563         default:
   729         if( noPowerKey ) // end key as power key >> snooze
   760         if( noPowerKey ) // end key as power key >> snooze
   730         {
   761         {
   731             // cancel the alarm
   762             // cancel the alarm
   732             if( iGlobalNoteId != KErrNotFound )
   763             if( iGlobalNoteId != KErrNotFound )
   733             {
   764             {
   734                 // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   765                 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this );
   735                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   766                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );
   736                 iAlarmUtils->NotifierDialogController()->dismissAlarmAlert();
       
   737             }
   767             }
   738         }
   768         }
   739         else // stop
   769         else // stop
   740         {
   770         {
   741             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   771             HandleInterruptAlarm( EReasonKSysApHideAlarm );
   751         {
   781         {
   752             ShowAlarm();
   782             ShowAlarm();
   753         }
   783         }
   754     }
   784     }
   755 
   785 
   756 	/*
       
   757     //For plasma support
   786     //For plasma support
   758     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   787     else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm )
   759     {
   788     {
   760         //Set the P&S to an uninitialized value
   789         //Set the P&S to an uninitialized value
   761     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   790     	TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized;
   770     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   799     	TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized;
   771     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   800     	PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); )
   772 
   801 
   773     	ExternalSnoozeAlarm();
   802     	ExternalSnoozeAlarm();
   774     }
   803     }
   775 	*/
       
   776 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   804 	else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive)
   777 	{
   805 	{
   778 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   806 		if(IsState(EStateWaitingInput) && aValue ==  ELightsBlinkingUninitialized )
   779 		{
   807 		{
   780 			iAlarmUtils->SetBackLight(ETrue);
   808 			iAlarmUtils->SetBackLight(ETrue);
   855                 {
   883                 {
   856                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   884                     if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() )
   857 	                    {
   885 	                    {
   858                         // Do not leave if calendar launch fails. Just continue as normally
   886                         // Do not leave if calendar launch fails. Just continue as normally
   859                         iAlarmUtils->StopAlarmSound();
   887                         iAlarmUtils->StopAlarmSound();
   860                         // PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   888                         PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); )
   861                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   889                         iAlarmUtils->StartAutoSnoozeTimer();  // restart auto-snooze timer
   862 	                    }
   890 	                    }
   863                 }
   891                 }
   864                 break;
   892                 break;
   865 
   893 
   943     {
   971     {
   944         case EStateWaitingDisplayRequest:
   972         case EStateWaitingDisplayRequest:
   945         {
   973         {
   946             iAlarmUtils->StartAutoSnoozeTimer();
   974             iAlarmUtils->StartAutoSnoozeTimer();
   947             iAlarmUtils->PlayAlarmSound();
   975             iAlarmUtils->PlayAlarmSound();
   948             //iAlarmUtils->SetKeyGuard( EFalse );
   976             iAlarmUtils->SetKeyGuard( EFalse );
   949             SetState( EStateWaitingInput );
   977             SetState( EStateWaitingInput );
   950             iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
   978             iAlarmUtils->StartKeyBlocker();  // block all input for 0.5 seconds
   951         }
   979         }
   952         break;
   980         break;
   953 
   981 
   998         case EStateWaitingShowRequest:
  1026         case EStateWaitingShowRequest:
   999         case EStateWaitingDisplayRequest:
  1027         case EStateWaitingDisplayRequest:
  1000         case EStateWaitingInput:
  1028         case EStateWaitingInput:
  1001         {
  1029         {
  1002             SetState( EStateIdle );
  1030             SetState( EStateIdle );
  1003             DoCancelDialog();
  1031 	          DoCancelDialog();
  1004             iAlarmUtils->TryToSnoozeActiveAlarm();
  1032             StopOrSnoozeAlarm();
  1005         }
  1033         }
  1006         break;
  1034         break;
  1007 
  1035 
  1008         case EStateBeforeAskingWakeup:
  1036         case EStateBeforeAskingWakeup:
  1009         case EStateAskingWakeup:
  1037         case EStateAskingWakeup:
  1105 
  1133 
  1106             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1134             case EKeyPhoneEnd: // (scan code EStdKeyNo)
  1107             {
  1135             {
  1108                 // Normally pressing End Call key generates CancelDialog callback, but
  1136                 // Normally pressing End Call key generates CancelDialog callback, but
  1109                 // when we have an active call we don't get the CancelDialog...
  1137                 // when we have an active call we don't get the CancelDialog...
  1110                 // iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1138                 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId );  // Cancel alarm....will snooze...
  1111                 TRACE_EXIT_POINT;
  1139                 TRACE_EXIT_POINT;
  1112                 return EKeyWasNotConsumed;
  1140                 return EKeyWasNotConsumed;
  1113             }
  1141             }
  1114 
  1142 
  1115             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1143             case EKeyVolumeUp:   // (scan code EStdKeyIncVolume)
  1158 // ---------------------------------------------------------
  1186 // ---------------------------------------------------------
  1159 //
  1187 //
  1160 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1188 void CAlmAlarmControl::ShowSnoozeInfoNoteL()
  1161 {
  1189 {
  1162     TRACE_ENTRY_POINT;
  1190     TRACE_ENTRY_POINT;
  1163 /*
  1191 
  1164     //Changes for MPIN-73VCR2
  1192     //Changes for MPIN-73VCR2
  1165    HBufC* stringHolder = NULL;
  1193    HBufC* stringHolder = NULL;
  1166    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1194    CAknInformationNote* note = new (ELeave) CAknInformationNote();
  1167    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1195    TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote;
  1168 
  1196 
  1206     }
  1234     }
  1207     else
  1235     else
  1208     {
  1236     {
  1209         SetState( EStateIdle );
  1237         SetState( EStateIdle );
  1210     }
  1238     }
  1211 	*/
       
  1212     TRACE_EXIT_POINT;
  1239     TRACE_EXIT_POINT;
  1213 }
  1240 }
  1214 
  1241 
  1215 // ---------------------------------------------------------
  1242 // ---------------------------------------------------------
  1216 // Stops an active alarm.
  1243 // Stops an active alarm.
  1305 //
  1332 //
  1306  TBool CAlmAlarmControl::IsStopFromContext()
  1333  TBool CAlmAlarmControl::IsStopFromContext()
  1307  {
  1334  {
  1308  	return iStopFromContextFw;
  1335  	return iStopFromContextFw;
  1309  }
  1336  }
       
  1337 
       
  1338  CAlarmUtils* CAlmAlarmControl::AlarmUtils() const
       
  1339      {
       
  1340      return iAlarmUtils;
       
  1341      }
       
  1342  // End of File
  1310  
  1343  
  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