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 |
259 TRACE_ENTRY_POINT; |
274 TRACE_ENTRY_POINT; |
260 iAskWakeup = EFalse; |
275 iAskWakeup = EFalse; |
261 ASSERT( IsState( EStateBeforeAskingWakeup ) ); |
276 ASSERT( IsState( EStateBeforeAskingWakeup ) ); |
262 if( IsState( EStateBeforeAskingWakeup ) ) |
277 if( IsState( EStateBeforeAskingWakeup ) ) |
263 { |
278 { |
264 HBufC* label = NULL; |
279 // HBufC* label = NULL; |
265 TBuf<1> time; |
280 // TBuf<1> time; |
266 iAlarmUtils->GetWakeupLabelL( label ); |
281 // iAlarmUtils->GetWakeupLabelL( label ); |
267 CleanupStack::PushL( label ); |
282 // CleanupStack::PushL( label ); |
268 |
283 |
269 if(!IsVisible()) |
284 /* if(!IsVisible()) |
270 { |
285 { |
271 MakeVisible(ETrue); |
286 MakeVisible(ETrue); |
272 } |
287 }*/ |
273 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
288 // iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
274 iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ ); |
289 // iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ ); |
275 |
290 SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo(); |
276 CleanupStack::PopAndDestroy( label ); |
291 iAlarmUtils->NotifierDialogController()->showAlarmAlert( alarmInfo ); |
|
292 |
|
293 // CleanupStack::PopAndDestroy( label ); |
277 |
294 |
278 // shutdown automatically if user doesn't react within one minute |
295 // shutdown automatically if user doesn't react within one minute |
279 iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown ); |
296 iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown ); |
280 } |
297 } |
281 TRACE_EXIT_POINT; |
298 TRACE_EXIT_POINT; |
356 // |
373 // |
357 void CAlmAlarmControl::StoreMissedAlarmDataL() |
374 void CAlmAlarmControl::StoreMissedAlarmDataL() |
358 { |
375 { |
359 //Get the Calendar instance values and |
376 //Get the Calendar instance values and |
360 //Store it in the missed alarm repository |
377 //Store it in the missed alarm repository |
361 |
378 /* |
362 RPointerArray<CMissedAlarm> missedAlarmList; |
379 RPointerArray<CMissedAlarm> missedAlarmList; |
363 TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid; |
380 TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid; |
364 TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime; |
381 TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime; |
365 TTime startTime = instanceTime.TimeLocalL(); |
382 TTime startTime = instanceTime.TimeLocalL(); |
366 CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime, |
383 CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime, |
372 missedAlarmStore->AddL(missedAlarmList); |
389 missedAlarmStore->AddL(missedAlarmList); |
373 |
390 |
374 CleanupStack::PopAndDestroy( missedAlarmStore ); |
391 CleanupStack::PopAndDestroy( missedAlarmStore ); |
375 CleanupStack::Pop( missedAlarm ); |
392 CleanupStack::Pop( missedAlarm ); |
376 missedAlarmList.ResetAndDestroy(); |
393 missedAlarmList.ResetAndDestroy(); |
377 } |
394 */ |
378 |
395 } |
379 |
|
380 // --------------------------------------------------------- |
|
381 // Checks for calendar type alarm needed to be stored as missed alarm |
|
382 // Stops the alarm and enters to missed alarm table. If the calendar type |
|
383 // is clock, then snoozes the alarm. |
|
384 // --------------------------------------------------------- |
|
385 // |
|
386 void CAlmAlarmControl::StopOrSnoozeAlarm() |
|
387 { |
|
388 |
|
389 TRACE_ENTRY_POINT; |
|
390 if( iAlarmUtils->IsCalendarAlarm() ) |
|
391 { |
|
392 if( iAlarmUtils->IsCalendarAlarmViewer() ) |
|
393 { |
|
394 iAlarmUtils->SetCalendarAlarmViewer(EFalse); |
|
395 } |
|
396 else |
|
397 { |
|
398 TRAP_IGNORE( StoreMissedAlarmDataL() ); |
|
399 } |
|
400 iAlarmUtils->DoStopAlarm(); |
|
401 } |
|
402 else |
|
403 { |
|
404 iAlarmUtils->TryToSnoozeActiveAlarm(); |
|
405 } |
|
406 TRACE_EXIT_POINT; |
|
407 } |
|
408 |
|
409 // =========================================================== |
396 // =========================================================== |
410 // ================ INHERITED FUNCTIONS ====================== |
397 // ================ INHERITED FUNCTIONS ====================== |
411 |
398 |
412 // --------------------------------------------------------- |
399 // --------------------------------------------------------- |
413 // Symbian 2nd phase constructor |
400 // Symbian 2nd phase constructor |
430 |
417 |
431 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile ); |
418 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile ); |
432 iResOffset = iEikonEnv->AddResourceFileL( resFile ); |
419 iResOffset = iEikonEnv->AddResourceFileL( resFile ); |
433 |
420 |
434 |
421 |
435 iEikonEnv->EikAppUi()->AddToStackL( |
422 /*iEikonEnv->EikAppUi()->AddToStackL( |
436 this, |
423 this, |
437 ECoeStackPriorityAlert, |
424 ECoeStackPriorityAlert, |
438 ECoeStackFlagRefusesFocus ); |
425 ECoeStackFlagRefusesFocus ); |
439 |
426 */ |
440 MakeVisible(EFalse); |
427 // MakeVisible(EFalse); |
441 SetStopFromContext(EFalse); |
428 SetStopFromContext(EFalse); |
442 iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor ); |
429 iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor ); |
443 |
430 |
444 // observe "hide alarm" commands (i.e. powerkey presses) |
431 // observe "hide alarm" commands (i.e. powerkey presses) |
445 iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm ); |
432 iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm ); |
446 |
433 |
447 // observe system state changes |
434 // observe system state changes |
448 iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState ); |
435 iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState ); |
449 //For Plasma accessory handling |
436 //For Plasma accessory handling |
450 _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy ); |
437 // _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy ); |
451 _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData ); |
438 // _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData ); |
452 |
439 |
|
440 /* |
453 RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
441 RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
454 RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
442 RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
455 |
443 |
456 //observe Plasma accessory stop key changes |
444 //observe Plasma accessory stop key changes |
457 iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey); |
445 iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey); |
458 |
446 |
459 //observe Plasma accessory snooze key changes |
447 //observe Plasma accessory snooze key changes |
460 iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey); |
448 iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey); |
|
449 */ |
461 //observe SysAp backlight setting PS Key |
450 //observe SysAp backlight setting PS Key |
462 iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive); |
451 iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive); |
463 TRACE_EXIT_POINT; |
452 TRACE_EXIT_POINT; |
464 } |
453 } |
465 |
454 |
501 |
490 |
502 // Only call this within ShowAlarm to prevent updating data too early/late. |
491 // Only call this within ShowAlarm to prevent updating data too early/late. |
503 // (e.g. updating snooze time before showing the snooze info note) |
492 // (e.g. updating snooze time before showing the snooze info note) |
504 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); ) |
493 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); ) |
505 |
494 |
506 HBufC* text = NULL; |
495 // Get the alarm information |
507 |
496 SAlarmInfo* alarmInfo = iAlarmUtils->GetAlarmInfo(); |
508 if( !err ) |
497 // Get the ringing type |
509 { |
498 alarmInfo->iIsSilent = iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone(); |
510 TRAP( err, iAlarmUtils->GetAlarmLabelL( text ); ) |
499 // Check if the alarm can be snoozed |
511 } |
500 alarmInfo->iCanSnooze = iAlarmUtils->CanSnooze(); |
512 // cleanup (release global data) |
501 |
513 iAlarmUtils->UninitialiseAlarmData(); |
502 // cleanup (release global data) |
514 if( !err ) |
503 iAlarmUtils->UninitialiseAlarmData(); |
515 { |
504 /*if(!IsVisible()) |
516 if(!IsVisible()) |
505 { |
517 { |
506 MakeVisible(ETrue); |
518 MakeVisible(ETrue); |
507 } |
519 } |
508 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
520 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
509 |
521 |
510 // setup CBA for the global note |
522 // setup CBA for the global note |
511 TUint cba(0); // See AknDialogController.h |
523 TUint cba(0); // See AknDialogController.h |
512 // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms |
524 // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms |
513 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm; |
525 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm; |
514 // disable silence key when ringing type is set to "silent" or if alarm sounds is set off |
526 // disable silence key when ringing type is set to "silent" or if alarm sounds is set off |
515 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0; |
527 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0; |
516 // disable silence and snooze key if alarm can't be snoozed anymore |
528 // disable silence and snooze key if alarm can't be snoozed anymore |
517 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence; |
529 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence; |
518 // show "Open" MSK for calendar alarms if the security lock is not active |
530 // show "Open" MSK for calendar alarms if the security lock is not active |
519 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0; |
531 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0; |
520 |
532 |
521 // request alarm dialog |
533 // request alarm dialog |
522 TBuf<1> time; |
534 TBuf<1> time; |
523 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, timenot used ) ); |
535 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, time/*not used*/ ) ); |
524 delete text; // only delete if GetAlarmLabelL call was successfull |
536 delete text; // only delete if GetAlarmLabelL call was successfull |
525 ASSERT( !err ); */ |
537 ASSERT( !err ); |
526 iAlarmUtils->NotifierDialogController()->showAlarmAlert(alarmInfo); |
538 } |
527 iAlarmUtils->StartAutoSnoozeTimer(); |
|
528 iAlarmUtils->PlayAlarmSound(); |
|
529 SetState( EStateWaitingInput ); |
539 |
530 |
540 if( err ) // failed to fetch alarm data or show the notification |
531 if( err ) // failed to fetch alarm data or show the notification |
541 { |
532 { |
542 // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry. |
533 // this happens if user has deleted calendar entry with a snoozed alarm or removed alarm from a snoozed calendar entry. |
543 // (or if the DisplayAlarmL call fails) |
534 // (or if the DisplayAlarmL call fails) |
544 // -> stop and ignore the alarm |
535 // -> stop and ignore the alarm |
545 HandleInterruptAlarm( EReasonKSysApHideAlarm ); |
536 HandleInterruptAlarm( EReasonKSysApHideAlarm ); |
546 } |
537 } |
|
538 delete alarmInfo->iLocation; |
|
539 delete alarmInfo->iSubject; |
547 } |
540 } |
548 } |
541 } |
549 break; |
542 break; |
550 |
543 |
551 default: |
544 default: |
787 TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized; |
782 TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized; |
788 PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); ) |
783 PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); ) |
789 |
784 |
790 ExternalSnoozeAlarm(); |
785 ExternalSnoozeAlarm(); |
791 } |
786 } |
|
787 */ |
792 else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive) |
788 else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive) |
793 { |
789 { |
794 if(IsState(EStateWaitingInput) && aValue == ELightsBlinkingUninitialized ) |
790 if(IsState(EStateWaitingInput) && aValue == ELightsBlinkingUninitialized ) |
795 { |
791 { |
796 iAlarmUtils->SetBackLight(ETrue); |
792 iAlarmUtils->SetBackLight(ETrue); |
1320 // |
1317 // |
1321 TBool CAlmAlarmControl::IsStopFromContext() |
1318 TBool CAlmAlarmControl::IsStopFromContext() |
1322 { |
1319 { |
1323 return iStopFromContextFw; |
1320 return iStopFromContextFw; |
1324 } |
1321 } |
|
1322 |
|
1323 void CAlmAlarmControl::alertCompleted(AlarmCommand command) |
|
1324 { |
|
1325 // cancel timers |
|
1326 iAlarmUtils->CancelAutoSnooze(); |
|
1327 iAlarmUtils->StopAlarmSound(); |
|
1328 |
|
1329 switch( iState ) |
|
1330 { |
|
1331 /** |
|
1332 * EStateWaitingInput: normal case |
|
1333 * EStateWaitingDisplayRequest: |
|
1334 * This happens only if the global note got handled before we got the DisplayDialogL call. |
|
1335 * (e.g. note is dismissed if the cover is closed at the same time when alarm expires) |
|
1336 **/ |
|
1337 case EStateWaitingInput: |
|
1338 case EStateWaitingDisplayRequest: |
|
1339 { |
|
1340 switch( command ) |
|
1341 { |
|
1342 case AlarmStop: |
|
1343 { |
|
1344 SetState( EStateAfterInput ); |
|
1345 iAskWakeup = ETrue; // ask wakeup after all the alarms are handled |
|
1346 iAlarmUtils->DoStopAlarm(); // stop |
|
1347 break; |
|
1348 } |
|
1349 case AlarmSnooze: |
|
1350 { |
|
1351 SetState( EStateAfterInput ); |
|
1352 |
|
1353 SetState( EStateShowingSnoozeInfo ); |
|
1354 iAlarmUtils->TryToSnoozeActiveAlarm(); |
|
1355 if( IsState( EStateWaitingShowRequest ) ) |
|
1356 { |
|
1357 ShowAlarm(); |
|
1358 } |
|
1359 else |
|
1360 { |
|
1361 SetState( EStateIdle ); |
|
1362 } |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 break; |
|
1367 } |
|
1368 TRACE_EXIT_POINT; |
|
1369 } |
|
1370 |
|
1371 void CAlmAlarmControl::alertDisplayed(AlarmCommand /*command*/) |
|
1372 { |
|
1373 TRACE_ENTRY_POINT; |
|
1374 switch( iState ) |
|
1375 { |
|
1376 case EStateWaitingDisplayRequest: |
|
1377 { |
|
1378 iAlarmUtils->StartAutoSnoozeTimer(); |
|
1379 iAlarmUtils->PlayAlarmSound(); |
|
1380 iAlarmUtils->SetKeyGuard( EFalse ); |
|
1381 SetState( EStateWaitingInput ); |
|
1382 iAlarmUtils->StartKeyBlocker(); // block all input for 0.5 seconds |
|
1383 } |
|
1384 break; |
|
1385 |
|
1386 case EStateBeforeAskingWakeup: |
|
1387 { |
|
1388 SetState( EStateAskingWakeup ); |
|
1389 } |
|
1390 break; |
|
1391 |
|
1392 default: |
|
1393 { |
|
1394 // panic - invalid state! |
|
1395 Panic( EAlarmUIInvalidState | EAlarmUIDisplayDialog ); |
|
1396 } |
|
1397 } |
|
1398 } |
|
1399 |
|
1400 void CAlmAlarmControl::alertCancelled(AlarmCommand /*command*/) |
|
1401 { |
|
1402 iAlarmUtils->StopAlarmSound(); |
|
1403 iAlarmUtils->CancelAutoSnooze(); |
|
1404 } |
1325 |
1405 |
1326 // End of File |
1406 // End of File |