|
1 /* |
|
2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: An alarm UI class, CAlmAlarmControl. |
|
15 * This class takes care of displaying the alarm note and |
|
16 * handling user input. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "AlmAlarmControl.h" |
|
24 #include "pim_trace.h" |
|
25 #include "alarmutils.h" |
|
26 #include <secondarydisplay/alarmuiSecondaryDisplay.h> |
|
27 #include <bautils.h> |
|
28 #include <StringLoader.h> |
|
29 #include <pathinfo.h> |
|
30 #include <featmgr.h> |
|
31 #include <aknnotewrappers.h> |
|
32 #include <coreapplicationuisdomainpskeys.h> |
|
33 #include <alarmuidomainpskeys.h> |
|
34 #include <data_caging_path_literals.hrh> |
|
35 |
|
36 #include <AlmAlert.rsg> |
|
37 #include "AlmAlert.hrh" |
|
38 #include "AlmAlert.pan" |
|
39 |
|
40 #include <aknnotewrappers.h> |
|
41 #include <AknMediatorFacade.h> |
|
42 |
|
43 #include <missedalarm.h> |
|
44 |
|
45 _LIT( KResourceFile, "AlmAlert.rsc" ); |
|
46 |
|
47 const TInt KAlarmPriority( 3095 ); // Priority for global note queue |
|
48 |
|
49 const TUint KAlarmAutoShutdown( 60000000 ); // 60 s |
|
50 const TUint KShutdownTime( 1500000 ); // 1.5 s |
|
51 |
|
52 // ========================================================== |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void CAlmAlarmControl::Panic(const TUint aReason) const |
|
60 { |
|
61 TRACE_ENTRY_POINT; |
|
62 _LIT( KPanicCategory, "AlarmUI-AlmAlert.pan" ); |
|
63 User::Panic( KPanicCategory, aReason ); |
|
64 TRACE_EXIT_POINT; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // C++ default constructor can NOT contain any code, that might leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CAlmAlarmControl::CAlmAlarmControl() : |
|
72 iGlobalNoteId( KErrNotFound ), |
|
73 iState( EStateIdle ) |
|
74 { |
|
75 TRACE_ENTRY_POINT; |
|
76 TRACE_EXIT_POINT; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Destructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CAlmAlarmControl::~CAlmAlarmControl() |
|
84 { |
|
85 TRACE_ENTRY_POINT; |
|
86 this->HideAlarm(); |
|
87 |
|
88 delete iAlarmUtils; |
|
89 iAlarmUtils = NULL; |
|
90 |
|
91 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
92 iEikonEnv->DeleteResourceFile( iResOffset ); |
|
93 |
|
94 delete iPropertyHideAlarm; |
|
95 iPropertyHideAlarm = NULL; |
|
96 |
|
97 delete iPropertySWStateValue; |
|
98 iPropertySWStateValue = NULL; |
|
99 |
|
100 delete iPropertyStopAlarm; |
|
101 iPropertyStopAlarm = NULL; |
|
102 |
|
103 delete iPropertySnoozeAlarm; |
|
104 iPropertySnoozeAlarm = NULL; |
|
105 TRACE_EXIT_POINT; |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------- |
|
109 // |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CAlmAlarmControl::SetState(TInt aState) |
|
113 { |
|
114 TRACE_ENTRY_POINT; |
|
115 const TInt oldState( iState ); |
|
116 iState = aState; |
|
117 // handle state transitions |
|
118 HandleStateChange( oldState ); |
|
119 TRACE_EXIT_POINT; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // handle custom state transitions |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CAlmAlarmControl::HandleStateChange(TInt aOldState) |
|
127 { |
|
128 TRACE_ENTRY_POINT; |
|
129 |
|
130 // stop observers when exiting from EStateWaitingInput state |
|
131 if( aOldState == EStateWaitingInput |
|
132 && iState != EStateWaitingInput ) |
|
133 { |
|
134 // stop the context/sensor observer. |
|
135 PIM_TRAPD_ASSERT( iAlarmUtils->StopCFObserverL(); ) |
|
136 |
|
137 // stop waiting for "end call" command from accessories |
|
138 iAlarmUtils->StopAccessoryObserver(); |
|
139 } |
|
140 |
|
141 switch( iState ) |
|
142 { |
|
143 case EStateIdle: |
|
144 { |
|
145 iAlarmUtils->StopInactivityResetTimer(); |
|
146 |
|
147 // was the device started for alarm? |
|
148 if( iAlarmUtils->IsDeviceInAlarmState() ) |
|
149 { |
|
150 /** |
|
151 * Show the wakeup query if any of the alarms was stopped (by user |
|
152 * pressing the stop key) and there is no more alarms in the queue. |
|
153 */ |
|
154 if( iAskWakeup && !iAlarmUtils->HasExpiredAlarmsWaiting() ) |
|
155 { |
|
156 SetState( EStateBeforeAskingWakeup ); |
|
157 iAlarmUtils->AsyncShowWakeupQuery(); |
|
158 } |
|
159 else |
|
160 { |
|
161 /** |
|
162 * Prepare to shutdown if wakeup query is not needed. |
|
163 * (also works as a fallback if we are waiting for more |
|
164 * alarms to be notified (iAlarmUtils->HasExpiredAlarmsWaiting()==ETrue), |
|
165 * but alarm server queue changes suddenly) |
|
166 */ |
|
167 iAlarmUtils->StartShutdownTimer( KShutdownTime ); |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 /** |
|
173 * block all input for 0.5 seconds |
|
174 * (try to prevent accidental key presses from going through the key or security lock) |
|
175 */ |
|
176 iAlarmUtils->StartKeyBlocker(); |
|
177 |
|
178 // reset the key guard |
|
179 iAlarmUtils->SetKeyGuard( ETrue ); |
|
180 } |
|
181 |
|
182 break; |
|
183 } |
|
184 |
|
185 case EStateWaitingInput: |
|
186 { |
|
187 // make sure the screen saver, key or security lock, etc. won't active during the alarm |
|
188 iAlarmUtils->StartInactivityResetTimer(); |
|
189 |
|
190 // start waiting for "end call" command from accessories |
|
191 iAlarmUtils->StartAccessoryObserver(); |
|
192 |
|
193 // publish new alarm context value and wait for any actions |
|
194 PIM_TRAPD_ASSERT( iAlarmUtils->StartCFObserverL(); ) |
|
195 break; |
|
196 } |
|
197 |
|
198 default: |
|
199 // fall through |
|
200 break; |
|
201 } |
|
202 TRACE_EXIT_POINT; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 TBool CAlmAlarmControl::IsState(const TInt aState) const |
|
210 { |
|
211 TRACE_ENTRY_POINT; |
|
212 TBool retVal(iState == aState); |
|
213 TRACE_EXIT_POINT; |
|
214 return retVal; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 void CAlmAlarmControl::DoAutoSnooze() |
|
222 { |
|
223 TRACE_ENTRY_POINT; |
|
224 iAlarmUtils->CancelAutoSnooze(); |
|
225 |
|
226 // Allow auto-snooze only while waiting user input |
|
227 if( IsState( EStateWaitingInput ) ) |
|
228 { |
|
229 SetState( EStateAfterInput ); |
|
230 StopOrSnoozeAlarm(); |
|
231 DoCancelDialog(); |
|
232 } |
|
233 TRACE_EXIT_POINT; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------- |
|
237 // Dismiss the alarm notification. |
|
238 // --------------------------------------------------------- |
|
239 // |
|
240 void CAlmAlarmControl::DoCancelDialog() |
|
241 { |
|
242 TRACE_ENTRY_POINT; |
|
243 if( iGlobalNoteId != KErrNotFound ) |
|
244 { |
|
245 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
|
246 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId ); |
|
247 } |
|
248 iAlarmUtils->StopAlarmSound(); |
|
249 iAlarmUtils->CancelAutoSnooze(); |
|
250 TRACE_EXIT_POINT; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------- |
|
254 // Show the wake-up query |
|
255 // --------------------------------------------------------- |
|
256 // |
|
257 void CAlmAlarmControl::AskWakeupPhoneL() |
|
258 { |
|
259 TRACE_ENTRY_POINT; |
|
260 iAskWakeup = EFalse; |
|
261 ASSERT( IsState( EStateBeforeAskingWakeup ) ); |
|
262 if( IsState( EStateBeforeAskingWakeup ) ) |
|
263 { |
|
264 HBufC* label = NULL; |
|
265 TBuf<1> time; |
|
266 iAlarmUtils->GetWakeupLabelL( label ); |
|
267 CleanupStack::PushL( label ); |
|
268 |
|
269 if(!IsVisible()) |
|
270 { |
|
271 MakeVisible(ETrue); |
|
272 } |
|
273 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
|
274 iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( EAskWakeUp, *label, time/*not used*/ ); |
|
275 |
|
276 CleanupStack::PopAndDestroy( label ); |
|
277 |
|
278 // shutdown automatically if user doesn't react within one minute |
|
279 iAlarmUtils->StartShutdownTimer( KAlarmAutoShutdown ); |
|
280 } |
|
281 TRACE_EXIT_POINT; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------- |
|
285 // Handle alarm interrupt commands (power key) |
|
286 // --------------------------------------------------------- |
|
287 // |
|
288 void CAlmAlarmControl::HandleInterruptAlarm(TInt aReason) |
|
289 { |
|
290 TRACE_ENTRY_POINT; |
|
291 switch( aReason ) |
|
292 { |
|
293 case EReasonKSysApHideAlarm: // stop |
|
294 { |
|
295 switch( iState ) |
|
296 { |
|
297 case EStateIdle: |
|
298 { |
|
299 // ignore |
|
300 } |
|
301 break; |
|
302 |
|
303 case EStateWaitingShowRequest: // stop -> EStateIdle |
|
304 case EStateWaitingDisplayRequest: // stop -> hide -> EStateIdle |
|
305 case EStateWaitingInput: // stop -> hide -> EStateIdle |
|
306 { |
|
307 iAskWakeup = EFalse; // don't show the wakeup query! |
|
308 SetState( EStateIdle ); |
|
309 // Stop alarm -> HideAlarm() -> CancelNote() |
|
310 iAlarmUtils->DoStopAlarm(); // stop |
|
311 DoCancelDialog(); |
|
312 } |
|
313 break; |
|
314 |
|
315 case EStateBeforeAskingWakeup: // hide and shutdown |
|
316 case EStateAskingWakeup: // hide and shutdown |
|
317 { |
|
318 iAskWakeup = EFalse; |
|
319 iAlarmUtils->CancelAsynchRequest(); |
|
320 SetState( EStateIdle ); |
|
321 DoCancelDialog(); |
|
322 } |
|
323 break; |
|
324 |
|
325 case EStateAfterInput: |
|
326 case EStateShowingSnoozeInfo: |
|
327 { |
|
328 SetState( EStateIdle ); |
|
329 } |
|
330 break; |
|
331 |
|
332 default: |
|
333 { |
|
334 // panic - unknown state! |
|
335 Panic( EAlarmUIUnknownState | EAlarmUIHandleInterrupt ); |
|
336 } |
|
337 break; |
|
338 } |
|
339 break; |
|
340 } |
|
341 |
|
342 default: |
|
343 { |
|
344 // Unknown reason |
|
345 Panic( EAlarmUIUnknownReason | EAlarmUIHandleInterrupt ); |
|
346 } |
|
347 break; |
|
348 } |
|
349 TRACE_EXIT_POINT; |
|
350 } |
|
351 |
|
352 |
|
353 // --------------------------------------------------------- |
|
354 // Stores the missed alarm data in the repository |
|
355 // --------------------------------------------------------- |
|
356 // |
|
357 void CAlmAlarmControl::StoreMissedAlarmDataL() |
|
358 { |
|
359 //Get the Calendar instance values and |
|
360 //Store it in the missed alarm repository |
|
361 |
|
362 RPointerArray<CMissedAlarm> missedAlarmList; |
|
363 TCalLocalUid localUid = iAlarmUtils->AlarmData().iLocalUid; |
|
364 TCalTime instanceTime = iAlarmUtils->AlarmData().iInstanceTime; |
|
365 TTime startTime = instanceTime.TimeLocalL(); |
|
366 CMissedAlarm* missedAlarm = CMissedAlarm::NewL( localUid, startTime, |
|
367 iAlarmUtils->AlarmData().iCalFileName ); |
|
368 CleanupStack::PushL( missedAlarm ); |
|
369 missedAlarmList.AppendL(missedAlarm); |
|
370 |
|
371 CMissedAlarmStore* missedAlarmStore = CMissedAlarmStore::NewLC(); |
|
372 missedAlarmStore->AddL(missedAlarmList); |
|
373 |
|
374 CleanupStack::PopAndDestroy( missedAlarmStore ); |
|
375 CleanupStack::Pop( missedAlarm ); |
|
376 missedAlarmList.ResetAndDestroy(); |
|
377 } |
|
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 |
|
409 // =========================================================== |
|
410 // ================ INHERITED FUNCTIONS ====================== |
|
411 |
|
412 // --------------------------------------------------------- |
|
413 // Symbian 2nd phase constructor |
|
414 // --------------------------------------------------------- |
|
415 // |
|
416 void CAlmAlarmControl::ConstructL(CAknAlarmService* aSupervisor) |
|
417 { |
|
418 TRACE_ENTRY_POINT; |
|
419 |
|
420 TFileName fileName; |
|
421 // Get the complate path of the DLL from where it is currently loaded |
|
422 Dll::FileName( fileName ); |
|
423 |
|
424 TFileName resFile; |
|
425 |
|
426 // Append the Drive letters ex., Z: or C: |
|
427 resFile.Append(fileName.Mid(0,2)); |
|
428 resFile.Append(KDC_RESOURCE_FILES_DIR); |
|
429 resFile.Append(KResourceFile); |
|
430 |
|
431 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resFile ); |
|
432 iResOffset = iEikonEnv->AddResourceFileL( resFile ); |
|
433 |
|
434 |
|
435 iEikonEnv->EikAppUi()->AddToStackL( |
|
436 this, |
|
437 ECoeStackPriorityAlert, |
|
438 ECoeStackFlagRefusesFocus ); |
|
439 |
|
440 MakeVisible(EFalse); |
|
441 SetStopFromContext(EFalse); |
|
442 iAlarmUtils = CAlarmUtils::NewL( this, aSupervisor ); |
|
443 |
|
444 // observe "hide alarm" commands (i.e. powerkey presses) |
|
445 iPropertyHideAlarm = CPropertyObserver::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm ); |
|
446 |
|
447 // observe system state changes |
|
448 iPropertySWStateValue = CPropertyObserver::NewL( *this, KPSUidStartup, KPSGlobalSystemState ); |
|
449 //For Plasma accessory handling |
|
450 _LIT_SECURITY_POLICY_PASS( KGeneralReadPolicy ); |
|
451 _LIT_SECURITY_POLICY_C1( KProtectedWritePolicy, ECapabilityWriteDeviceData ); |
|
452 |
|
453 RProperty::Define( KPSUidAlarmExtCntl, KAlarmStopKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
|
454 RProperty::Define( KPSUidAlarmExtCntl, KAlarmSnoozeKey, RProperty::EInt, KGeneralReadPolicy, KProtectedWritePolicy ); |
|
455 |
|
456 //observe Plasma accessory stop key changes |
|
457 iPropertyStopAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmStopKey); |
|
458 |
|
459 //observe Plasma accessory snooze key changes |
|
460 iPropertySnoozeAlarm = CPropertyObserver::NewL(*this, KPSUidAlarmExtCntl, KAlarmSnoozeKey); |
|
461 //observe SysAp backlight setting PS Key |
|
462 iPropertyBacklight = CPropertyObserver::NewL(*this, KPSUidCoreApplicationUIs, KLightsAlarmLightActive); |
|
463 TRACE_EXIT_POINT; |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------- |
|
467 // From MEikServAlarm (MAlarmObserver) |
|
468 // --------------------------------------------------------- |
|
469 // |
|
470 void CAlmAlarmControl::Release() |
|
471 { |
|
472 TRACE_ENTRY_POINT; |
|
473 delete this; |
|
474 TRACE_EXIT_POINT; |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------- |
|
478 // From MEikServAlarm |
|
479 // NOTE!!! This function is also called from HandlePropertyChange() |
|
480 // --------------------------------------------------------- |
|
481 // |
|
482 void CAlmAlarmControl::ShowAlarm() |
|
483 { |
|
484 TRACE_ENTRY_POINT; |
|
485 switch( iState ) |
|
486 { |
|
487 case EStateWaitingShowRequest: |
|
488 { |
|
489 /** |
|
490 * wait until device startup is ready, |
|
491 * snooze info note is not being displayed and |
|
492 * delay timer has finished. |
|
493 */ |
|
494 if( iAlarmUtils->IsPhoneStartupReady() && |
|
495 !iSnoozeInfoNoteActive && |
|
496 !iAlarmUtils->AlarmDelayTimerActive() ) |
|
497 { |
|
498 // State MUST be set before requesting the note from avkon! |
|
499 // DisplayAlarmL() will call DisplayDialogL() directly! |
|
500 SetState( EStateWaitingDisplayRequest ); |
|
501 |
|
502 // Only call this within ShowAlarm to prevent updating data too early/late. |
|
503 // (e.g. updating snooze time before showing the snooze info note) |
|
504 TRAPD( err, iAlarmUtils->InitialiseAlarmDataL(); ) |
|
505 |
|
506 HBufC* text = NULL; |
|
507 |
|
508 if( !err ) |
|
509 { |
|
510 TRAP( err, iAlarmUtils->GetAlarmLabelL( text ); ) |
|
511 } |
|
512 // cleanup (release global data) |
|
513 iAlarmUtils->UninitialiseAlarmData(); |
|
514 if( !err ) |
|
515 { |
|
516 if(!IsVisible()) |
|
517 { |
|
518 MakeVisible(ETrue); |
|
519 } |
|
520 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
|
521 |
|
522 // setup CBA for the global note |
|
523 TUint cba(0); // See AknDialogController.h |
|
524 // alarm type - no silence key for clock alarms, unknown alarms are handled as calendar alarms |
|
525 cba |= iAlarmUtils->IsClockAlarm() ? EClockAlarm | ENoSilence : ECalendarAlarm; |
|
526 // disable silence key when ringing type is set to "silent" or if alarm sounds is set off |
|
527 cba |= iAlarmUtils->IsRingingTypeSilent() || iAlarmUtils->IsOffTone() ? ENoSilence : 0; |
|
528 // disable silence and snooze key if alarm can't be snoozed anymore |
|
529 cba |= iAlarmUtils->CanSnooze() ? 0 : EHideSnooze | ENoSilence; |
|
530 // show "Open" MSK for calendar alarms if the security lock is not active |
|
531 cba |= iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ? EMskOpen : 0; |
|
532 |
|
533 // request alarm dialog |
|
534 TBuf<1> time; |
|
535 TRAP( err, iGlobalNoteId = iAlarmUtils->NotifierDialogController()->DisplayAlarmL( cba, *text, time/*not used*/ ) ); |
|
536 delete text; // only delete if GetAlarmLabelL call was successfull |
|
537 ASSERT( !err ); |
|
538 } |
|
539 |
|
540 if( err ) // failed to fetch alarm data or show the notification |
|
541 { |
|
542 // 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) |
|
544 // -> stop and ignore the alarm |
|
545 HandleInterruptAlarm( EReasonKSysApHideAlarm ); |
|
546 } |
|
547 } |
|
548 } |
|
549 break; |
|
550 |
|
551 default: |
|
552 { |
|
553 // All other states are ignored |
|
554 } |
|
555 } |
|
556 TRACE_EXIT_POINT; |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------- |
|
560 // From MEikServAlarm (MAlarmObserver) |
|
561 // !!! REMEMBER !!! - This function is only called AFTER |
|
562 // the alarm is snoozed or stopped |
|
563 // --------------------------------------------------------- |
|
564 // |
|
565 void CAlmAlarmControl::HideAlarm() |
|
566 { |
|
567 TRACE_ENTRY_POINT; |
|
568 switch( iState ) |
|
569 { |
|
570 case EStateIdle: |
|
571 case EStateBeforeAskingWakeup: |
|
572 case EStateAskingWakeup: |
|
573 case EStateShowingSnoozeInfo: |
|
574 { |
|
575 // fall through |
|
576 } |
|
577 break; |
|
578 |
|
579 case EStateWaitingShowRequest: |
|
580 case EStateWaitingDisplayRequest: |
|
581 case EStateWaitingInput: |
|
582 case EStateAfterInput: |
|
583 { |
|
584 SetState( EStateIdle ); |
|
585 DoCancelDialog(); |
|
586 } |
|
587 break; |
|
588 |
|
589 default: |
|
590 { |
|
591 // panic - unknown state! |
|
592 Panic( EAlarmUIUnknownState | EAlarmUIHideAlarm ); |
|
593 } |
|
594 } |
|
595 TRACE_EXIT_POINT; |
|
596 } |
|
597 |
|
598 // --------------------------------------------------------- |
|
599 // From MEikServAlarm (MAlarmObserver) |
|
600 // --------------------------------------------------------- |
|
601 // |
|
602 TInt CAlmAlarmControl::CurrentServerState() const |
|
603 { |
|
604 TRACE_ENTRY_POINT; |
|
605 TRACE_EXIT_POINT; |
|
606 return iCurrentServerState; |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------- |
|
610 // From MEikServAlarm (MAlarmObserver) |
|
611 // --------------------------------------------------------- |
|
612 // |
|
613 void CAlmAlarmControl::UpdateSoundPauseTimeInterval(TInt /*aMinutes*/) |
|
614 { |
|
615 TRACE_ENTRY_POINT; |
|
616 // No implementation |
|
617 TRACE_EXIT_POINT; |
|
618 } |
|
619 |
|
620 // --------------------------------------------------------- |
|
621 // From MEikServAlarm (MAlarmObserver) |
|
622 // --------------------------------------------------------- |
|
623 // |
|
624 void CAlmAlarmControl::UpdateForAlarmServerState(TInt aNewAlarmServerState) |
|
625 { |
|
626 TRACE_ENTRY_POINT; |
|
627 if( iCurrentServerState != aNewAlarmServerState ) |
|
628 { |
|
629 iCurrentServerState = aNewAlarmServerState; |
|
630 } |
|
631 TRACE_EXIT_POINT; |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------- |
|
635 // From MEikServAlarm (MAlarmObserver) |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 void CAlmAlarmControl::UpdateAlarmInfo(const TASShdAlarm& aAlarm, const TFullName& /*aOwner*/) |
|
639 { |
|
640 TRACE_ENTRY_POINT; |
|
641 // cancel timers |
|
642 iAlarmUtils->CancelAutoSnooze(); |
|
643 iAlarmUtils->CancelShutdown(); |
|
644 iAlarmUtils->StartAlarmDelayTimer(); |
|
645 |
|
646 // remember to store the alarm object |
|
647 iAlarmUtils->AlarmData().iAlarm = aAlarm; |
|
648 |
|
649 switch( iState ) |
|
650 { |
|
651 case EStateIdle: |
|
652 case EStateAfterInput: |
|
653 case EStateShowingSnoozeInfo: |
|
654 { |
|
655 /** |
|
656 * ignore and snooze other than wakeup alarms when phone is not in "normal" state |
|
657 * (special handling - don't increment the snooze count) |
|
658 */ |
|
659 if( !iAlarmUtils->IsDeviceInNormalState() && |
|
660 !iAlarmUtils->IsWakeupAlarm() ) |
|
661 { |
|
662 iAlarmUtils->DoSnooze(); |
|
663 } |
|
664 else |
|
665 { |
|
666 SetState( EStateWaitingShowRequest ); |
|
667 } |
|
668 } |
|
669 break; |
|
670 |
|
671 case EStateWaitingShowRequest: |
|
672 case EStateWaitingDisplayRequest: |
|
673 case EStateWaitingInput: |
|
674 { |
|
675 // Alarm server sent the alarm back to queue...just cancel the dialog and continue. |
|
676 SetState( EStateIdle ); |
|
677 DoCancelDialog(); |
|
678 SetState( EStateWaitingShowRequest ); |
|
679 } |
|
680 break; |
|
681 |
|
682 case EStateBeforeAskingWakeup: |
|
683 case EStateAskingWakeup: |
|
684 { |
|
685 /** |
|
686 * Just snooze the alarm for 1 minute (without changing the counter) and |
|
687 * let the user (or shutdown timer) handle the wakeup dialog... |
|
688 */ |
|
689 iAlarmUtils->AlarmData().iSnoozeTime = 1; |
|
690 iAlarmUtils->DoSnooze(); |
|
691 } |
|
692 break; |
|
693 |
|
694 default: |
|
695 { |
|
696 // All other states are invalid! |
|
697 Panic( EAlarmUIInvalidState | EAlarmUIUpdateAlarmInfo ); |
|
698 } |
|
699 } |
|
700 TRACE_EXIT_POINT; |
|
701 } |
|
702 |
|
703 // --------------------------------------------------------- |
|
704 // From MEikServAlarm (MAlarmObserver) |
|
705 // --------------------------------------------------------- |
|
706 // |
|
707 void CAlmAlarmControl::StartPlayAlarmL(const TDesC& /*aAlarmName*/) |
|
708 { |
|
709 TRACE_ENTRY_POINT; |
|
710 // No implementation. |
|
711 TRACE_EXIT_POINT; |
|
712 } |
|
713 |
|
714 // --------------------------------------------------------- |
|
715 // From MEikServAlarm (MAlarmObserver) |
|
716 // --------------------------------------------------------- |
|
717 // |
|
718 void CAlmAlarmControl::StopPlayAlarm() |
|
719 { |
|
720 TRACE_ENTRY_POINT; |
|
721 // No implementation. |
|
722 TRACE_EXIT_POINT; |
|
723 } |
|
724 |
|
725 // --------------------------------------------------------- |
|
726 // From MPropertyChangeHandler |
|
727 // --------------------------------------------------------- |
|
728 // |
|
729 void CAlmAlarmControl::HandlePropertyChange(const TUid aCategory, const TUint aKey, const TInt aValue) |
|
730 { |
|
731 TRACE_ENTRY_POINT; |
|
732 // Notified when user presses the power key... |
|
733 if( aCategory == KPSUidCoreApplicationUIs && aKey == KCoreAppUIsHideAlarm && aValue == ECoreAppUIsHideAlarm ) |
|
734 { |
|
735 /** |
|
736 * Does the device have a dedicated power key? |
|
737 */ |
|
738 TBool noPowerKey( EFalse ); // is end key used as a power key? |
|
739 TRAPD( err, FeatureManager::InitializeLibL(); ) |
|
740 ASSERT( !err ); |
|
741 |
|
742 if( !err ) |
|
743 { |
|
744 noPowerKey = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey ); |
|
745 FeatureManager::UnInitializeLib(); |
|
746 } |
|
747 |
|
748 if( noPowerKey ) // end key as power key >> snooze |
|
749 { |
|
750 // cancel the alarm |
|
751 if( iGlobalNoteId != KErrNotFound ) |
|
752 { |
|
753 iAlarmUtils->NotifierDialogController()->SetNoteObserver( this ); |
|
754 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId ); |
|
755 } |
|
756 } |
|
757 else // stop |
|
758 { |
|
759 HandleInterruptAlarm( EReasonKSysApHideAlarm ); |
|
760 } |
|
761 } |
|
762 // phone state changed |
|
763 else if( aCategory == KPSUidStartup && aKey == KPSGlobalSystemState ) |
|
764 { |
|
765 iAlarmUtils->SetDeviceState( static_cast<TPSGlobalSystemState>(aValue) ); |
|
766 // This is just to make sure the ShowAlarm gets always called because |
|
767 // ShowAlarm() is ignored if phone is not in some of it's final states. |
|
768 if( IsState( EStateWaitingShowRequest ) ) |
|
769 { |
|
770 ShowAlarm(); |
|
771 } |
|
772 } |
|
773 |
|
774 //For plasma support |
|
775 else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmStopKey && aValue == EAlarmUIStopAlarm ) |
|
776 { |
|
777 //Set the P&S to an uninitialized value |
|
778 TAlarmUIStopAlarm extStopAlarm = EAlarmUIStopAlarmUninitialized; |
|
779 PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, static_cast<TInt>(extStopAlarm)); ) |
|
780 |
|
781 ExternalStopAlarm(); |
|
782 } |
|
783 |
|
784 else if( aCategory == KPSUidAlarmExtCntl && aKey == KAlarmSnoozeKey && aValue == EAlarmUISnoozeAlarm) |
|
785 { |
|
786 //Set the P&S to an uninitialized value |
|
787 TAlarmUISnoozeAlarm extSnoozeAlarm = EAlarmUISnoozeAlarmUninitialized; |
|
788 PIM_ASSERT( RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, static_cast<TInt>(extSnoozeAlarm)); ) |
|
789 |
|
790 ExternalSnoozeAlarm(); |
|
791 } |
|
792 else if( aCategory == KPSUidCoreApplicationUIs && aKey == KLightsAlarmLightActive) |
|
793 { |
|
794 if(IsState(EStateWaitingInput) && aValue == ELightsBlinkingUninitialized ) |
|
795 { |
|
796 iAlarmUtils->SetBackLight(ETrue); |
|
797 } |
|
798 } |
|
799 TRACE_EXIT_POINT; |
|
800 } |
|
801 |
|
802 // --------------------------------------------------------- |
|
803 // From MNotifierDialogObserver |
|
804 // --------------------------------------------------------- |
|
805 // |
|
806 void CAlmAlarmControl::NoteCompleted(TInt aNoteId, TInt aCommand) |
|
807 { |
|
808 TRACE_ENTRY_POINT; |
|
809 if( aNoteId != iGlobalNoteId ) // Valid note? |
|
810 { |
|
811 TRACE_EXIT_POINT; |
|
812 return; |
|
813 } |
|
814 |
|
815 // cancel timers |
|
816 iAlarmUtils->CancelAutoSnooze(); |
|
817 iAlarmUtils->CancelShutdown(); |
|
818 |
|
819 // do not silence if EAlertOpen or EAknSoftkeyEmpty is received |
|
820 if ( EAlertOpen != aCommand && EAknSoftkeyEmpty != aCommand ) |
|
821 { |
|
822 iAlarmUtils->StopAlarmSound(); |
|
823 } |
|
824 if(IsVisible()) |
|
825 { |
|
826 MakeVisible(EFalse); |
|
827 } |
|
828 |
|
829 switch( iState ) |
|
830 { |
|
831 /** |
|
832 * EStateWaitingInput: normal case |
|
833 * EStateWaitingDisplayRequest: |
|
834 * This happens only if the global note got handled before we got the DisplayDialogL call. |
|
835 * (e.g. note is dismissed if the cover is closed at the same time when alarm expires) |
|
836 **/ |
|
837 case EStateWaitingInput: |
|
838 case EStateWaitingDisplayRequest: |
|
839 { |
|
840 switch( aCommand ) |
|
841 { |
|
842 case EAlertStop: |
|
843 { |
|
844 iGlobalNoteId = KErrNotFound; // Set note as discarded/used... |
|
845 SetState( EStateAfterInput ); |
|
846 iAskWakeup = ETrue; // ask wakeup after all the alarms are handled |
|
847 iAlarmUtils->DoStopAlarm(); // stop |
|
848 } |
|
849 break; |
|
850 |
|
851 case EAlertSnooze: |
|
852 { |
|
853 iGlobalNoteId = KErrNotFound; // Set note as discarded/used... |
|
854 SetState( EStateAfterInput ); |
|
855 |
|
856 // show the snooze info note |
|
857 iSnoozeInfoNoteActive = ETrue; |
|
858 SetState( EStateShowingSnoozeInfo ); |
|
859 iAlarmUtils->AsyncShowSnoozeInfoNote(); |
|
860 iAlarmUtils->TryToSnoozeActiveAlarm(); |
|
861 } |
|
862 break; |
|
863 |
|
864 case EAlertSilence: |
|
865 { |
|
866 iAlarmUtils->StartAutoSnoozeTimer(); // restart auto-snooze timer |
|
867 } |
|
868 break; |
|
869 |
|
870 case EAlertOpen: |
|
871 { |
|
872 if( iAlarmUtils->IsCalendarAlarm() && !iAlarmUtils->IsSecurityLockActive() ) |
|
873 { |
|
874 // Do not leave if calendar launch fails. Just continue as normally |
|
875 iAlarmUtils->StopAlarmSound(); |
|
876 PIM_TRAPD_ASSERT( iAlarmUtils->StartCalendarL(); ) |
|
877 iAlarmUtils->StartAutoSnoozeTimer(); // restart auto-snooze timer |
|
878 } |
|
879 } |
|
880 break; |
|
881 |
|
882 case EAknSoftkeyEmpty: |
|
883 // Ignore if there is an empty softkey. No functionality to be completed. |
|
884 break; |
|
885 |
|
886 |
|
887 default: |
|
888 { |
|
889 // Unknown command! |
|
890 Panic( EAlarmUIUnknownCommand | EAlarmUINoteCompleted ); |
|
891 } |
|
892 break; |
|
893 } |
|
894 } |
|
895 break; |
|
896 |
|
897 case EStateAskingWakeup: |
|
898 { |
|
899 iGlobalNoteId = KErrNotFound; // Set note as discarded/used... |
|
900 |
|
901 switch( aCommand ) |
|
902 { |
|
903 case EAknSoftkeyYes: |
|
904 { |
|
905 SetState( EStateIdle ); |
|
906 /* |
|
907 * Going to EStateIdle when phone was started for an alarm will |
|
908 * always start the shutdown timer. Stop the timer before requesting |
|
909 * device startup. |
|
910 */ |
|
911 iAlarmUtils->CancelShutdown(); |
|
912 |
|
913 // boot up the device |
|
914 iAlarmUtils->DeviceStartup(); |
|
915 } |
|
916 break; |
|
917 |
|
918 case EAknSoftkeyNo: |
|
919 { |
|
920 // shutdown |
|
921 SetState( EStateIdle ); |
|
922 } |
|
923 break; |
|
924 |
|
925 default: |
|
926 { |
|
927 // Unknown command! |
|
928 Panic( EAlarmUIUnknownCommand | EAlarmUINoteCompleted ); |
|
929 } |
|
930 break; |
|
931 } |
|
932 } |
|
933 break; |
|
934 |
|
935 default: |
|
936 { |
|
937 // panic - invalid state! |
|
938 Panic( EAlarmUIInvalidState | EAlarmUINoteCompleted ); |
|
939 } |
|
940 } |
|
941 TRACE_EXIT_POINT; |
|
942 } |
|
943 |
|
944 // --------------------------------------------------------- |
|
945 // From MNotifierDialogObserver |
|
946 // --------------------------------------------------------- |
|
947 // |
|
948 TBool CAlmAlarmControl::DisplayDialogL(TInt aPriority) |
|
949 { |
|
950 TRACE_ENTRY_POINT; |
|
951 // Is it our responsibility |
|
952 if( aPriority != KAlarmPriority ) |
|
953 { |
|
954 TRACE_EXIT_POINT; |
|
955 return EFalse; |
|
956 } |
|
957 |
|
958 switch( iState ) |
|
959 { |
|
960 case EStateWaitingDisplayRequest: |
|
961 { |
|
962 iAlarmUtils->StartAutoSnoozeTimer(); |
|
963 iAlarmUtils->PlayAlarmSound(); |
|
964 iAlarmUtils->SetKeyGuard( EFalse ); |
|
965 SetState( EStateWaitingInput ); |
|
966 iAlarmUtils->StartKeyBlocker(); // block all input for 0.5 seconds |
|
967 } |
|
968 break; |
|
969 |
|
970 case EStateBeforeAskingWakeup: |
|
971 { |
|
972 SetState( EStateAskingWakeup ); |
|
973 } |
|
974 break; |
|
975 |
|
976 default: |
|
977 { |
|
978 // panic - invalid state! |
|
979 Panic( EAlarmUIInvalidState | EAlarmUIDisplayDialog ); |
|
980 } |
|
981 } |
|
982 TRACE_EXIT_POINT; |
|
983 return EFalse; |
|
984 } |
|
985 |
|
986 // --------------------------------------------------------- |
|
987 // From MNotifierDialogObserver |
|
988 // --------------------------------------------------------- |
|
989 // |
|
990 TBool CAlmAlarmControl::CancelDialog(TInt aPriority) |
|
991 { |
|
992 TRACE_ENTRY_POINT; |
|
993 // Is it our responsibility |
|
994 if( aPriority != KAlarmPriority ) |
|
995 { |
|
996 TRACE_EXIT_POINT; |
|
997 return EFalse; // -> ignore |
|
998 } |
|
999 |
|
1000 iGlobalNoteId = KErrNotFound; |
|
1001 |
|
1002 /** |
|
1003 * Reset back to EStateIdle and snooze the alarm if active. |
|
1004 */ |
|
1005 switch( iState ) |
|
1006 { |
|
1007 case EStateIdle: |
|
1008 case EStateShowingSnoozeInfo: |
|
1009 { |
|
1010 // fall through |
|
1011 } |
|
1012 break; |
|
1013 |
|
1014 case EStateWaitingShowRequest: |
|
1015 case EStateWaitingDisplayRequest: |
|
1016 case EStateWaitingInput: |
|
1017 { |
|
1018 SetState( EStateIdle ); |
|
1019 DoCancelDialog(); |
|
1020 StopOrSnoozeAlarm(); |
|
1021 } |
|
1022 break; |
|
1023 |
|
1024 case EStateBeforeAskingWakeup: |
|
1025 case EStateAskingWakeup: |
|
1026 { |
|
1027 // cancel and shutdown |
|
1028 iAlarmUtils->CancelAsynchRequest(); |
|
1029 SetState( EStateIdle ); |
|
1030 DoCancelDialog(); // make sure the dialog gets cancelled |
|
1031 } |
|
1032 break; |
|
1033 |
|
1034 case EStateAfterInput: |
|
1035 { |
|
1036 SetState( EStateIdle ); |
|
1037 } |
|
1038 break; |
|
1039 |
|
1040 default: |
|
1041 { |
|
1042 // panic - invalid state! |
|
1043 Panic( EAlarmUIUnknownState | EAlarmUICancelDialog ); |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 TRACE_EXIT_POINT; |
|
1048 return EFalse; |
|
1049 } |
|
1050 |
|
1051 // --------------------------------------------------------- |
|
1052 // From CCoeControl |
|
1053 // --------------------------------------------------------- |
|
1054 // |
|
1055 TKeyResponse CAlmAlarmControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
1056 { |
|
1057 TRACE_ENTRY_POINT; |
|
1058 // Consume all events except softkeys + power and end call key |
|
1059 // For keycodes see AVKON documentation: Series_60_AVKON_Key_Codes_Modifications_UI_B.doc |
|
1060 |
|
1061 // consume all key presses while key block timer is active |
|
1062 if( iAlarmUtils->KeyBlockActive() ) |
|
1063 { |
|
1064 TRACE_EXIT_POINT; |
|
1065 return EKeyWasConsumed; |
|
1066 } |
|
1067 |
|
1068 // don't consume any keys while in idle state or showing snooze info note |
|
1069 if( IsState( EStateIdle ) || iSnoozeInfoNoteActive ) |
|
1070 { |
|
1071 TRACE_EXIT_POINT; |
|
1072 return EKeyWasNotConsumed; |
|
1073 } |
|
1074 |
|
1075 if( (IsState( EStateWaitingInput ) || |
|
1076 IsState( EStateAskingWakeup ) ) |
|
1077 && aType == EEventKey ) |
|
1078 { |
|
1079 switch( aKeyEvent.iCode ) |
|
1080 { |
|
1081 case EKeyCBA1: // (scan code EStdKeyDevice0) |
|
1082 case EKeyCBA2: // (scan code EStdKeyDevice1) |
|
1083 case EKeyPowerOff: // (scan code EStdKeyDevice2) |
|
1084 { |
|
1085 // no need to let the event through if we don't have an active alarm note |
|
1086 if( iGlobalNoteId != KErrNotFound ) |
|
1087 { |
|
1088 TRACE_EXIT_POINT; |
|
1089 return EKeyWasNotConsumed; |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 TRACE_EXIT_POINT; |
|
1094 return EKeyWasConsumed; |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 // MSK support |
|
1099 case EKeyOK: // (scan code EStdKeyDevice3) |
|
1100 { |
|
1101 // Allow MSK for the "wakeup" query. |
|
1102 if( IsState( EStateAskingWakeup ) ) |
|
1103 { |
|
1104 TRACE_EXIT_POINT; |
|
1105 return EKeyWasNotConsumed; |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 if( IsState( EStateWaitingInput ) && |
|
1110 iAlarmUtils->IsCalendarAlarm() && |
|
1111 !iAlarmUtils->IsSecurityLockActive() ) |
|
1112 { |
|
1113 TRACE_EXIT_POINT; |
|
1114 return EKeyWasNotConsumed; |
|
1115 } |
|
1116 |
|
1117 TRACE_EXIT_POINT; |
|
1118 return EKeyWasConsumed; |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 case EKeyPhoneEnd: // (scan code EStdKeyNo) |
|
1123 { |
|
1124 // Normally pressing End Call key generates CancelDialog callback, but |
|
1125 // when we have an active call we don't get the CancelDialog... |
|
1126 iAlarmUtils->NotifierDialogController()->CancelNote( iGlobalNoteId ); // Cancel alarm....will snooze... |
|
1127 TRACE_EXIT_POINT; |
|
1128 return EKeyWasNotConsumed; |
|
1129 } |
|
1130 |
|
1131 case EKeyVolumeUp: // (scan code EStdKeyIncVolume) |
|
1132 case EKeyVolumeDown: // (scan code EStdKeyDecVolume) |
|
1133 { |
|
1134 ExternalSnoozeAlarm(); // snooze the alarm |
|
1135 TRACE_EXIT_POINT; |
|
1136 return EKeyWasConsumed; |
|
1137 } |
|
1138 |
|
1139 // OK/selection key, number keys, etc.. |
|
1140 default: |
|
1141 { |
|
1142 // let the user "silence" the calendar alarm (=stop flashing & vibra) when |
|
1143 // using "silent" or "beep once" ringing type. |
|
1144 // !!! calendar alarm uses "silence" key if ringing type is not "silent" or "beep once" |
|
1145 if( !iAlarmUtils->IsClockAlarm() && iAlarmUtils->IsRingingTypeSilent() ) |
|
1146 { |
|
1147 iAlarmUtils->StopAlarmSound(); |
|
1148 } |
|
1149 |
|
1150 // Eat all other keys... |
|
1151 // To enable keys (numbers, etc.) remember to re-evaluate |
|
1152 // all the switch...case Panics... |
|
1153 TRACE_EXIT_POINT; |
|
1154 return EKeyWasConsumed; |
|
1155 } |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 // consume all other key presses if phone startup is ready |
|
1160 if( iAlarmUtils->IsPhoneStartupReady() ) |
|
1161 { |
|
1162 TRACE_EXIT_POINT; |
|
1163 return EKeyWasConsumed; |
|
1164 } |
|
1165 else // still booting (alarm might be waiting to show the notification while phone is still in PIN query) |
|
1166 { |
|
1167 TRACE_EXIT_POINT; |
|
1168 return EKeyWasNotConsumed; |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 // --------------------------------------------------------- |
|
1173 // |
|
1174 // --------------------------------------------------------- |
|
1175 // |
|
1176 void CAlmAlarmControl::ShowSnoozeInfoNoteL() |
|
1177 { |
|
1178 TRACE_ENTRY_POINT; |
|
1179 |
|
1180 //Changes for MPIN-73VCR2 |
|
1181 HBufC* stringHolder = NULL; |
|
1182 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1183 TAlarmSecondaryDisplayNote alarmSecDispNote = EAlarmNoNote; |
|
1184 |
|
1185 if( iAlarmUtils->AlarmData().iSnoozeTime == 1 ) |
|
1186 { |
|
1187 stringHolder = StringLoader::LoadLC( R_EIKALARM_NOTE_SNOOZE_ONE ); |
|
1188 alarmSecDispNote = EAlarmSingleMinuteSnooze; |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 stringHolder = StringLoader::LoadLC( R_EIKALARM_NOTE_SNOOZE, iAlarmUtils->AlarmData().iSnoozeTime ); |
|
1193 alarmSecDispNote = EAlarmMutlipleMinuteSnooze; |
|
1194 } |
|
1195 |
|
1196 CleanupStack::PushL( note ); |
|
1197 note->PublishDialogL(alarmSecDispNote,KAlarmUINoteCategory); |
|
1198 CleanupStack::Pop(); |
|
1199 |
|
1200 TPtr bufPtr = stringHolder->Des(); |
|
1201 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( bufPtr ); |
|
1202 |
|
1203 //Commit data for buffer |
|
1204 CAknMediatorFacade* covercl1 = AknMediatorFacade(note); |
|
1205 if (covercl1) // returns null if __COVER_DISPLAY is not defined |
|
1206 { |
|
1207 covercl1->BufStream().WriteInt32L( iAlarmUtils->AlarmData().iSnoozeTime );// for coverui localisation info |
|
1208 covercl1->BufStream().CommitL(); // no more data to send so commit buf |
|
1209 } |
|
1210 note->ExecuteLD( *stringHolder ); |
|
1211 |
|
1212 CleanupStack::PopAndDestroy(); //stringHolder |
|
1213 |
|
1214 // End of changes for MPIN-73VCR2 |
|
1215 |
|
1216 iSnoozeInfoNoteActive = EFalse; |
|
1217 |
|
1218 // new alarm expired during the snooze info note --> show it |
|
1219 if( IsState( EStateWaitingShowRequest ) ) |
|
1220 { |
|
1221 ShowAlarm(); |
|
1222 } |
|
1223 else |
|
1224 { |
|
1225 SetState( EStateIdle ); |
|
1226 } |
|
1227 TRACE_EXIT_POINT; |
|
1228 } |
|
1229 |
|
1230 // --------------------------------------------------------- |
|
1231 // Stops an active alarm. |
|
1232 // Has the same effect as pressing the power key (i.e. if |
|
1233 // the device was set off the startup query won't be shown) |
|
1234 // --------------------------------------------------------- |
|
1235 // |
|
1236 void CAlmAlarmControl::ExternalStopAlarm() |
|
1237 { |
|
1238 TRACE_ENTRY_POINT; |
|
1239 /** |
|
1240 * External commands should be handled only if we are |
|
1241 * really expecting some input from the user... |
|
1242 */ |
|
1243 if( IsState( EStateWaitingInput ) ) |
|
1244 { |
|
1245 iAlarmUtils->CancelAutoSnooze(); |
|
1246 iAskWakeup = EFalse; // don't show the wakeup query! |
|
1247 SetState( EStateAfterInput ); |
|
1248 iAlarmUtils->DoStopAlarm(); // stop |
|
1249 DoCancelDialog(); |
|
1250 } |
|
1251 iAlarmUtils->SetCalendarAlarmViewer(EFalse); |
|
1252 TRACE_EXIT_POINT; |
|
1253 } |
|
1254 |
|
1255 // --------------------------------------------------------- |
|
1256 // Snoozes an active alarm. |
|
1257 // --------------------------------------------------------- |
|
1258 // |
|
1259 void CAlmAlarmControl::ExternalSnoozeAlarm() |
|
1260 { |
|
1261 TRACE_ENTRY_POINT; |
|
1262 /** |
|
1263 * External commands should be handled only if we are |
|
1264 * really expecting some input from the user... |
|
1265 */ |
|
1266 if( IsState( EStateWaitingInput ) ) |
|
1267 { |
|
1268 iAlarmUtils->CancelAutoSnooze(); |
|
1269 SetState( EStateAfterInput ); |
|
1270 |
|
1271 if( iAlarmUtils->CanSnooze() ) |
|
1272 { |
|
1273 // show the snooze info note |
|
1274 iSnoozeInfoNoteActive = ETrue; |
|
1275 SetState( EStateShowingSnoozeInfo ); |
|
1276 iAlarmUtils->AsyncShowSnoozeInfoNote(); |
|
1277 } |
|
1278 // snooze (or stop, if max snooze count passed) the alarm and cancel the dialog |
|
1279 iAlarmUtils->TryToSnoozeActiveAlarm(); |
|
1280 DoCancelDialog(); |
|
1281 } |
|
1282 iAlarmUtils->SetCalendarAlarmViewer(EFalse); |
|
1283 TRACE_EXIT_POINT; |
|
1284 } |
|
1285 |
|
1286 /** |
|
1287 * Return if alarm can be snoozed. |
|
1288 * @since 5.0 |
|
1289 **/ |
|
1290 TBool CAlmAlarmControl::CanSnooze() |
|
1291 { |
|
1292 return iAlarmUtils->CanSnooze(); |
|
1293 } |
|
1294 |
|
1295 //--------------------------------------------------------- |
|
1296 // CAlmAlarmControl::HandleAlmInfoCRChangeL |
|
1297 // Handles Missed Alarm Store notifications |
|
1298 //--------------------------------------------------------- |
|
1299 // |
|
1300 void CAlmAlarmControl::HandleAlmInfoCRChangeL(TUint32 /*aCount*/) |
|
1301 { |
|
1302 TRACE_ENTRY_POINT; |
|
1303 |
|
1304 TRACE_EXIT_POINT; |
|
1305 } |
|
1306 |
|
1307 //--------------------------------------------------------- |
|
1308 // CAlmAlarmControl::SetStopFromContext |
|
1309 // Sets if Stop to be sent to calendar |
|
1310 //--------------------------------------------------------- |
|
1311 void CAlmAlarmControl::SetStopFromContext(TBool aStopFromContext) |
|
1312 { |
|
1313 iStopFromContextFw = aStopFromContext; |
|
1314 } |
|
1315 |
|
1316 //--------------------------------------------------------- |
|
1317 // CAlmAlarmControl::IsStopFromContext |
|
1318 // Gets if Stop/StopAndExit to be sent to calendar |
|
1319 //--------------------------------------------------------- |
|
1320 // |
|
1321 TBool CAlmAlarmControl::IsStopFromContext() |
|
1322 { |
|
1323 return iStopFromContextFw; |
|
1324 } |
|
1325 |
|
1326 // End of File |