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 // ----------------------------------------------------------------------------- |
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: |
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 |
|