|
1 /* |
|
2 * Copyright (c) 2002-2008 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: System soft notifications. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <uikon/eiksrvui.h> |
|
20 #include <AknNotiferAppServerApplication.h> |
|
21 #include "AknSystemPopup.h" |
|
22 #include <AknNotifyStd.h> |
|
23 #include <AknNotifierControllerPlugin.h> |
|
24 |
|
25 #include <avkon.rsg> |
|
26 #include <avkon.mbg> |
|
27 #include <eikbtgpc.h> |
|
28 #include <eikenv.h> |
|
29 #include <avkon.hrh> |
|
30 #include <eikimage.h> |
|
31 #include <barsread.h> |
|
32 |
|
33 #include <aknnotpi.rsg> |
|
34 |
|
35 #include "AknNotifyPlugin.hrh" |
|
36 #include <aknnotedialog.h> |
|
37 #include <aknnotecontrol.h> |
|
38 #include <aknconsts.h> |
|
39 |
|
40 #include <s32mem.h> |
|
41 #include <viewcli.h> |
|
42 #include <e32base.h> |
|
43 |
|
44 #include <AknNotifySignature.h> |
|
45 #include <aknnoteattributes.h> // for icon to skin conversion |
|
46 |
|
47 #include <AknCapServer.h> |
|
48 #include "AknCapServerEntry.h" |
|
49 #include <AknMediatorFacade.h> |
|
50 #include <aknSDData.h> |
|
51 |
|
52 #include <SecondaryDisplay/AknSecondaryDisplayDefs.h> |
|
53 #include <AknsUtils.h> |
|
54 #include <aknglobalpopupprioritycontroller.h> |
|
55 #include "GlobalWindowPriorities.h" |
|
56 #include "aknmessagereaderlongpressdetector.h" // CAknMessageReaderLongPressDetector |
|
57 |
|
58 #include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsAutolockStatus |
|
59 |
|
60 #include "AknDynamicNotificationData.h" |
|
61 #include "AknPrivateImageLoader.h" |
|
62 #include <AknUtils.h> |
|
63 #include <aknlayout.cdl.h> |
|
64 |
|
65 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
66 |
|
67 #include <gfxtranseffect/gfxtranseffect.h> |
|
68 #include <akntransitionutils.h> |
|
69 |
|
70 #endif |
|
71 |
|
72 |
|
73 const TInt KGlobalNoteGranularity = 4; // Initialize with space for 4 notes |
|
74 |
|
75 const TInt KMaxSoftNotePriority = 3000; |
|
76 const TInt KMaxAlarmNotePriority = 4000; |
|
77 const TInt KMaxNotePriority = 5000; |
|
78 const TInt KAlarmNotePriority = 3095; |
|
79 |
|
80 // class CGlobalNoteInfo |
|
81 |
|
82 CGlobalNoteInfo::CGlobalNoteInfo() : |
|
83 iSoftkeys( 0 ), |
|
84 iGraphic( -1 ), |
|
85 iAnimation( 0 ), |
|
86 iPlural( 0 ), |
|
87 iAsync( EFalse ), |
|
88 iTextProcessing( ETrue ), |
|
89 iSDData(NULL), |
|
90 iGlobalPopupPriority(0) |
|
91 { |
|
92 } |
|
93 |
|
94 CGlobalNoteInfo::~CGlobalNoteInfo() |
|
95 { |
|
96 delete iSDData; |
|
97 } |
|
98 |
|
99 // class CAknGlobalNoteDialog |
|
100 |
|
101 |
|
102 CAknGlobalNoteDialog::CAknGlobalNoteDialog(MGlobalNoteObserver* aObserver) |
|
103 :iObserver(aObserver), iPreviousNoteId( KErrNotFound ) |
|
104 { |
|
105 iCommand = KErrCancel; |
|
106 } |
|
107 |
|
108 void CAknGlobalNoteDialog::ConstructL() |
|
109 { |
|
110 ConstructSleepingDialogL(R_GLOBAL_NOTE); |
|
111 } |
|
112 |
|
113 CAknGlobalNoteDialog::~CAknGlobalNoteDialog() |
|
114 { |
|
115 delete iImageLoader; |
|
116 } |
|
117 |
|
118 TBool CAknGlobalNoteDialog::OkToExitL(TInt aButtonId) |
|
119 { |
|
120 |
|
121 ((CAknCapAppServerAppUi*) CEikonEnv::Static()->AppUi())->SetIsShortTimeGlobalNoteDisplaying(EFalse); |
|
122 |
|
123 if ( (iControlType == R_PERMANENT_CONTROL) || |
|
124 (iControlType == R_WAIT_CONTROL && iSoftkeys == R_AVKON_SOFTKEYS_EMPTY) ) |
|
125 { |
|
126 return EFalse; |
|
127 } |
|
128 |
|
129 else if ( iIsAlarm ) |
|
130 { |
|
131 // Don't let an empty command through. |
|
132 if ( aButtonId == EAknSoftkeyEmpty ) |
|
133 { |
|
134 return EFalse; |
|
135 } |
|
136 |
|
137 CEikButtonGroupContainer& bgc = ButtonGroupContainer(); |
|
138 |
|
139 if ( aButtonId == EAlertSilence ) |
|
140 { |
|
141 if ( iSoftkeys == R_ALERT_SOFTKEYS_STOP_SILENT__OPEN ) |
|
142 { |
|
143 iSoftkeys = R_ALERT_SOFTKEYS_STOP_SNOOZE__OPEN; |
|
144 } |
|
145 else // R_ALERT_SOFTKEYS_STOP_SILENT |
|
146 { |
|
147 iSoftkeys = R_ALERT_SOFTKEYS_STOP_SNOOZE; |
|
148 } |
|
149 bgc.SetCommandSetL( iSoftkeys ); |
|
150 bgc.ActivateL(); |
|
151 bgc.MakeVisible( ETrue ); |
|
152 bgc.DrawNow(); |
|
153 iObserver->GlobalNoteCompleted( EAlertSilence ); |
|
154 return EFalse; |
|
155 } |
|
156 |
|
157 // make sure that rsk will be visible next time |
|
158 // (this is actually a CBA fault but anyway). |
|
159 else if ( iSoftkeys == R_ALERT_SOFTKEYS_STOP_SNOOZE && |
|
160 !bgc.IsCommandVisible( EAlertSnooze ) ) |
|
161 { |
|
162 bgc.MakeCommandVisible( EAlertSnooze, ETrue ); |
|
163 } |
|
164 |
|
165 if ( aButtonId == EAlertOpen ) |
|
166 { |
|
167 if ( iSoftkeys == R_ALERT_SOFTKEYS_STOP_SILENT__OPEN || |
|
168 iSoftkeys == R_ALERT_SOFTKEYS_STOP_SNOOZE__OPEN || |
|
169 iSoftkeys == R_ALERT_SOFTKEYS_STOP_SNOOZE ) |
|
170 { |
|
171 iSoftkeys = R_ALERT_SOFTKEYS_STOP_SNOOZE; |
|
172 } |
|
173 else if ( iSoftkeys == R_ALERT_SOFTKEYS_STOP_SILENT ) |
|
174 { |
|
175 iSoftkeys = R_ALERT_SOFTKEYS_STOP_SILENT ; |
|
176 } |
|
177 else // R_ALERT_SOFTKEYS_STOP_EMPTY__OPEN |
|
178 { |
|
179 iSoftkeys = R_ALERT_SOFTKEYS_STOP_EMPTY__EMPTY; |
|
180 } |
|
181 |
|
182 bgc.SetCommandSetL( iSoftkeys ); |
|
183 bgc.ActivateL(); |
|
184 bgc.MakeVisible( ETrue ); |
|
185 bgc.DrawNow(); |
|
186 iObserver->GlobalNoteCompleted( EAlertOpen ); |
|
187 return EFalse; |
|
188 } |
|
189 } |
|
190 |
|
191 iCommand = aButtonId; |
|
192 NextNoteOrExit(); |
|
193 return ETrue; |
|
194 } |
|
195 |
|
196 |
|
197 void CAknGlobalNoteDialog::PreLayoutDynInitL() |
|
198 { |
|
199 delete iTimer; |
|
200 iTimer = NULL; |
|
201 if ( iTimeoutInMicroseconds != ENoTimeout ) |
|
202 { |
|
203 iTimer = CPeriodic::NewL(0); |
|
204 iTimer->Start(iTimeoutInMicroseconds, iTimeoutInMicroseconds, |
|
205 TCallBack(CallNextNoteOrExit,this)); |
|
206 } |
|
207 |
|
208 TransferControlAttributes(); // Ensure that new layout will be done |
|
209 |
|
210 if (iIsSoftNotification && iObserver->IsAppsKeyLocked() ) |
|
211 { |
|
212 iObserver->SetAppsKeyLocked( EFalse ); |
|
213 } |
|
214 } |
|
215 |
|
216 void CAknGlobalNoteDialog::HandleResourceChange(TInt aType) |
|
217 { |
|
218 if ( aType == KAknsMessageSkinChange ) |
|
219 { |
|
220 iPreviousAnimation = 0; // reload next animation always |
|
221 } |
|
222 |
|
223 CAknStaticNoteDialog::HandleResourceChange(aType); |
|
224 } |
|
225 |
|
226 |
|
227 void CAknGlobalNoteDialog::PostLayoutDynInitL() |
|
228 { |
|
229 CEikButtonGroupContainer& bgc = ButtonGroupContainer(); |
|
230 |
|
231 if ( iSoftkeys ) |
|
232 { |
|
233 bgc.SetCommandSetL(iSoftkeys); |
|
234 MEikButtonGroup* buttonGrp = bgc.ButtonGroup(); |
|
235 if( buttonGrp ) |
|
236 { |
|
237 if( iSoftkeyLeft.Length() > 0 ) |
|
238 { |
|
239 bgc.SetCommandL( buttonGrp->CommandId( |
|
240 CEikButtonGroupContainer::ELeftSoftkeyPosition ), |
|
241 iSoftkeyLeft ); |
|
242 } |
|
243 if( iSoftkeyRight.Length() > 0 ) |
|
244 { |
|
245 bgc.SetCommandL( buttonGrp->CommandId( |
|
246 CEikButtonGroupContainer::ERightSoftkeyPosition ), |
|
247 iSoftkeyRight ); |
|
248 } |
|
249 |
|
250 if (AknLayoutUtils::PenEnabled()) |
|
251 { |
|
252 if (iIsSoftNotification && iAutoLock) |
|
253 { |
|
254 bgc.MakeCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ELeftSoftkeyPosition), EFalse); |
|
255 bgc.MakeCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ERightSoftkeyPosition), EFalse); |
|
256 } |
|
257 else |
|
258 { |
|
259 if (!bgc.IsCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ELeftSoftkeyPosition))) |
|
260 bgc.MakeCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ELeftSoftkeyPosition), ETrue); |
|
261 if (!bgc.IsCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ERightSoftkeyPosition))) |
|
262 bgc.MakeCommandVisible(buttonGrp->CommandId(CEikButtonGroupContainer::ERightSoftkeyPosition), ETrue); |
|
263 } |
|
264 } |
|
265 } |
|
266 } |
|
267 |
|
268 CAknStaticNoteDialog::PostLayoutDynInitL(); |
|
269 |
|
270 if ( iIsSoftNotification && (iAutoLock > EAutolockOff) ) |
|
271 { // members below exist always when dialog exists, |
|
272 // LockKeys can be called multiple w/o problems, but as a optimisation, lets not |
|
273 if (!((CAknGlobalNoteSubject*)iObserver)->iKeyLockController->IsKeyLockEnabled()) |
|
274 { |
|
275 ((CAknGlobalNoteSubject*)iObserver)->iKeyLockController->LockKeys(ETrue); |
|
276 } |
|
277 } |
|
278 |
|
279 // Play the note note here, since RunLD will not be called (which is where tones are normally played from) |
|
280 PlayTone(); |
|
281 if (!iObserver->IsAppsKeyLocked() && !iIsSoftNotification) |
|
282 { |
|
283 if(iTimeoutInMicroseconds != EShortTimeout) |
|
284 { |
|
285 iObserver->SetAppsKeyLocked( ETrue ); |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 TKeyResponse CAknGlobalNoteDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
291 { |
|
292 if (iIsSoftNotification && aType == EEventKey) |
|
293 { |
|
294 // Send numbers keys to phone app, and bring it for foreground |
|
295 if ((aKeyEvent.iCode >= '0' && aKeyEvent.iCode <= '9') |
|
296 || aKeyEvent.iCode == '#' |
|
297 || aKeyEvent.iCode == '*') |
|
298 { |
|
299 if( aKeyEvent.iRepeats == 0 ) |
|
300 { |
|
301 MAknPhoneKeyForwarder* keyf = STATIC_CAST( |
|
302 CAknCapAppServerAppUi*, |
|
303 CEikonEnv::Static()->AppUi())->AsKeyForwarder(); |
|
304 |
|
305 keyf->ForwardKeyToPhoneAppL(aKeyEvent); |
|
306 |
|
307 ((CAknGlobalNoteSubject*)iObserver)->SetMaxDisplayPriorityL(KMinimumSoftNotePriority); |
|
308 } |
|
309 return EKeyWasConsumed; |
|
310 } |
|
311 else if ( aKeyEvent.iCode == EKeyEnter ) |
|
312 { |
|
313 TKeyEvent ccpuStart = { EKeyOK, EStdKeyDevice3, 0, 0 }; |
|
314 CCoeEnv::Static()->SimulateKeyEventL( ccpuStart, EEventKey ); |
|
315 return EKeyWasConsumed; |
|
316 } |
|
317 else if ( aKeyEvent.iCode != EKeyOK ) //Other keys don't remove soft notification. |
|
318 { |
|
319 if ( aKeyEvent.iCode == EKeyNo ) |
|
320 { |
|
321 iCommand = EAknSoftkeyExit; |
|
322 NextNoteOrExit(); |
|
323 } |
|
324 |
|
325 return EKeyWasConsumed; |
|
326 } |
|
327 } |
|
328 |
|
329 if (aKeyEvent.iCode == EKeyEscape) |
|
330 { |
|
331 return EKeyWasNotConsumed; |
|
332 } |
|
333 |
|
334 // Don't consume send key for displaying the dialer view, |
|
335 // only for soft notification. |
|
336 if (aKeyEvent.iScanCode == EStdKeyYes && iIsSoftNotification) |
|
337 { |
|
338 return EKeyWasNotConsumed; |
|
339 } |
|
340 |
|
341 if (iControlType == R_PERMANENT_CONTROL || |
|
342 iControlType == R_WAIT_CONTROL || |
|
343 iTimeoutInMicroseconds == ENoTimeout) |
|
344 { |
|
345 return EKeyWasConsumed; |
|
346 } |
|
347 |
|
348 // Any keypress dismissed other types of notes |
|
349 if (aType == EEventKey) |
|
350 { |
|
351 NextNoteOrExit(); |
|
352 } |
|
353 return EKeyWasConsumed; |
|
354 } |
|
355 |
|
356 TBool CAknGlobalNoteDialog::CallNextNoteOrExit(TAny* aThis) |
|
357 { |
|
358 STATIC_CAST(CAknGlobalNoteDialog*, aThis)->NextNoteOrExit(); |
|
359 return ETrue; |
|
360 } |
|
361 |
|
362 void CAknGlobalNoteDialog::NextNoteOrExit(TBool aDirectExit) |
|
363 { |
|
364 // If there is another global note waiting, show the next note, |
|
365 // otherwise put the global note back to sleep |
|
366 delete iTimer; |
|
367 iTimer = NULL; |
|
368 |
|
369 // if there are more notes on queue, don't release the apps key |
|
370 if (iObserver->IsAppsKeyLocked() && !iObserver->NoteWaiting()) |
|
371 { |
|
372 iObserver->SetAppsKeyLocked( EFalse ); |
|
373 } |
|
374 |
|
375 // Set borders back to zero |
|
376 SetNumberOfBorders(0); |
|
377 |
|
378 // to make sure that we don't leave RSK hidden even if OkToExitL is not called |
|
379 if (aDirectExit) |
|
380 { |
|
381 CEikButtonGroupContainer& bgc = ButtonGroupContainer(); |
|
382 if ( iSoftkeys == R_ALERT_SOFTKEYS_STOP_SNOOZE && |
|
383 !bgc.IsCommandVisible( EAlertSnooze ) ) |
|
384 { |
|
385 bgc.MakeCommandVisible( EAlertSnooze, ETrue ); |
|
386 } |
|
387 } |
|
388 |
|
389 #ifdef RD_SCALABLE_UI_V2 |
|
390 if ( AknLayoutUtils::PenEnabled() ) |
|
391 { |
|
392 SetGloballyCapturing( EFalse ); |
|
393 SetPointerCapture( EFalse ); |
|
394 } |
|
395 #endif // RD_SCALABLE_UI_V2 |
|
396 |
|
397 ExitSleepingDialog(); |
|
398 iDialogActive = EFalse; |
|
399 |
|
400 TRAP_IGNORE( PublishDialogL( 0 ) ); // to reset |
|
401 iObserver->GlobalNoteCompleted(iCommand); |
|
402 } |
|
403 |
|
404 void CAknGlobalNoteDialog::RemoveCurrentNote() |
|
405 { |
|
406 // Removes the current global note, so that a non-note dialog can be |
|
407 // shown |
|
408 delete iTimer; |
|
409 iTimer = NULL; |
|
410 #ifdef RD_SCALABLE_UI_V2 |
|
411 if ( AknLayoutUtils::PenEnabled() ) |
|
412 { |
|
413 SetGloballyCapturing( EFalse ); |
|
414 SetPointerCapture( EFalse ); |
|
415 } |
|
416 #endif // RD_SCALABLE_UI_V2 |
|
417 |
|
418 ExitSleepingDialog(); |
|
419 iDialogActive = EFalse; |
|
420 } |
|
421 |
|
422 void CAknGlobalNoteDialog::UpdateNoteAndDisplayL( CGlobalNoteInfo* aInfo ) |
|
423 { |
|
424 TInt notePriority = aInfo->iPriority; |
|
425 TInt noteResource = aInfo->iResourceId; |
|
426 TInt noteSoftkeys = aInfo->iSoftkeys; |
|
427 TInt notePlural = aInfo->iPlural; |
|
428 TInt noteGraphic = aInfo->iGraphic; |
|
429 TInt noteGraphicM = aInfo->iGraphicMask; |
|
430 TInt noteAnimation = aInfo->iAnimation; |
|
431 CAknNoteDialog::TTimeout noteTimeout = aInfo->iTimeOut; |
|
432 CAknNoteDialog::TTone noteTone = aInfo->iTone; |
|
433 CAknSDData* noteSDData = aInfo->iSDData; |
|
434 |
|
435 iCommand = KErrCancel; |
|
436 iTimeoutInMicroseconds = noteTimeout; |
|
437 iControlType = noteResource; |
|
438 |
|
439 iIsSoftNotification = ( |
|
440 notePriority >= KMinimumSoftNotePriority && |
|
441 notePriority <= KMaxSoftNotePriority ); |
|
442 |
|
443 //close the blank screen when global note display |
|
444 if (noteTimeout == EShortTimeout) |
|
445 { |
|
446 CAknCapAppServerAppUi* pAppui = |
|
447 (CAknCapAppServerAppUi*) CEikonEnv::Static()->AppUi(); |
|
448 pAppui->SetIsShortTimeGlobalNoteDisplaying(ETrue); |
|
449 } |
|
450 |
|
451 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
452 |
|
453 // use soft notify context |
|
454 if( iIsSoftNotification ) |
|
455 { |
|
456 GfxTransEffect::Register( this, KGfxSystemNotificationControlUid ); |
|
457 } |
|
458 else // must register other possible contexts (global notes) |
|
459 { |
|
460 class TResIdToContext |
|
461 { |
|
462 public: |
|
463 TInt iResId; |
|
464 TUid iContextId; |
|
465 }; |
|
466 |
|
467 TResIdToContext mapArray[] = |
|
468 { |
|
469 R_INFORMATION_CONTROL, KGfxInformationNoteControlUid, |
|
470 R_WARNING_CONTROL, KGfxWarningNoteControlUid, |
|
471 R_CONFIRMATION_CONTROL, KGfxConfirmationNoteControlUid, |
|
472 R_ERROR_CONTROL, KGfxErrorNoteControlUid, |
|
473 R_WAIT_CONTROL, KGfxWaitNoteControlUid, |
|
474 R_BATTERY_CHARGING_CONTROL,KGfxSystemNotifBatteryControlUid, |
|
475 R_BATTERY_NOT_CHARGING_CONTROL,KGfxSystemNotifBatteryControlUid, |
|
476 R_BATTERY_FULL_CONTROL,KGfxSystemNotifBatteryControlUid, |
|
477 R_BATTERY_LOW_CONTROL,KGfxSystemNotifBatteryControlUid, |
|
478 R_RECHARGE_BATTERY_CONTROL,KGfxSystemNotifBatteryControlUid |
|
479 }; |
|
480 |
|
481 TUid contextId = TUid::Uid(0); |
|
482 for( TInt i = 0; i<sizeof(mapArray)/sizeof(TResIdToContext); i++ ) |
|
483 { |
|
484 if( mapArray[i].iResId == noteResource ) |
|
485 { |
|
486 contextId = mapArray[i].iContextId; |
|
487 break; |
|
488 } |
|
489 } |
|
490 |
|
491 if( contextId.iUid == 0 ) |
|
492 { |
|
493 contextId = KGfxPopupDefaultControlUid; |
|
494 } |
|
495 |
|
496 GfxTransEffect::Register( this, contextId ); |
|
497 } |
|
498 |
|
499 #endif // RD_UI_TRANSITION_EFFECTS_POPUPS |
|
500 |
|
501 iIsAlarm = ( notePriority == KAlarmNotePriority ); |
|
502 iIsAlarmWakeup = (iIsAlarm && aInfo->iAlmFlag == EAskWakeUp); |
|
503 iSoftkeys = noteSoftkeys; |
|
504 |
|
505 #ifdef RD_SCALABLE_UI_V2 |
|
506 if ( AknLayoutUtils::PenEnabled() ) |
|
507 { |
|
508 SetGloballyCapturing( ETrue ); |
|
509 SetPointerCapture( ETrue ); |
|
510 } |
|
511 #endif |
|
512 |
|
513 if ( !iSoftkeys ) |
|
514 { |
|
515 if (iControlType == R_WAIT_CONTROL) |
|
516 { |
|
517 iSoftkeys = R_AVKON_SOFTKEYS_CANCEL; |
|
518 } |
|
519 else if ( notePriority != KAlarmNotePriority ) |
|
520 { |
|
521 iSoftkeys = R_AVKON_SOFTKEYS_EMPTY; |
|
522 } |
|
523 } |
|
524 |
|
525 iSoftkeyLeft.Set( aInfo->iLeftSK ); |
|
526 iSoftkeyRight.Set( aInfo->iRightSK ); |
|
527 |
|
528 if (aInfo->iImage.Length() <= 0) |
|
529 { |
|
530 // Exit sleeping dialog firstly for preventing from ui flicker. |
|
531 ExitSleepingDialog(); |
|
532 } |
|
533 |
|
534 if( iPreviousNoteId != aInfo->iNoteId && |
|
535 aInfo->iImage.Length() > 0 && |
|
536 !noteResource ) |
|
537 { |
|
538 // this is dynamic soft notification with new image. |
|
539 // Set dialogs layout with resource. |
|
540 noteResource = R_NEW_DYNAMIC_NOTIFIER_NOTE; |
|
541 } |
|
542 |
|
543 CAknNoteControl* note = STATIC_CAST( CAknNoteControl*, Control(ENPIGlobalNote) ); |
|
544 if ( noteResource ) |
|
545 { |
|
546 TResourceReader reader; |
|
547 iEikonEnv->CreateResourceReaderLC( reader, noteResource ); |
|
548 note->ConstructFromResourceL( reader ); |
|
549 CleanupStack::PopAndDestroy(); // reader |
|
550 } |
|
551 |
|
552 SetTextProcessing( aInfo->iTextProcessing ); |
|
553 |
|
554 if ( aInfo->iText.Length() ) |
|
555 { |
|
556 SetTextL( aInfo->iText ); |
|
557 } |
|
558 if ( notePlural > 0 ) |
|
559 { |
|
560 SetTextNumberL( notePlural ); |
|
561 } |
|
562 |
|
563 // check whether this is the same note we showed last time |
|
564 TBool noteChanged = ( iPreviousNoteId != aInfo->iNoteId ); |
|
565 iPreviousNoteId = aInfo->iNoteId; |
|
566 TBool asyncImageLoading = EFalse; // delay dialog until image is loaded |
|
567 |
|
568 if( aInfo->iImage.Length() > 0 ) |
|
569 { |
|
570 // Only load image if the notification has changed |
|
571 if( noteChanged ) |
|
572 { |
|
573 // Get icon size from LAF |
|
574 TRect mainpane; |
|
575 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, mainpane ); |
|
576 TAknLayoutRect noterect; |
|
577 noterect.LayoutRect( mainpane, AknLayout::popup_note_image_window() ); |
|
578 TAknLayoutRect gfxrect; |
|
579 gfxrect.LayoutRect( noterect.Rect(), |
|
580 AknLayout::Note_with_an_image_pop_up_window_elements_Line_12() ); |
|
581 |
|
582 // Create image loader |
|
583 if( !iImageLoader ) |
|
584 { |
|
585 iImageLoader = CAknPrivateImageLoader::NewL( |
|
586 CEikonEnv::Static()->FsSession(), *this ); |
|
587 } |
|
588 |
|
589 // load icon |
|
590 TRAPD( err, |
|
591 iImageLoader->LoadIconL( aInfo->iImage, gfxrect.Rect().Size() ) ); |
|
592 |
|
593 if( !err ) |
|
594 { |
|
595 // we're loading image -> delay dialog until loading is done |
|
596 asyncImageLoading = ETrue; |
|
597 } |
|
598 else |
|
599 { |
|
600 // when image loading fails, we reset the dialog's image |
|
601 SetImageL( NULL ); |
|
602 } |
|
603 } |
|
604 } |
|
605 if ( noteGraphic != -1 ) |
|
606 { |
|
607 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
608 |
|
609 CEikImage* image = new (ELeave) CEikImage; |
|
610 CleanupStack::PushL( image ); |
|
611 |
|
612 //Check For Skin Icon |
|
613 TAknsItemID id = CAknNoteAttributes::GetSkinnedBitmapID( noteGraphic ); |
|
614 |
|
615 CFbsBitmap* bitmap = NULL; |
|
616 CFbsBitmap* mask = NULL; |
|
617 |
|
618 AknsUtils::CreateIconL( |
|
619 skin, |
|
620 id, |
|
621 bitmap, |
|
622 mask, |
|
623 KAvkonBitmapFile, |
|
624 noteGraphic, |
|
625 noteGraphicM); |
|
626 |
|
627 image->SetPicture( bitmap, mask ); |
|
628 SetImageL( image ); |
|
629 CleanupStack::Pop( image ); |
|
630 } |
|
631 |
|
632 if ( noteAnimation != 0 ) |
|
633 { |
|
634 // don't reset animation if it is already loaded |
|
635 if ( noteResource || iPreviousAnimation != noteAnimation ) |
|
636 { |
|
637 note->SetAnimationL( noteAnimation ); |
|
638 iPreviousAnimation = noteAnimation; |
|
639 } |
|
640 } |
|
641 else |
|
642 iPreviousAnimation = 0; |
|
643 |
|
644 iTone = noteTone; |
|
645 |
|
646 // We don't want play tone twice (In case some other note appears on top of this note). |
|
647 noteTone = CAknNoteDialog::ENoTone; |
|
648 |
|
649 ReportUserActivity(); |
|
650 |
|
651 if ( noteSDData ) |
|
652 { |
|
653 // secondary display data has been published |
|
654 PublishDialogL( noteSDData->iDialogIdx, noteSDData->iCategory ); |
|
655 } |
|
656 else |
|
657 { |
|
658 // or the global note is unidentified |
|
659 PublishDialogL( EAknUnidentifiedNote, KAknSecondaryDisplayCategory ); |
|
660 } |
|
661 |
|
662 CAknMediatorFacade* cover_info = AknMediatorFacade(this); |
|
663 if (cover_info) // cover ui defined |
|
664 { |
|
665 if ( noteSDData && noteSDData->iAdditionalData ) |
|
666 {// information from client |
|
667 cover_info->BufStream() << *(noteSDData->iAdditionalData); |
|
668 } |
|
669 else if (iIsAlarm && iObserver->AlarmData()) |
|
670 { // share detailled alarm info |
|
671 TBuf8<sizeof(SAknAlarmPSInfo)> buf; |
|
672 |
|
673 // copy constructor should do just fine, but just to make sure |
|
674 buf.Append((const TUint8*)iObserver->AlarmData(),sizeof(SAknAlarmPSInfo)); |
|
675 |
|
676 cover_info->BufStream() << buf; |
|
677 } |
|
678 else |
|
679 { // default information about global note |
|
680 SAknGlobalNoteData params; |
|
681 params.iResourceId = noteResource; |
|
682 params.iTimeOut = noteTimeout; |
|
683 params.iTone = noteTone; |
|
684 params.iTextLength = aInfo->iText.Length(); |
|
685 params.iSoftkeys = noteSoftkeys; |
|
686 params.iImage.iImageId = noteGraphic; |
|
687 params.iImage.iImageMaskId = noteGraphicM; |
|
688 params.iAnimation = noteAnimation; |
|
689 params.iPlural = notePlural; |
|
690 TPckgBuf<SAknGlobalNoteData> buf(params); |
|
691 cover_info->BufStream() << buf; |
|
692 cover_info->BufStream() << aInfo->iText; |
|
693 } |
|
694 cover_info->BufStream().CommitL(); |
|
695 } |
|
696 |
|
697 AknGlobalPopupPriorityController::SetPopupPriorityL(*this, aInfo->iGlobalPopupPriority); |
|
698 |
|
699 iDialogActive = ETrue; |
|
700 |
|
701 // invalidate whole dialog area |
|
702 if( !asyncImageLoading ) |
|
703 { |
|
704 // DrawDeferred(); |
|
705 RouseSleepingDialog(); |
|
706 } |
|
707 } |
|
708 |
|
709 void CAknGlobalNoteDialog::ImageLoadSuccess( CEikImage* aImage ) |
|
710 { |
|
711 // set image |
|
712 TRAP_IGNORE(SetImageL(aImage)); |
|
713 |
|
714 if( iDialogActive ) |
|
715 { |
|
716 // Draw dialog |
|
717 DrawDeferred(); |
|
718 RouseSleepingDialog(); |
|
719 } |
|
720 |
|
721 delete iImageLoader; |
|
722 iImageLoader = NULL; |
|
723 } |
|
724 |
|
725 void CAknGlobalNoteDialog::ImageLoadError( TInt /*aError*/ ) |
|
726 { |
|
727 // clear previous image |
|
728 TRAP_IGNORE(SetImageL(NULL)); |
|
729 |
|
730 if( iDialogActive ) |
|
731 { |
|
732 // Draw dialog without image |
|
733 DrawDeferred(); |
|
734 RouseSleepingDialog(); |
|
735 } |
|
736 |
|
737 delete iImageLoader; |
|
738 iImageLoader = NULL; |
|
739 } |
|
740 |
|
741 void CAknGlobalNoteDialog::SetAutoLock(TBool aAutoLock) |
|
742 { |
|
743 iAutoLock = aAutoLock; |
|
744 } |
|
745 |
|
746 RWindow& CAknGlobalNoteDialog::GlobalNoteWindow() |
|
747 { |
|
748 return Window(); |
|
749 } |
|
750 |
|
751 void CAknGlobalNoteDialog::CEikDialog_Reserved_1() |
|
752 { |
|
753 } |
|
754 |
|
755 void CAknGlobalNoteDialog::CEikDialog_Reserved_2() |
|
756 { |
|
757 } |
|
758 |
|
759 void CAknGlobalNoteDialog::CAknNoteDialog_Reserved() |
|
760 { |
|
761 } |
|
762 |
|
763 void CAknGlobalNoteDialog::CAknStaticNoteDialog_Reserved() |
|
764 { |
|
765 } |
|
766 |
|
767 void CAknGlobalNoteDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
768 { |
|
769 if (Rect().Contains(aPointerEvent.iPosition) && (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
770 && iIsAlarm) |
|
771 { |
|
772 if (!iIsAlarmWakeup) |
|
773 { |
|
774 CEikDialog::TryExitL(EAlertOpen); |
|
775 } |
|
776 } |
|
777 else if ((iSoftkeys == R_AVKON_SOFTKEYS_EMPTY) && |
|
778 (iTimeoutInMicroseconds != ENoTimeout) && |
|
779 (aPointerEvent.iType == TPointerEvent::EButton1Up)) |
|
780 { |
|
781 CEikDialog::TryExitL(EAknSoftkeyExit); |
|
782 } |
|
783 else |
|
784 { |
|
785 CAknStaticNoteDialog::HandlePointerEventL(aPointerEvent); |
|
786 } |
|
787 } |
|
788 |
|
789 // class CAknGlobalNoteSubject |
|
790 |
|
791 CAknGlobalNoteSubject* CAknGlobalNoteSubject::NewL( |
|
792 MAknKeyLockController* aKeyLockController ) |
|
793 { |
|
794 CAknGlobalNoteSubject* self = |
|
795 new (ELeave) CAknGlobalNoteSubject(aKeyLockController); |
|
796 CleanupStack::PushL( self ); |
|
797 self->ConstructL(); |
|
798 CleanupStack::Pop( self ); |
|
799 return self; |
|
800 } |
|
801 |
|
802 CAknGlobalNoteSubject::CAknGlobalNoteSubject(MAknKeyLockController* aKeyLockController) |
|
803 :iKeyLockController(aKeyLockController),iNoteId(1), iMaxDisplayPriority(KMaxTInt), |
|
804 iMaxDisplayPriorityLimit(KMaxSoftNotePriority) |
|
805 { |
|
806 } |
|
807 |
|
808 void CAknGlobalNoteSubject::ConstructL() |
|
809 { |
|
810 iGlobalNoteList = new(ELeave) CArrayFixFlat<CGlobalNoteInfo*>(KGlobalNoteGranularity); |
|
811 iGlobalNoteList->SetReserveL(KGlobalNoteGranularity); |
|
812 iDisplayingNoteId = KErrNotFound; |
|
813 |
|
814 // Construct the emergency call support here, but it is not activated until a |
|
815 // permanent note is started |
|
816 iEcsDetector = CAknEcsDetector::NewL(); |
|
817 iKeyLockController->AddObserverL(this); |
|
818 |
|
819 // Setup a async callback for displaying the next note in the queue |
|
820 // This allows the next note to be displayed from the destructor of |
|
821 // a previous note, but the callback will execute only when the |
|
822 // destructor has finished |
|
823 TCallBack callback(CallDisplayNextNote, this); |
|
824 iDisplayCallback = new(ELeave)CAsyncCallBack(callback, CActive::EPriorityHigh); |
|
825 |
|
826 iGlobalNote = new(ELeave)CAknGlobalNoteDialog(this); |
|
827 iGlobalNote->ConstructL(); |
|
828 |
|
829 iDialogController = CNotifierDialogController::NewL(this); |
|
830 SetNotificationDialogObserver(iDialogController); |
|
831 |
|
832 // Make sure that server has a pointer to the dialog stack |
|
833 STATIC_CAST(CAknCapServer*,CEikonEnv::Static()->AppServer())-> |
|
834 SetGlobalNoteController(iDialogController); |
|
835 |
|
836 STATIC_CAST(CAknCapAppServerAppUi*,CEikonEnv::Static()->AppUi())-> |
|
837 iGlobalNotesController = this; |
|
838 |
|
839 // Only initialize message reader long press detector |
|
840 // if message reader has been installed |
|
841 if ( CAknMessageReaderLongPressDetector::MessageReaderInstalled() ) |
|
842 { |
|
843 iMessageReaderLongPressDetector = CAknMessageReaderLongPressDetector::NewL( &iGlobalNote->ButtonGroupContainer(), iGlobalNote->GlobalNoteWindow() ); |
|
844 STATIC_CAST(CAknCapAppServerAppUi*,CEikonEnv::Static()->AppUi())-> |
|
845 iMessageReaderLongPressDetector = iMessageReaderLongPressDetector; |
|
846 } |
|
847 |
|
848 // Set-up autolock status change notification. |
|
849 User::LeaveIfError(iAutolockStatusProperty.Attach( |
|
850 KPSUidCoreApplicationUIs, |
|
851 KCoreAppUIsAutolockStatus)); |
|
852 |
|
853 iAutolockStatusSubscriber = new (ELeave) CSubscriber( |
|
854 TCallBack(AutolockStatusNotificationL, this), |
|
855 iAutolockStatusProperty); |
|
856 |
|
857 iAutolockStatusSubscriber->Subscribe(); |
|
858 |
|
859 // Get the initial value. |
|
860 iAutolockStatusProperty.Get(iAutoLock); |
|
861 |
|
862 iGlobalNote->SetAutoLock(iAutoLock > EAutolockOff); |
|
863 |
|
864 iAlarmData = new SAknAlarmPSInfo; |
|
865 User::LeaveIfNull(iAlarmData); |
|
866 } |
|
867 |
|
868 |
|
869 TPtrC8 CAknGlobalNoteSubject::StartL(const TDesC8& aBuffer) |
|
870 { |
|
871 RDesReadStream readStream(aBuffer); |
|
872 |
|
873 // TInt32 takes four chars. |
|
874 if ( aBuffer.Length() < 4 ) |
|
875 { |
|
876 User::Leave(KErrArgument); |
|
877 } |
|
878 else |
|
879 { |
|
880 TInt signature = readStream.ReadInt32L(); |
|
881 |
|
882 if ( signature == KAKNNOTIFIERSIGNATURE_GETNOTEID ) |
|
883 { |
|
884 iRetPckg().iNoteId = iNoteId++; |
|
885 return iRetPckg; |
|
886 } |
|
887 |
|
888 if ( signature != KAKNNOTIFIERSIGNATURE ) |
|
889 { |
|
890 User::Leave(KErrArgument); |
|
891 } |
|
892 } |
|
893 |
|
894 TBuf<KGlobalNoteTextLength> text; // We mustn't use heap... |
|
895 |
|
896 TInt type = readStream.ReadInt16L(); |
|
897 readStream >> text; |
|
898 |
|
899 TInt priority = readStream.ReadInt16L(); |
|
900 TInt softkeys = readStream.ReadInt32L(); |
|
901 TInt graphic = readStream.ReadInt16L(); |
|
902 TInt graphicMask = readStream.ReadInt16L(); |
|
903 TInt animation = readStream.ReadInt32L(); |
|
904 TInt tone = readStream.ReadInt16L(); |
|
905 TChar adapterTypesUsed = readStream.ReadInt8L(); |
|
906 TChar textProcessing = readStream.ReadInt8L(); |
|
907 TInt preallocatedNoteId = readStream.ReadInt32L(); |
|
908 CAknSDData* secondaryDisplayInfo = new (ELeave) CAknSDData(); |
|
909 CleanupStack::PushL(secondaryDisplayInfo); |
|
910 if (readStream.ReadInt8L()) |
|
911 { |
|
912 readStream >> *secondaryDisplayInfo; |
|
913 } |
|
914 |
|
915 TInt noteId = KErrNotFound; |
|
916 |
|
917 if ( type == EAknGlobalRechargeBatteryNote || |
|
918 type == EAknGlobalBatteryLowNote|| |
|
919 type == EAknGlobalBatteryFullNote|| |
|
920 type == EAknGlobalChargingNote || |
|
921 type == EAknGlobalNotChargingNote || |
|
922 type == EAknGlobalBatteryFullUnplugNote || |
|
923 type == EAknGlobalUnplugChargerNote ) |
|
924 { |
|
925 if (iNotesDisabled) |
|
926 { |
|
927 priority = KMaxAlarmNotePriority; |
|
928 tone = CAknNoteDialog::ENoTone; |
|
929 } |
|
930 secondaryDisplayInfo->iDialogIdx = type; |
|
931 // fw will set correct category uid automatically |
|
932 secondaryDisplayInfo->iCategory = KNullUid; |
|
933 } |
|
934 |
|
935 // make sure that error notes w/o timeout do not get hidden behinds soft notifications |
|
936 if (type == EAknGlobalErrorNote || type == EAknGlobalWarningNote ) |
|
937 { |
|
938 // We alter only default priority, and do it only if note does not have timeout. |
|
939 if (priority == 0 && softkeys != 0 ) |
|
940 { |
|
941 priority = KMaxSoftNotePriority+1; |
|
942 } |
|
943 } |
|
944 |
|
945 switch ( type ) |
|
946 { |
|
947 case EAknGlobalInformationNote: |
|
948 noteId = AddNoteToQueueL( R_INFORMATION_CONTROL, |
|
949 text, |
|
950 priority, |
|
951 CAknNoteDialog::ELongTimeout, |
|
952 CAknNoteDialog::EConfirmationTone, |
|
953 tone, |
|
954 graphic, |
|
955 graphicMask, |
|
956 animation, |
|
957 softkeys, |
|
958 preallocatedNoteId ); |
|
959 break; |
|
960 |
|
961 case EAknGlobalWarningNote: |
|
962 noteId = AddNoteToQueueL( R_WARNING_CONTROL, |
|
963 text, |
|
964 priority, |
|
965 CAknNoteDialog::ELongTimeout, |
|
966 CAknNoteDialog::EWarningTone, |
|
967 tone, |
|
968 graphic, |
|
969 graphicMask, |
|
970 animation, |
|
971 softkeys, |
|
972 preallocatedNoteId ); |
|
973 break; |
|
974 |
|
975 case EAknGlobalConfirmationNote: |
|
976 noteId = AddNoteToQueueL( R_CONFIRMATION_CONTROL, |
|
977 text, |
|
978 priority, |
|
979 CAknNoteDialog::EShortTimeout, |
|
980 CAknNoteDialog::EConfirmationTone, |
|
981 tone, |
|
982 graphic, |
|
983 graphicMask, |
|
984 animation, |
|
985 softkeys, |
|
986 preallocatedNoteId ); |
|
987 break; |
|
988 |
|
989 case EAknGlobalErrorNote: |
|
990 noteId = AddNoteToQueueL( R_ERROR_CONTROL, |
|
991 text, |
|
992 priority, |
|
993 CAknNoteDialog::ELongTimeout, |
|
994 CAknNoteDialog::EErrorTone, |
|
995 tone, |
|
996 graphic, |
|
997 graphicMask, |
|
998 animation, |
|
999 softkeys, |
|
1000 preallocatedNoteId ); |
|
1001 break; |
|
1002 |
|
1003 case EAknGlobalWaitNote: |
|
1004 noteId = AddNoteToQueueL( R_WAIT_CONTROL, |
|
1005 text, |
|
1006 priority, |
|
1007 CAknNoteDialog::ENoTimeout, |
|
1008 CAknNoteDialog::ENoTone, |
|
1009 tone, |
|
1010 graphic, |
|
1011 graphicMask, |
|
1012 animation, |
|
1013 softkeys, |
|
1014 preallocatedNoteId ); |
|
1015 break; |
|
1016 |
|
1017 case EAknGlobalPermanentNote: |
|
1018 noteId = AddNoteToQueueL( R_PERMANENT_CONTROL, |
|
1019 text, |
|
1020 priority, |
|
1021 CAknNoteDialog::ENoTimeout, |
|
1022 CAknNoteDialog::ENoTone, |
|
1023 tone, |
|
1024 graphic, |
|
1025 graphicMask, |
|
1026 animation, |
|
1027 0, // softkeys |
|
1028 preallocatedNoteId ); |
|
1029 break; |
|
1030 |
|
1031 case EAknGlobalChargingNote: |
|
1032 noteId = AddNoteToQueueL( R_BATTERY_CHARGING_CONTROL, |
|
1033 priority, |
|
1034 tone, |
|
1035 preallocatedNoteId ); |
|
1036 break; |
|
1037 |
|
1038 case EAknGlobalNotChargingNote: |
|
1039 noteId = AddNoteToQueueL( R_BATTERY_NOT_CHARGING_CONTROL, |
|
1040 priority, |
|
1041 tone, |
|
1042 preallocatedNoteId ); |
|
1043 break; |
|
1044 |
|
1045 case EAknGlobalBatteryFullNote: |
|
1046 noteId = AddNoteToQueueL( R_BATTERY_FULL_CONTROL, |
|
1047 priority, |
|
1048 tone, |
|
1049 preallocatedNoteId ); |
|
1050 break; |
|
1051 |
|
1052 case EAknGlobalBatteryLowNote: |
|
1053 noteId = AddNoteToQueueL( R_BATTERY_LOW_CONTROL, |
|
1054 priority, |
|
1055 tone, |
|
1056 preallocatedNoteId ); |
|
1057 break; |
|
1058 |
|
1059 case EAknGlobalRechargeBatteryNote: |
|
1060 noteId = AddNoteToQueueL( R_RECHARGE_BATTERY_CONTROL, |
|
1061 priority, |
|
1062 tone, |
|
1063 preallocatedNoteId ); |
|
1064 break; |
|
1065 |
|
1066 case EAknCancelGlobalNote: |
|
1067 CancelNote( priority ); |
|
1068 break; |
|
1069 |
|
1070 case EAknGlobalTextNote: |
|
1071 noteId = AddNoteToQueueL( R_NOTE_PLAIN_TEXT_CONTROL, |
|
1072 text, |
|
1073 priority, |
|
1074 CAknNoteDialog::ELongTimeout, |
|
1075 CAknNoteDialog::EConfirmationTone, |
|
1076 tone, |
|
1077 graphic, |
|
1078 graphicMask, |
|
1079 animation, |
|
1080 softkeys, |
|
1081 preallocatedNoteId ); |
|
1082 break; |
|
1083 |
|
1084 case EAknGlobalBatteryFullUnplugNote: |
|
1085 noteId = AddNoteToQueueL( R_BATTERY_FULL_UNPLUG_CONTROL, |
|
1086 priority, |
|
1087 tone, |
|
1088 preallocatedNoteId ); |
|
1089 break; |
|
1090 |
|
1091 case EAknGlobalUnplugChargerNote: |
|
1092 noteId = AddNoteToQueueL( R_UNPLUG_CHARGER_CONTROL, |
|
1093 priority, |
|
1094 tone, |
|
1095 preallocatedNoteId ); |
|
1096 break; |
|
1097 |
|
1098 default: |
|
1099 break; |
|
1100 } |
|
1101 |
|
1102 if( type == EAknGlobalChargingNote || |
|
1103 type == EAknGlobalNotChargingNote || |
|
1104 type == EAknGlobalBatteryFullNote || |
|
1105 type == EAknGlobalBatteryLowNote || |
|
1106 type == EAknGlobalRechargeBatteryNote || |
|
1107 type == EAknGlobalBatteryFullUnplugNote || |
|
1108 type == EAknGlobalUnplugChargerNote ) |
|
1109 { |
|
1110 Note(noteId)->iGlobalPopupPriority = 1; |
|
1111 } |
|
1112 |
|
1113 TBool sdDataSet( EFalse ); |
|
1114 |
|
1115 if ( noteId != KErrNotFound && iGlobalNoteList ) // we are not in cancel state |
|
1116 { |
|
1117 TInt index = NoteIndex(noteId); |
|
1118 if ( index != KErrNotFound && iGlobalNoteList->Count() > index ) |
|
1119 { |
|
1120 // Is global note adapter used. |
|
1121 (*iGlobalNoteList)[index]->iIsFromAdapter = adapterTypesUsed; |
|
1122 (*iGlobalNoteList)[index]->iTextProcessing = textProcessing; |
|
1123 } |
|
1124 if ( index != KErrNotFound && secondaryDisplayInfo->iDialogIdx != 0 ) |
|
1125 { |
|
1126 sdDataSet = SetSDData( noteId, secondaryDisplayInfo ); |
|
1127 } |
|
1128 } |
|
1129 |
|
1130 if ( sdDataSet ) |
|
1131 { |
|
1132 CleanupStack::Pop( secondaryDisplayInfo ); |
|
1133 } |
|
1134 else // secondaryDisplayInfo ownership not transferred |
|
1135 { |
|
1136 CleanupStack::PopAndDestroy( secondaryDisplayInfo ); |
|
1137 } |
|
1138 |
|
1139 #ifdef _DEBUG |
|
1140 _LIT(KDmsg, "AknGlobalNote, StartL:id %d,type %d,prior %d"); |
|
1141 RDebug::Print(KDmsg,noteId,type,priority); |
|
1142 #endif |
|
1143 |
|
1144 TryDisplayNextNoteL(ETrue); |
|
1145 |
|
1146 iRetPckg().iNoteId = noteId; |
|
1147 return iRetPckg; |
|
1148 } |
|
1149 |
|
1150 CAknGlobalNoteSubject::~CAknGlobalNoteSubject() |
|
1151 { |
|
1152 // Stop subscribe for autolock status changes in PubSub. |
|
1153 if (iAutolockStatusSubscriber) |
|
1154 { |
|
1155 iAutolockStatusSubscriber->StopSubscribe(); |
|
1156 } |
|
1157 iAutolockStatusProperty.Close(); |
|
1158 delete iAutolockStatusSubscriber; |
|
1159 |
|
1160 delete iDialogController; |
|
1161 delete iGlobalNote; |
|
1162 delete iDisplayCallback; |
|
1163 iKeyLockController->RemoveObserver(this); |
|
1164 delete iEcsDetector; |
|
1165 |
|
1166 if ( iGlobalNoteList ) |
|
1167 { |
|
1168 TInt count = iGlobalNoteList->Count(); |
|
1169 for ( TInt i = count - 1; i > KErrNotFound; i-- ) |
|
1170 { |
|
1171 delete (*iGlobalNoteList)[i]; |
|
1172 } |
|
1173 delete iGlobalNoteList; |
|
1174 } |
|
1175 |
|
1176 delete iIdle; |
|
1177 delete iAlarmData; |
|
1178 |
|
1179 if ( iMessageReaderLongPressDetector ) |
|
1180 { |
|
1181 delete iMessageReaderLongPressDetector; |
|
1182 } |
|
1183 } |
|
1184 |
|
1185 void CAknGlobalNoteSubject::Release() |
|
1186 { |
|
1187 delete this; |
|
1188 } |
|
1189 |
|
1190 CAknGlobalNoteSubject::TNotifierInfo CAknGlobalNoteSubject::RegisterL() |
|
1191 { |
|
1192 iInfo.iUid = KAknGlobalNoteUid; |
|
1193 iInfo.iChannel=EAknNotifierChannelNote; |
|
1194 iInfo.iPriority = ENotifierPriorityVHigh; |
|
1195 return iInfo; |
|
1196 } |
|
1197 |
|
1198 CAknGlobalNoteSubject::TNotifierInfo CAknGlobalNoteSubject::Info() const |
|
1199 { |
|
1200 return iInfo; |
|
1201 } |
|
1202 |
|
1203 void CAknGlobalNoteSubject::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, |
|
1204 const RMessagePtr2& aMessage) |
|
1205 { |
|
1206 RDesReadStream readStream(aBuffer); |
|
1207 |
|
1208 // TInt32 takes four chars. |
|
1209 if (aBuffer.Length() >= 4 && readStream.ReadInt32L() == KAKNNOTIFIERSIGNATURE_GETNOTEID) |
|
1210 { |
|
1211 aMessage.Complete(KErrNotSupported); |
|
1212 return; |
|
1213 } |
|
1214 |
|
1215 StartL(aBuffer); |
|
1216 TInt noteId = iRetPckg().iNoteId; |
|
1217 |
|
1218 if (noteId == KErrNotFound) |
|
1219 { |
|
1220 aMessage.Complete(KErrNone); |
|
1221 return; |
|
1222 } |
|
1223 |
|
1224 // returns correct info or panics, no need to error handling here |
|
1225 CGlobalNoteInfo* info = Note(noteId); |
|
1226 |
|
1227 info->iAsync = ETrue; |
|
1228 info->iMessage = aMessage; |
|
1229 #ifdef _DEBUG |
|
1230 _LIT(KDmsg, "AknGlobalNote, async StartL:id %d,prior %d"); |
|
1231 RDebug::Print(KDmsg,noteId,info->iPriority); |
|
1232 #endif |
|
1233 } |
|
1234 |
|
1235 void CAknGlobalNoteSubject::Cancel() |
|
1236 { |
|
1237 CancelOustandingRequests(); |
|
1238 } |
|
1239 |
|
1240 TPtrC8 CAknGlobalNoteSubject::UpdateL(const TDesC8& aBuffer) |
|
1241 { |
|
1242 #ifdef _DEBUG |
|
1243 _LIT(KDmsg,"AknGlobalNote, UpdateL"); |
|
1244 RDebug::Print(KDmsg); |
|
1245 #endif |
|
1246 return StartL(aBuffer); |
|
1247 } |
|
1248 |
|
1249 void CAknGlobalNoteSubject::KeyPressed(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) |
|
1250 { |
|
1251 } |
|
1252 |
|
1253 TInt CAknGlobalNoteSubject::AddNoteToQueueL( |
|
1254 TInt aResourceId, |
|
1255 const TDesC& aText, |
|
1256 TInt aPriority, |
|
1257 CAknNoteDialog::TTimeout aTimeout, |
|
1258 CAknNoteDialog::TTone aDefaultTone, |
|
1259 TInt aUserTone, |
|
1260 TInt aGraphic, |
|
1261 TInt aGraphicMask, |
|
1262 TInt aAnimation, |
|
1263 TInt aSoftkeys) |
|
1264 { |
|
1265 return AddNoteToQueueL( |
|
1266 aResourceId, |
|
1267 aText, |
|
1268 aPriority, |
|
1269 aTimeout, |
|
1270 aDefaultTone, |
|
1271 aUserTone, |
|
1272 aGraphic, |
|
1273 aGraphicMask, |
|
1274 aAnimation, |
|
1275 aSoftkeys, |
|
1276 0); |
|
1277 } |
|
1278 |
|
1279 TInt CAknGlobalNoteSubject::AddNoteToQueueL( |
|
1280 TInt aResourceId, |
|
1281 const TDesC& aText, |
|
1282 TInt aPriority, |
|
1283 CAknNoteDialog::TTimeout aTimeout, |
|
1284 CAknNoteDialog::TTone aDefaultTone, |
|
1285 TInt aUserTone, |
|
1286 TInt aGraphic, |
|
1287 TInt aGraphicMask, |
|
1288 TInt aAnimation, |
|
1289 TInt aSoftkeys, |
|
1290 TInt aPreAllocatedNoteId) |
|
1291 { |
|
1292 if (!IsPreallocatedNoteIdValid(aPreAllocatedNoteId)) |
|
1293 { |
|
1294 return KErrNotFound; |
|
1295 } |
|
1296 |
|
1297 // Check that note doesn't already exist |
|
1298 TInt count = iGlobalNoteList->Count(); |
|
1299 for (TInt ii=0; ii<count; ii++) |
|
1300 { |
|
1301 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1302 if (info->iResourceId == aResourceId) |
|
1303 { |
|
1304 if (info->iText.Compare(aText) == 0) |
|
1305 { |
|
1306 return KErrNotFound; |
|
1307 } |
|
1308 } |
|
1309 } |
|
1310 |
|
1311 CGlobalNoteInfo* info = new (ELeave) CGlobalNoteInfo(); |
|
1312 |
|
1313 if (aPreAllocatedNoteId) |
|
1314 { |
|
1315 info->iNoteId = aPreAllocatedNoteId; |
|
1316 } |
|
1317 else |
|
1318 { |
|
1319 info->iNoteId = iNoteId++; |
|
1320 } |
|
1321 |
|
1322 info->iResourceId = aResourceId; |
|
1323 info->iTimeOut = aTimeout; |
|
1324 if (aSoftkeys) |
|
1325 { |
|
1326 info->iTimeOut = CAknNoteDialog::ENoTimeout; |
|
1327 } |
|
1328 CAknNoteDialog::TTone tone = aDefaultTone; |
|
1329 if (aUserTone != -1) |
|
1330 { |
|
1331 tone = (CAknNoteDialog::TTone)aUserTone; |
|
1332 } |
|
1333 info->iTone = tone; |
|
1334 info->iText.Copy(aText); |
|
1335 info->iPriority = aPriority; |
|
1336 info->iSoftkeys = aSoftkeys; |
|
1337 info->iGraphic = aGraphic; |
|
1338 info->iGraphicMask = aGraphicMask; |
|
1339 info->iAnimation = aAnimation; |
|
1340 iGlobalNoteList->AppendL( info ); |
|
1341 |
|
1342 iGlobalNote->SetNumberOfBorders( StackCount() ); |
|
1343 |
|
1344 return info->iNoteId; |
|
1345 } |
|
1346 |
|
1347 TInt CAknGlobalNoteSubject::AddNoteToQueueL(TInt aResourceId, TInt aPriority, TInt aTone, |
|
1348 TInt aPreAllocatedNoteId) |
|
1349 { |
|
1350 if (!IsPreallocatedNoteIdValid(aPreAllocatedNoteId)) |
|
1351 { |
|
1352 return KErrNotFound; |
|
1353 } |
|
1354 |
|
1355 // Check that note doesn't already exist |
|
1356 TInt count = iGlobalNoteList->Count(); |
|
1357 for (TInt ii=0; ii<count; ii++) |
|
1358 { |
|
1359 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1360 if (info->iResourceId == aResourceId) |
|
1361 { |
|
1362 return KErrNotFound; |
|
1363 } |
|
1364 } |
|
1365 |
|
1366 CGlobalNoteInfo* info = new (ELeave) CGlobalNoteInfo(); |
|
1367 |
|
1368 if (aPreAllocatedNoteId) |
|
1369 { |
|
1370 info->iNoteId = aPreAllocatedNoteId; |
|
1371 } |
|
1372 else |
|
1373 { |
|
1374 info->iNoteId = iNoteId++; |
|
1375 } |
|
1376 |
|
1377 info->iResourceId = aResourceId; |
|
1378 info->iTimeOut = CAknNoteDialog::EShortTimeout; |
|
1379 CAknNoteDialog::TTone tone = CAknNoteDialog::ENoTone; |
|
1380 if (aTone != -1) |
|
1381 { |
|
1382 tone = (CAknNoteDialog::TTone)aTone; |
|
1383 } |
|
1384 info->iTone = tone; |
|
1385 info->iPriority = aPriority; |
|
1386 iGlobalNoteList->AppendL( info ); |
|
1387 |
|
1388 iGlobalNote->SetNumberOfBorders( StackCount() ); |
|
1389 |
|
1390 return info->iNoteId; |
|
1391 } |
|
1392 |
|
1393 |
|
1394 TInt CAknGlobalNoteSubject::AddSoftNotificationL(const TDesC& aText, TInt aResource, TInt aCount, |
|
1395 TInt aPriority, TInt aSoftkeys, TInt aTone) |
|
1396 { |
|
1397 CGlobalNoteInfo* info = new (ELeave) CGlobalNoteInfo(); |
|
1398 info->iNoteId = iNoteId++; |
|
1399 info->iText.Copy(aText); |
|
1400 info->iResourceId = aResource; |
|
1401 info->iTimeOut = CAknNoteDialog::ENoTimeout; |
|
1402 info->iTone = CAknNoteDialog::TTone(aTone); |
|
1403 info->iPriority = aPriority; |
|
1404 info->iSoftkeys = aSoftkeys; |
|
1405 info->iPlural = aCount; |
|
1406 iGlobalNoteList->AppendL( info ); |
|
1407 |
|
1408 iGlobalNote->SetNumberOfBorders( StackCount() ); |
|
1409 |
|
1410 return info->iNoteId; |
|
1411 } |
|
1412 |
|
1413 TInt CAknGlobalNoteSubject::AddSoftNotificationL( |
|
1414 const TDesC& aText, |
|
1415 TInt aCount, |
|
1416 TInt aPriority, |
|
1417 TInt aTone, |
|
1418 const TDesC& aLeftSK, |
|
1419 const TDesC& aRightSK, |
|
1420 const TDesC8& aImage ) |
|
1421 { |
|
1422 CGlobalNoteInfo* info = new (ELeave) CGlobalNoteInfo(); |
|
1423 CleanupStack::PushL( info ); |
|
1424 info->iNoteId = iNoteId++; |
|
1425 // use resource if no image is defined to clear the previous image |
|
1426 info->iResourceId = |
|
1427 aImage.Length() > 0 ? 0 : R_NEW_DYNAMIC_NOTIFIER_NOTE; |
|
1428 info->iText.Copy( aText.Left( KGlobalNoteTextLength ) ); |
|
1429 info->iSoftkeys = R_AVKON_SOFTKEYS_SHOW_EXIT__SHOW; |
|
1430 info->iTimeOut = CAknNoteDialog::ENoTimeout; |
|
1431 info->iTone = CAknNoteDialog::TTone(aTone); |
|
1432 info->iPriority = aPriority; |
|
1433 info->iPlural = aCount; |
|
1434 |
|
1435 // extended custom parameters |
|
1436 info->iImage.Set( aImage ); |
|
1437 info->iRightSK.Set( aRightSK ); |
|
1438 info->iLeftSK.Set( aLeftSK ); |
|
1439 |
|
1440 iGlobalNoteList->AppendL( info ); |
|
1441 CleanupStack::Pop( info ); |
|
1442 iGlobalNote->SetNumberOfBorders( StackCount() ); |
|
1443 return info->iNoteId; |
|
1444 } |
|
1445 |
|
1446 void CAknGlobalNoteSubject::TryDisplayNextNoteL(TBool aShowAsynch) |
|
1447 { |
|
1448 if ( iGlobalNoteList && iGlobalNoteList->Count() == 0 ) |
|
1449 { |
|
1450 return; |
|
1451 } |
|
1452 |
|
1453 #ifdef _DEBUG |
|
1454 _LIT(KDmsg, "AknGlobalNote, TryDisplayNextNoteL:displaying %d"); |
|
1455 RDebug::Print(KDmsg,iDisplayingNoteId); |
|
1456 #endif |
|
1457 |
|
1458 if (iDisplayingNoteId == KErrNotFound) |
|
1459 { |
|
1460 // Note current note, so display as normal |
|
1461 if (!aShowAsynch) |
|
1462 { |
|
1463 DisplayNextNoteL(); |
|
1464 } |
|
1465 else if (!iDisplayCallback->IsActive()) |
|
1466 { |
|
1467 iDisplayCallback->CallBack(); |
|
1468 } |
|
1469 } |
|
1470 else |
|
1471 { |
|
1472 TInt highIndex; |
|
1473 TInt highPriority; |
|
1474 CGlobalNoteInfo* info = Note( iDisplayingNoteId ); |
|
1475 // we don't want add any note on top of alarm note ( at least currently ) |
|
1476 if (info->iPriority == KAlarmNotePriority ) |
|
1477 { |
|
1478 return; |
|
1479 } |
|
1480 |
|
1481 HighestPriorityNote(highIndex, highPriority); |
|
1482 if (highPriority > iCurrentPriority) |
|
1483 { |
|
1484 if (iSoftNoteObserver) |
|
1485 { |
|
1486 iSoftNoteObserver->CancelSoftNote(info->iPriority); |
|
1487 } |
|
1488 if (iNotificationDialogObserver ) |
|
1489 { |
|
1490 iNotificationDialogObserver->CancelSoftNote(info->iPriority); |
|
1491 } |
|
1492 iDisplayingNoteId = KErrNotFound; |
|
1493 if (!aShowAsynch) |
|
1494 { |
|
1495 DisplayNextNoteL(); |
|
1496 iCurrentPriority = highPriority; |
|
1497 } |
|
1498 else if (!iDisplayCallback->IsActive()) |
|
1499 { |
|
1500 iDisplayCallback->CallBack(); |
|
1501 } |
|
1502 } |
|
1503 } |
|
1504 } |
|
1505 |
|
1506 |
|
1507 void CAknGlobalNoteSubject::HighestPriorityNote(TInt& aIndex, TInt& aPriority) |
|
1508 { |
|
1509 // Priority of notes: |
|
1510 // First added non-waiting note in queue has priority |
|
1511 // If no non-waiting notes added, first added waiting note |
|
1512 // Notes with a prioriy higher than iMaxDisplayPriority are ignored |
|
1513 TInt priority = KMinTInt; |
|
1514 TInt index = KErrNotFound; |
|
1515 TInt count = iGlobalNoteList->Count(); |
|
1516 for (TInt ii=0; ii<count; ii++) |
|
1517 { |
|
1518 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1519 if (info->iPriority < iMaxDisplayPriority || info->iPriority > iMaxDisplayPriorityLimit) |
|
1520 { |
|
1521 TInt actualPriority = info->iPriority; |
|
1522 if (info->iTimeOut != CAknNoteDialog::ENoTimeout) |
|
1523 { |
|
1524 // Boost priority of non-waiting notes, so that |
|
1525 // they interrupt soft notifications |
|
1526 actualPriority += KMaxNotePriority; |
|
1527 } |
|
1528 if (actualPriority > priority) |
|
1529 { |
|
1530 priority = actualPriority; |
|
1531 index = ii; |
|
1532 } |
|
1533 } |
|
1534 } |
|
1535 aIndex = index; |
|
1536 aPriority = priority; |
|
1537 } |
|
1538 |
|
1539 |
|
1540 void CAknGlobalNoteSubject::DisplayNextNoteL() |
|
1541 { |
|
1542 if (iDisplayCallback->IsActive()) |
|
1543 { |
|
1544 iDisplayCallback->Cancel(); |
|
1545 } |
|
1546 |
|
1547 if ( iMessageReaderLongPressDetector ) |
|
1548 { |
|
1549 iMessageReaderLongPressDetector->SoftNotifierVisible( EFalse ); |
|
1550 } |
|
1551 |
|
1552 // Count permanent notes and see if ECS should be turned on/off |
|
1553 TInt permanentNoteCount = PermanentNotesCount(); |
|
1554 if ( permanentNoteCount > 0 ) |
|
1555 { |
|
1556 iEcsDetector->ConnectToEventSource(); |
|
1557 } |
|
1558 else |
|
1559 { |
|
1560 iEcsDetector->CloseEventSource(); |
|
1561 iEcsDetector->Reset(); // Ecs queue is cleared; keys up til here are forgotten |
|
1562 } |
|
1563 |
|
1564 TInt count = iGlobalNoteList->Count(); |
|
1565 if (iDisplayingNoteId != KErrNotFound || count == 0) |
|
1566 { |
|
1567 return; |
|
1568 } |
|
1569 |
|
1570 // Find next highest priority note |
|
1571 |
|
1572 TInt priority = KMinTInt; |
|
1573 TInt index = 0; |
|
1574 HighestPriorityNote(index, priority); |
|
1575 if (index == KErrNotFound) |
|
1576 { |
|
1577 return; |
|
1578 } |
|
1579 |
|
1580 CGlobalNoteInfo* info = (*iGlobalNoteList)[index]; |
|
1581 |
|
1582 if (iSoftNoteObserver) |
|
1583 { |
|
1584 |
|
1585 // activate long press detector if soft notification is shown |
|
1586 if ( iMessageReaderLongPressDetector ) |
|
1587 { |
|
1588 TBool isSoftNotification = ( info->iPriority >= KMinimumSoftNotePriority && |
|
1589 info->iPriority <= KMaxSoftNotePriority ); |
|
1590 if ( isSoftNotification ) |
|
1591 { |
|
1592 iMessageReaderLongPressDetector->SoftNotifierVisible( ETrue ); |
|
1593 } |
|
1594 } |
|
1595 if (iSoftNoteObserver->ShowSoftNoteL( info->iPriority, info->iText ) ) |
|
1596 { |
|
1597 // Soft note is being displayed instead |
|
1598 iDisplayingNoteId = info->iNoteId; |
|
1599 #ifdef _DEBUG |
|
1600 _LIT(KDmsg, "AknGlobalNote, DisplayNextNoteL:SoftNote %d"); |
|
1601 RDebug::Print( KDmsg, info->iPriority ); |
|
1602 #endif |
|
1603 return; |
|
1604 } |
|
1605 } |
|
1606 if (iNotificationDialogObserver) |
|
1607 { |
|
1608 if (iNotificationDialogObserver->ShowSoftNoteL(info->iPriority, info->iText)) |
|
1609 { |
|
1610 // Get rid of any current global note |
|
1611 iGlobalNote->RemoveCurrentNote(); |
|
1612 // Notifier note is being displayed instead |
|
1613 iDisplayingNoteId = info->iNoteId; |
|
1614 #ifdef _DEBUG |
|
1615 _LIT(KDmsg2, "AknGlobalNote, DisplayNextNoteL:Other type %d"); |
|
1616 RDebug::Print(KDmsg2,info->iPriority); |
|
1617 #endif |
|
1618 return; |
|
1619 } |
|
1620 } |
|
1621 |
|
1622 iGlobalNote->UpdateNoteAndDisplayL(info); |
|
1623 |
|
1624 // display stack indicator, if more than 1 note pending |
|
1625 iGlobalNote->SetNumberOfBorders(StackCount()); |
|
1626 |
|
1627 iDisplayingNoteId = info->iNoteId; |
|
1628 iCurrentPriority = priority; |
|
1629 #ifdef _DEBUG |
|
1630 _LIT(KDmsg3, "AknGlobalNote, DisplayNextNoteL:Normal: %d"); |
|
1631 RDebug::Print(KDmsg3,info->iPriority); |
|
1632 #endif |
|
1633 } |
|
1634 |
|
1635 |
|
1636 void CAknGlobalNoteSubject::GlobalNoteCompleted(TInt aCommand) |
|
1637 { |
|
1638 iCurrentPriority = KMinTInt; |
|
1639 if (iDisplayingNoteId == KErrNotFound) |
|
1640 { |
|
1641 return; |
|
1642 } |
|
1643 CGlobalNoteInfo* info = Note( iDisplayingNoteId ); |
|
1644 |
|
1645 #ifdef _DEBUG |
|
1646 _LIT(KDmsg, "AknGlobalNote, NoteCompleted:Command %d, id %d"); |
|
1647 RDebug::Print(KDmsg,aCommand, info->iNoteId); |
|
1648 #endif |
|
1649 |
|
1650 if ( iSoftNoteObserver && info->iPriority >= KMinimumSoftNotePriority) |
|
1651 { |
|
1652 iSoftNoteObserver->SoftNoteCompleted(info->iNoteId, aCommand); |
|
1653 } |
|
1654 if (iNotificationDialogObserver) |
|
1655 { |
|
1656 iNotificationDialogObserver->SoftNoteCompleted(info->iNoteId, aCommand); |
|
1657 if ( aCommand == EAlertSilence ) |
|
1658 { |
|
1659 CAknMediatorFacade* coverData = AknMediatorFacade( iGlobalNote ); |
|
1660 if ( coverData ) |
|
1661 { |
|
1662 SAknIntegerUpdate s = |
|
1663 { |
|
1664 EAknGlobalNotifierUpdateSoftkeys, |
|
1665 R_ALERT_SOFTKEYS_STOP_SNOOZE |
|
1666 }; |
|
1667 |
|
1668 TPckg<SAknIntegerUpdate> pck(s); |
|
1669 coverData->ResetBuffer(); |
|
1670 coverData->BufStream() << pck; |
|
1671 TRAP_IGNORE( |
|
1672 coverData->BufStream().CommitL(); |
|
1673 coverData->PostUpdatedDataL(); |
|
1674 ); |
|
1675 } |
|
1676 return; |
|
1677 } |
|
1678 else if ( aCommand == EAlertOpen ) |
|
1679 { |
|
1680 // Works the same way as the "silence" key...don't complete/close the note. |
|
1681 return; |
|
1682 } |
|
1683 } |
|
1684 if (info->iAsync) |
|
1685 { |
|
1686 if (info->iIsFromAdapter) // if adapter is in use, we need to change softkey |
|
1687 { // enumeration according to GlobalNote.h |
|
1688 if ( aCommand == EAknSoftkeyOk ) |
|
1689 { |
|
1690 info->iMessage.Complete( 1 ); // EGlobalNoteResultOk = 1, |
|
1691 } |
|
1692 else if ( aCommand == EAknSoftkeyExit ) |
|
1693 { |
|
1694 info->iMessage.Complete( 2 ); // EGlobalNoteResultExit = 2, |
|
1695 } |
|
1696 else if ( aCommand == EAknSoftkeyCancel ) |
|
1697 { |
|
1698 info->iMessage.Complete( 3 ); // EGlobalNoteResultCancel = 3, |
|
1699 } |
|
1700 else if ( aCommand == EAknSoftkeyBack ) |
|
1701 { |
|
1702 info->iMessage.Complete( 4 ); // EGlobalNoteResultBack = 4, |
|
1703 } |
|
1704 else if ( aCommand == EAknSoftkeyClose ) |
|
1705 { |
|
1706 info->iMessage.Complete( 5 ); // EGlobalNoteResultClose = 5, |
|
1707 } |
|
1708 else if ( aCommand == EAknSoftkeyQuit ) |
|
1709 { |
|
1710 info->iMessage.Complete( 6 ); // EGlobalNoteResultQuit = 6, |
|
1711 } |
|
1712 else if ( aCommand == EAknSoftkeyYes ) |
|
1713 { |
|
1714 info->iMessage.Complete( 7 ); // EGlobalNoteResultYes = 7, |
|
1715 } |
|
1716 else if ( aCommand == EAknSoftkeyNo ) |
|
1717 { |
|
1718 info->iMessage.Complete( 8 ); // EGlobalNoteResultNo = 8, |
|
1719 } |
|
1720 else if ( aCommand == EAknSoftkeyShow ) |
|
1721 { |
|
1722 info->iMessage.Complete( 9 ); // EGlobalNoteResultAnswer = 9 |
|
1723 } |
|
1724 else // Default: |
|
1725 { |
|
1726 info->iMessage.Complete(KErrCancel); |
|
1727 } |
|
1728 } |
|
1729 else // return S60 softkeyId |
|
1730 { |
|
1731 info->iMessage.Complete(aCommand); |
|
1732 } |
|
1733 info->iAsync = EFalse; |
|
1734 } |
|
1735 |
|
1736 iGlobalNoteList->Delete( NoteIndex( iDisplayingNoteId ) ); |
|
1737 delete info; |
|
1738 info = NULL; |
|
1739 |
|
1740 iDisplayingNoteId = KErrNotFound; |
|
1741 |
|
1742 // Call DisplayNextNoteL via a async callback. |
|
1743 iDisplayCallback->CallBack(); |
|
1744 } |
|
1745 |
|
1746 TInt CAknGlobalNoteSubject::CallDisplayNextNote( TAny* aThis ) |
|
1747 { |
|
1748 // Need to trap this, since this may be called from destructor of |
|
1749 // prevous global note. |
|
1750 // Worst situation is that global note will not be displayed immediately, |
|
1751 // and sit in queue until another global note is displayed. |
|
1752 TRAP_IGNORE( STATIC_CAST( CAknGlobalNoteSubject*, aThis )->DisplayNextNoteL() ); |
|
1753 return 0; |
|
1754 } |
|
1755 |
|
1756 void CAknGlobalNoteSubject::SetMessageNotifierObserver( MAknMessageNotifierObserver* aMessageNotifierObserver ) |
|
1757 { |
|
1758 if ( iMessageReaderLongPressDetector ) |
|
1759 { |
|
1760 iMessageReaderLongPressDetector->SetMessageNotifierObserver( aMessageNotifierObserver ); |
|
1761 } |
|
1762 } |
|
1763 |
|
1764 // ----------------------------------------------------------------------------- |
|
1765 // CAknGlobalNoteSubject::CancelNote |
|
1766 // ----------------------------------------------------------------------------- |
|
1767 // |
|
1768 void CAknGlobalNoteSubject::CancelNote( TInt aNoteId, TBool aShowNext ) |
|
1769 { |
|
1770 CancelNote( aNoteId, aShowNext, ETrue ); |
|
1771 } |
|
1772 |
|
1773 |
|
1774 // ----------------------------------------------------------------------------- |
|
1775 // CAknGlobalNoteSubject::CancelNote |
|
1776 // ----------------------------------------------------------------------------- |
|
1777 // |
|
1778 void CAknGlobalNoteSubject::CancelNote( TInt aNoteId, |
|
1779 TBool aShowNext, |
|
1780 TBool aDeleteNoteInfo ) |
|
1781 { |
|
1782 |
|
1783 #ifdef _DEBUG |
|
1784 _LIT( KDmsg, "AknGlobalNote, NoteCompleted:Command %d, id %d" ); |
|
1785 RDebug::Print( KDmsg, aNoteId ); |
|
1786 #endif |
|
1787 |
|
1788 TInt noteIndex = NoteIndex( aNoteId ); |
|
1789 if ( noteIndex == KErrNotFound ) |
|
1790 { |
|
1791 return; |
|
1792 } |
|
1793 |
|
1794 CGlobalNoteInfo* info = Note( aNoteId ); |
|
1795 const TInt priority = info->iPriority; |
|
1796 |
|
1797 if ( iNotificationDialogObserver ) |
|
1798 { |
|
1799 iNotificationDialogObserver->CancelSoftNote( priority ); |
|
1800 } |
|
1801 |
|
1802 if ( iDisplayingNoteId == aNoteId ) |
|
1803 { |
|
1804 // Deleting will also remove note from stack. |
|
1805 if ( !aShowNext ) |
|
1806 { |
|
1807 if ( info->iAsync ) |
|
1808 { |
|
1809 info->iMessage.Complete( KErrCancel ); |
|
1810 info->iAsync = EFalse; |
|
1811 } |
|
1812 |
|
1813 iGlobalNoteList->Delete( noteIndex ); |
|
1814 |
|
1815 if ( aDeleteNoteInfo ) |
|
1816 { |
|
1817 // aDeleteNoteInfo specifies whether or not the note |
|
1818 // is really discarded. |
|
1819 delete info; |
|
1820 info = NULL; |
|
1821 // info should not be accessed any more. |
|
1822 } |
|
1823 |
|
1824 iDisplayingNoteId = KErrNotFound; |
|
1825 } |
|
1826 |
|
1827 if ( iSoftNoteObserver ) |
|
1828 { |
|
1829 // disable long press detector when notification is closed from the screen |
|
1830 if ( iMessageReaderLongPressDetector ) |
|
1831 { |
|
1832 iMessageReaderLongPressDetector->SoftNotifierVisible( EFalse ); |
|
1833 } |
|
1834 TBool noteDeleted = iSoftNoteObserver->CancelSoftNote( priority ); |
|
1835 if ( noteDeleted && aShowNext ) // grouped note was deleted so remove it from queue |
|
1836 { |
|
1837 iGlobalNoteList->Delete( noteIndex ); |
|
1838 |
|
1839 if ( aDeleteNoteInfo ) |
|
1840 { |
|
1841 // aDeleteNoteInfo specifies whether or not the note |
|
1842 // is really discarded. |
|
1843 delete info; |
|
1844 info = NULL; |
|
1845 // info should not be accessed any more. |
|
1846 } |
|
1847 |
|
1848 iDisplayingNoteId = KErrNotFound; |
|
1849 } |
|
1850 } |
|
1851 |
|
1852 iGlobalNote->NextNoteOrExit( ETrue ); |
|
1853 iDisplayingNoteId = KErrNotFound; |
|
1854 } |
|
1855 else |
|
1856 { |
|
1857 // If not displayed, remove note from stack. |
|
1858 if ( info->iAsync ) |
|
1859 { |
|
1860 info->iMessage.Complete( KErrCancel ); |
|
1861 info->iAsync = EFalse; |
|
1862 } |
|
1863 |
|
1864 iGlobalNoteList->Delete( noteIndex ); |
|
1865 |
|
1866 if ( aDeleteNoteInfo ) |
|
1867 { |
|
1868 // aDeleteNoteInfo specifies whether or not the note |
|
1869 // is really discarded. |
|
1870 delete info; |
|
1871 info = NULL; |
|
1872 // info should not be accessed any more. |
|
1873 } |
|
1874 |
|
1875 // Change stack indicator. Display stack indicator, if more than 1 note pending. |
|
1876 iGlobalNote->SetNumberOfBorders( StackCount() ); |
|
1877 } |
|
1878 } |
|
1879 |
|
1880 |
|
1881 void CAknGlobalNoteSubject::CancelOustandingRequests() |
|
1882 { |
|
1883 TInt count = iGlobalNoteList->Count(); |
|
1884 for (TInt ii = count - 1; ii >= 0; ii--) |
|
1885 { |
|
1886 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1887 if ( info->iAsync ) |
|
1888 { |
|
1889 // Only cancelled if the cancelling thread is where the |
|
1890 // global note originated from. |
|
1891 RThread t; |
|
1892 TInt err = info->iMessage.Client(t); |
|
1893 CAknCapAppServerAppUi* appUi = (CAknCapAppServerAppUi*) CEikonEnv::Static()->AppUi(); |
|
1894 if ( !err && ( appUi->iClientId == t.Id() ) ) |
|
1895 { |
|
1896 CancelNote( info->iNoteId ); |
|
1897 } |
|
1898 t.Close(); |
|
1899 } |
|
1900 } |
|
1901 } |
|
1902 |
|
1903 |
|
1904 void CAknGlobalNoteSubject::SetSoftNoteObserver(MSoftNotificationObserver* aObserver) |
|
1905 { |
|
1906 iSoftNoteObserver = aObserver; |
|
1907 } |
|
1908 |
|
1909 void CAknGlobalNoteSubject::SetNotificationDialogObserver(MSoftNotificationObserver* aObserver) |
|
1910 { |
|
1911 iNotificationDialogObserver = aObserver; |
|
1912 } |
|
1913 |
|
1914 TInt CAknGlobalNoteSubject::NotePlural(TInt aNoteId) |
|
1915 { |
|
1916 TInt count = iGlobalNoteList->Count(); |
|
1917 for (TInt ii = 0; ii < count; ii++) |
|
1918 { |
|
1919 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1920 if (info->iNoteId == aNoteId) |
|
1921 { |
|
1922 return info->iPlural; |
|
1923 } |
|
1924 } |
|
1925 return -1; |
|
1926 } |
|
1927 |
|
1928 const TDesC& CAknGlobalNoteSubject::NoteText(TInt aNoteId) |
|
1929 { |
|
1930 TInt count = iGlobalNoteList->Count(); |
|
1931 for (TInt ii = 0; ii < count; ii++) |
|
1932 { |
|
1933 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
1934 if (info->iNoteId == aNoteId) |
|
1935 { |
|
1936 return info->iText; |
|
1937 } |
|
1938 } |
|
1939 return KNullDesC; |
|
1940 } |
|
1941 |
|
1942 void CAknGlobalNoteSubject::SetMaxDisplayPriorityL(TInt aPriority, TInt aDelay) |
|
1943 { |
|
1944 #ifdef _DEBUG |
|
1945 _LIT(KDmsg, "AknGlobalNote, SetMaxDisplayPriorityL: %d"); |
|
1946 RDebug::Print(KDmsg,aPriority); |
|
1947 #endif |
|
1948 |
|
1949 if (iNotesDisabled) |
|
1950 { |
|
1951 iPreviousDisplayPriority = aPriority; |
|
1952 return; |
|
1953 } |
|
1954 |
|
1955 iMaxDisplayPriority = aPriority; |
|
1956 if (iDisplayingNoteId == KErrNotFound) |
|
1957 { |
|
1958 if (aDelay > 0 && iGlobalNoteList->Count() > 0) |
|
1959 { |
|
1960 if (!iDisplayCallback->IsActive()) |
|
1961 { |
|
1962 iDisplayCallback->CallBack(); |
|
1963 } |
|
1964 return; |
|
1965 } |
|
1966 |
|
1967 TryDisplayNextNoteL(); |
|
1968 return; |
|
1969 } |
|
1970 |
|
1971 CGlobalNoteInfo* info = Note( iDisplayingNoteId ); |
|
1972 |
|
1973 if (info->iPriority >= iMaxDisplayPriority) |
|
1974 { |
|
1975 TBool async = info->iAsync; |
|
1976 // Displaying note is higher than max priority, so cancel it. |
|
1977 if ( async ) |
|
1978 { |
|
1979 // Leave note to queue, but remove it from display. |
|
1980 iDisplayingNoteId = KErrNotFound; |
|
1981 iGlobalNote->NextNoteOrExit(); |
|
1982 } |
|
1983 else |
|
1984 { |
|
1985 if ( info->iPriority == KAlarmNotePriority ) |
|
1986 { |
|
1987 // Idle states does not have any effect to alarm. |
|
1988 if ( iMaxDisplayPriority != KMinimumSoftNotePriority ) |
|
1989 { |
|
1990 CancelNote( info->iNoteId, EFalse ); |
|
1991 } |
|
1992 } |
|
1993 else |
|
1994 { |
|
1995 // All the others but alarm note are rescheduled. |
|
1996 CancelNote( info->iNoteId, EFalse, EFalse ); // remove from display, but |
|
1997 // don't delete info object, |
|
1998 // as it's appended back. |
|
1999 iGlobalNoteList->AppendL( info ); // add to queue |
|
2000 } |
|
2001 } |
|
2002 } |
|
2003 |
|
2004 else if ( iGlobalNoteList->Count() > 1 ) // there are other notifications on queue |
|
2005 { |
|
2006 TryDisplayNextNoteL(); |
|
2007 } |
|
2008 } |
|
2009 |
|
2010 TInt CAknGlobalNoteSubject::StackCount() |
|
2011 { |
|
2012 TInt total = 0; |
|
2013 TInt count = iGlobalNoteList->Count(); |
|
2014 for (TInt ii = 0; ii < count; ii++) |
|
2015 { |
|
2016 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
2017 if (info->iPriority < iMaxDisplayPriority) |
|
2018 { |
|
2019 total++; |
|
2020 } |
|
2021 } |
|
2022 return total; |
|
2023 } |
|
2024 |
|
2025 |
|
2026 CGlobalNoteInfo* CAknGlobalNoteSubject::Note(TInt aNoteId) |
|
2027 { |
|
2028 TInt count = iGlobalNoteList->Count(); |
|
2029 for (TInt ii = 0; ii < count; ii++) |
|
2030 { |
|
2031 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
2032 if (info->iNoteId == aNoteId) |
|
2033 { |
|
2034 return info; |
|
2035 } |
|
2036 } |
|
2037 return (*iGlobalNoteList)[0]; |
|
2038 } |
|
2039 |
|
2040 |
|
2041 TInt CAknGlobalNoteSubject::NoteIndex(TInt aNoteId) |
|
2042 { |
|
2043 TInt count = iGlobalNoteList->Count(); |
|
2044 for (TInt ii = 0; ii < count; ii++) |
|
2045 { |
|
2046 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
2047 if ( info->iNoteId == aNoteId ) |
|
2048 { |
|
2049 return ii; |
|
2050 } |
|
2051 } |
|
2052 return KErrNotFound; |
|
2053 } |
|
2054 |
|
2055 TInt CAknGlobalNoteSubject::PermanentNotesCount() const |
|
2056 { |
|
2057 TInt permanentCount = 0; |
|
2058 TInt count = iGlobalNoteList->Count(); |
|
2059 for (TInt ii = 0; ii < count; ii++) |
|
2060 { |
|
2061 const CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
2062 if (info->iPriority < iMaxDisplayPriority) |
|
2063 if ( info->iResourceId == R_PERMANENT_CONTROL ) |
|
2064 { |
|
2065 permanentCount++; |
|
2066 } |
|
2067 } |
|
2068 return permanentCount; |
|
2069 } |
|
2070 |
|
2071 void CAknGlobalNoteSubject::KeyLockStatusChange(TKeyLockStatus aStatus) |
|
2072 { |
|
2073 #ifdef _DEBUG |
|
2074 RDebug::Print(_L("--KeyLockStatusChange aStatus [%d], NoteDisabled [%d], Previous [%d], Limit [%d], Max [%d]"), |
|
2075 aStatus, iNotesDisabled, iPreviousDisplayPriority, iMaxDisplayPriorityLimit, iMaxDisplayPriority); |
|
2076 #endif |
|
2077 |
|
2078 // Handle EKeyLockStopNotifications. |
|
2079 if (aStatus == EKeyLockStopNotifications) |
|
2080 { |
|
2081 if (!iNotesDisabled) |
|
2082 { |
|
2083 iPreviousDisplayPriority = iMaxDisplayPriority; |
|
2084 iMaxDisplayPriorityLimit = KMaxAlarmNotePriority; |
|
2085 // Ignore errors, just means next note may not display at present. |
|
2086 TRAP_IGNORE(SetMaxDisplayPriorityL(KMinTInt)); |
|
2087 iNotesDisabled = ETrue; |
|
2088 #ifdef _DEBUG |
|
2089 _LIT(KDmsg, "--DisableGlobalNotes"); |
|
2090 RDebug::Print(KDmsg); |
|
2091 #endif |
|
2092 } |
|
2093 } |
|
2094 // Handle EKeyLockAllowNotifications. |
|
2095 else if (aStatus == EKeyLockAllowNotifications) |
|
2096 { |
|
2097 if (iNotesDisabled) |
|
2098 { |
|
2099 iNotesDisabled = EFalse; |
|
2100 iMaxDisplayPriorityLimit = KMaxSoftNotePriority; |
|
2101 // Ignore errors, just means next note may not display at present. |
|
2102 TRAP_IGNORE( SetMaxDisplayPriorityL(iPreviousDisplayPriority)); |
|
2103 #ifdef _DEBUG |
|
2104 _LIT(KDmsg2, "--AllowGlobalNotes"); |
|
2105 RDebug::Print(KDmsg2); |
|
2106 #endif |
|
2107 } |
|
2108 } |
|
2109 // Handle EKeyLockCancelNotification. |
|
2110 else if (aStatus == EKeyLockCancelNotification) |
|
2111 { |
|
2112 #ifdef _DEBUG |
|
2113 _LIT(KDmsg3, "--CancelAllGlobalNotes"); |
|
2114 RDebug::Print(KDmsg3); |
|
2115 #endif |
|
2116 // First check to make sure. |
|
2117 if (iDisplayingNoteId >= 0) |
|
2118 { |
|
2119 CGlobalNoteInfo* info = Note(iDisplayingNoteId); |
|
2120 if (info->iResourceId == R_PERMANENT_CONTROL) |
|
2121 { |
|
2122 return; |
|
2123 } |
|
2124 } |
|
2125 |
|
2126 CancelNote(iDisplayingNoteId, EFalse); |
|
2127 |
|
2128 // Cancel all other queued notifications. |
|
2129 TInt count = iGlobalNoteList->Count(); |
|
2130 for (TInt ii = count - 1; ii >= 0; ii--) |
|
2131 { |
|
2132 CGlobalNoteInfo* info = (*iGlobalNoteList)[ii]; |
|
2133 if (info->iPriority < iMaxDisplayPriority && info->iResourceId != R_PERMANENT_CONTROL) |
|
2134 { |
|
2135 CancelNote(info->iNoteId, EFalse); |
|
2136 } |
|
2137 } |
|
2138 SetAppsKeyLocked( EFalse ); |
|
2139 } |
|
2140 // Handle EHideSoftNotifications. |
|
2141 else if ( aStatus == EHideSoftNotifications ) |
|
2142 { |
|
2143 #ifdef _DEBUG |
|
2144 _LIT(KDmsg4, "--HideSoftNotifications"); |
|
2145 RDebug::Print(KDmsg4); |
|
2146 #endif |
|
2147 TRAP_IGNORE(SetMaxDisplayPriorityL(KMinimumSoftNotePriority)); |
|
2148 } |
|
2149 // Handle EShowSoftNotifications. |
|
2150 else if ( aStatus == EShowSoftNotifications ) |
|
2151 { |
|
2152 #ifdef _DEBUG |
|
2153 _LIT(KDmsg5, "--AllowSoftNotifications"); |
|
2154 RDebug::Print(KDmsg5); |
|
2155 #endif |
|
2156 if (iNotesDisabled) |
|
2157 { |
|
2158 // After the max priority is set, we need to restore iNoteDisabled back to ETrue, |
|
2159 // otherwise, it will break EKeyLockAllowNotifications. |
|
2160 iNotesDisabled = EFalse; |
|
2161 TRAP_IGNORE(SetMaxDisplayPriorityL(KMaxTInt, 50000)); |
|
2162 iNotesDisabled = ETrue; |
|
2163 iPreviousDisplayPriority = KMaxTInt; |
|
2164 } |
|
2165 else |
|
2166 { |
|
2167 TRAP_IGNORE(SetMaxDisplayPriorityL(KMaxTInt, 50000)); |
|
2168 } |
|
2169 } |
|
2170 } |
|
2171 |
|
2172 TBool CAknGlobalNoteSubject::NoteWaiting() |
|
2173 { |
|
2174 TInt count = StackCount(); |
|
2175 if (count > 1 && iDisplayingNoteId != KErrNotFound) |
|
2176 { |
|
2177 return ETrue; |
|
2178 } |
|
2179 return EFalse; |
|
2180 } |
|
2181 |
|
2182 TBool CAknGlobalNoteSubject::IsAppsKeyLocked() |
|
2183 { |
|
2184 return iAppsKeyLocked; |
|
2185 } |
|
2186 |
|
2187 void CAknGlobalNoteSubject::SetAppsKeyLocked( TBool aLocked ) |
|
2188 { |
|
2189 if ( ( iAppsKeyLocked && aLocked ) || ( !iAppsKeyLocked && !aLocked ) ) |
|
2190 { |
|
2191 return; |
|
2192 } |
|
2193 |
|
2194 TInt err = ((CAknNotifierAppServerAppUi*)(CEikonEnv::Static())->EikAppUi())-> |
|
2195 SuppressAppSwitching( aLocked ); |
|
2196 |
|
2197 if ( !err ) |
|
2198 { |
|
2199 iAppsKeyLocked = aLocked; |
|
2200 } |
|
2201 } |
|
2202 |
|
2203 TInt CAknGlobalNoteSubject::EnableAutolockEmulation( TAny* aThis ) |
|
2204 { |
|
2205 CAknGlobalNoteSubject& me = *static_cast<CAknGlobalNoteSubject*>(aThis); |
|
2206 me.iKeyLockController->LockKeys(ETrue); |
|
2207 delete me.iIdle; |
|
2208 me.iIdle = 0; |
|
2209 return KErrNone; |
|
2210 } |
|
2211 |
|
2212 |
|
2213 TInt CAknGlobalNoteSubject::DisplayAlarmL( TInt aType, |
|
2214 const TDesC& aDescription, |
|
2215 const TDesC& /*aTime*/ ) |
|
2216 { |
|
2217 |
|
2218 #ifdef _DEBUG |
|
2219 RDebug::Print(_L("CAknGlobalNoteSubject::DisplayAlarmL type [%d], noteId [%d], priority [%d]"), |
|
2220 aType, iDisplayingNoteId, iCurrentPriority); |
|
2221 #endif |
|
2222 |
|
2223 TBuf<KGlobalNoteTextLength> buf; |
|
2224 |
|
2225 // Make sure that buffer will not overflow. |
|
2226 if ( aDescription.Length() > KGlobalNoteTextLength ) |
|
2227 { |
|
2228 buf.Append( aDescription.Left( KGlobalNoteTextLength ) ); |
|
2229 } |
|
2230 else |
|
2231 { |
|
2232 buf.Append( aDescription ); |
|
2233 } |
|
2234 |
|
2235 TInt rid( R_ALARM_CONTROL ); |
|
2236 TInt animation( 0 ); |
|
2237 TInt softkeys( 0 ); |
|
2238 TInt imageId( -1 ); |
|
2239 TInt maskId( -1 ); |
|
2240 |
|
2241 if ( aType & EMskOpen ) // msk |
|
2242 { |
|
2243 if ( aType & EHideSnooze ) // no snooze (+ no silence) |
|
2244 { |
|
2245 // stop_open_empty |
|
2246 softkeys = R_ALERT_SOFTKEYS_STOP_EMPTY__OPEN; |
|
2247 iAlarmData->iAlarmSoftkeys = EAknAlarmStopNone; |
|
2248 } |
|
2249 else if ( aType & ENoSilence ) // no silence |
|
2250 { |
|
2251 // stop_open_snooze |
|
2252 softkeys = R_ALERT_SOFTKEYS_STOP_SNOOZE__OPEN; |
|
2253 iAlarmData->iAlarmSoftkeys = EAknAlarmStopSnooze; |
|
2254 } |
|
2255 else // silence |
|
2256 { |
|
2257 // stop_open_silence |
|
2258 softkeys = R_ALERT_SOFTKEYS_STOP_SILENT__OPEN; |
|
2259 iAlarmData->iAlarmSoftkeys = EAknAlarmStopSilent; |
|
2260 } |
|
2261 } |
|
2262 else // no msk |
|
2263 { |
|
2264 if ( aType & EHideSnooze ) // no snooze (+ no silence) |
|
2265 { |
|
2266 // stop_empty_empty |
|
2267 softkeys = R_ALERT_SOFTKEYS_STOP_EMPTY__EMPTY; |
|
2268 iAlarmData->iAlarmSoftkeys = EAknAlarmStopNone; |
|
2269 } |
|
2270 else if ( aType & ENoSilence ) // no snooze |
|
2271 { |
|
2272 // stop_empty_snooze |
|
2273 softkeys = R_ALERT_SOFTKEYS_STOP_SNOOZE; |
|
2274 iAlarmData->iAlarmSoftkeys = EAknAlarmStopSnooze; |
|
2275 } |
|
2276 else // silence |
|
2277 { |
|
2278 // stop_empty_silence |
|
2279 softkeys = R_ALERT_SOFTKEYS_STOP_SILENT; |
|
2280 iAlarmData->iAlarmSoftkeys = EAknAlarmStopSilent; |
|
2281 } |
|
2282 } |
|
2283 |
|
2284 if ( aType & EClockAlarm ) |
|
2285 { |
|
2286 // animation = R_ANIM_CLOCK_ALARM; |
|
2287 imageId = EMbmAvkonQgn_note_alarm_clock; |
|
2288 maskId = EMbmAvkonQgn_note_alarm_clock_mask; |
|
2289 } |
|
2290 |
|
2291 else if ( aType & ECalendarAlarm ) |
|
2292 { |
|
2293 // animation = R_ANIM_CALENDAR_ALARM; |
|
2294 imageId = EMbmAvkonQgn_note_alarm_calendar; |
|
2295 maskId = EMbmAvkonQgn_note_alarm_calendar_mask; |
|
2296 } |
|
2297 else if ( aType == EAskWakeUp ) |
|
2298 { |
|
2299 animation = R_QGN_NOTE_QUERY_ANIM; |
|
2300 softkeys = R_AVKON_SOFTKEYS_YES_NO__YES; |
|
2301 } |
|
2302 |
|
2303 TInt noteId = |
|
2304 AddNoteToQueueL( rid, |
|
2305 buf, |
|
2306 KAlarmNotePriority, |
|
2307 CAknNoteDialog::ENoTimeout, |
|
2308 CAknNoteDialog::ENoTone, |
|
2309 -1, |
|
2310 imageId, |
|
2311 maskId, |
|
2312 animation, |
|
2313 softkeys ); |
|
2314 |
|
2315 CGlobalNoteInfo* alarmNoteInfo = (*iGlobalNoteList)[iGlobalNoteList->Count()-1]; |
|
2316 if ( alarmNoteInfo ) |
|
2317 { |
|
2318 alarmNoteInfo->iGlobalPopupPriority = KGlobalWindowPriority_Alarm; |
|
2319 alarmNoteInfo->iAlmFlag = aType; |
|
2320 } |
|
2321 |
|
2322 // We will not specify alarm otherwise here. Alarm implementation provides more precise |
|
2323 // information using AddAlarmAdditionalData. |
|
2324 CAknSDData* data = CAknSDData::NewL( |
|
2325 KAknSecondaryDisplayCategory, |
|
2326 aType == EAskWakeUp ? EAknSwitchOnAfterAlarmNote : EAknAlarmNote, |
|
2327 KNullDesC8 ); |
|
2328 |
|
2329 TBool sdDataSet = SetSDData( noteId, data ); |
|
2330 |
|
2331 if ( !sdDataSet ) // data ownership not transferred |
|
2332 { |
|
2333 delete data; |
|
2334 } |
|
2335 |
|
2336 TryDisplayNextNoteL(); |
|
2337 |
|
2338 #ifdef _DEBUG |
|
2339 RDebug::Print(_L("DisplayAlarmL noteId [%d], Display [%d], Prio [%d], AutoLock [%d], Limit [%d], Disabled [%d]"), |
|
2340 noteId, iDisplayingNoteId, iCurrentPriority, iAutoLock, iMaxDisplayPriorityLimit, iNotesDisabled); |
|
2341 #endif |
|
2342 |
|
2343 return noteId; |
|
2344 } |
|
2345 |
|
2346 |
|
2347 void CAknGlobalNoteSubject::AddAlarmAdditionalInfo( |
|
2348 TInt aType, |
|
2349 const TDesC& aTime, |
|
2350 const TDesC& aDate, |
|
2351 const TDesC& aSubject, |
|
2352 const TDesC& aLocation ) |
|
2353 { |
|
2354 if ( iAlarmData ) |
|
2355 { |
|
2356 iAlarmData->iType = aType > 0 ? |
|
2357 (SAknAlarmPSInfo::TAlarmType)aType : SAknAlarmPSInfo::EAknClock; |
|
2358 |
|
2359 iAlarmData->iTime.Zero(); |
|
2360 iAlarmData->iTime.Append( |
|
2361 aTime.Ptr(), |
|
2362 Min(iAlarmData->iTime.MaxLength(), |
|
2363 aTime.Length())); |
|
2364 |
|
2365 iAlarmData->iDate.Zero(); |
|
2366 iAlarmData->iDate.Append( |
|
2367 aDate.Ptr(), |
|
2368 Min(iAlarmData->iDate.MaxLength(), |
|
2369 aDate.Length())); |
|
2370 |
|
2371 iAlarmData->iSubject.Zero(); |
|
2372 iAlarmData->iSubject.Append( |
|
2373 aSubject.Ptr(), |
|
2374 Min(iAlarmData->iSubject.MaxLength(), |
|
2375 aSubject.Length())); |
|
2376 |
|
2377 iAlarmData->iLocation.Zero(); |
|
2378 iAlarmData->iLocation.Append( |
|
2379 aLocation.Ptr(), |
|
2380 Min(iAlarmData->iLocation.MaxLength(), |
|
2381 aLocation.Length())); |
|
2382 } |
|
2383 } |
|
2384 |
|
2385 TBool CAknGlobalNoteSubject::SetSDData( TInt aNoteId, CAknSDData* aData ) |
|
2386 { |
|
2387 TInt index = NoteIndex( aNoteId ); |
|
2388 |
|
2389 if ( index != KErrNotFound ) |
|
2390 { |
|
2391 delete (*iGlobalNoteList)[index]->iSDData; |
|
2392 (*iGlobalNoteList)[index]->iSDData = aData; |
|
2393 return ETrue; |
|
2394 } |
|
2395 |
|
2396 return EFalse; |
|
2397 } |
|
2398 |
|
2399 TBool CAknGlobalNoteSubject::IsPreallocatedNoteIdValid(const TInt aPreAllocatedNoteId) |
|
2400 { |
|
2401 if (aPreAllocatedNoteId) |
|
2402 { |
|
2403 // Pre-allocated note id is given. Check that it is from valid range and that there is no |
|
2404 // note with that id already existing. |
|
2405 if (aPreAllocatedNoteId >= iNoteId || NoteIndex(aPreAllocatedNoteId) != KErrNotFound) |
|
2406 { |
|
2407 return EFalse; |
|
2408 } |
|
2409 } |
|
2410 |
|
2411 return ETrue; |
|
2412 } |
|
2413 |
|
2414 // ----------------------------------------------------------------------------- |
|
2415 // CAknGlobalNoteSubject::AutolockStatusNotificationL |
|
2416 // ----------------------------------------------------------------------------- |
|
2417 // |
|
2418 TInt CAknGlobalNoteSubject::AutolockStatusNotificationL(TAny* aObj) |
|
2419 { |
|
2420 if (aObj != NULL) |
|
2421 { |
|
2422 static_cast<CAknGlobalNoteSubject*>(aObj)->HandleAutolockStatusNotificationL(); |
|
2423 return KErrNone; |
|
2424 } |
|
2425 else |
|
2426 { |
|
2427 return KErrArgument; |
|
2428 } |
|
2429 } |
|
2430 |
|
2431 // ----------------------------------------------------------------------------- |
|
2432 // CAknGlobalNoteSubject::HandleAutolockStatusNotificationL |
|
2433 // ----------------------------------------------------------------------------- |
|
2434 // |
|
2435 void CAknGlobalNoteSubject::HandleAutolockStatusNotificationL() |
|
2436 { |
|
2437 iAutolockStatusProperty.Get(iAutoLock); |
|
2438 |
|
2439 iGlobalNote->SetAutoLock(iAutoLock > EAutolockOff); |
|
2440 if (iAutoLock > EAutolockOff) |
|
2441 { |
|
2442 if (iIdle) |
|
2443 { |
|
2444 return; // Notify already activated. |
|
2445 } |
|
2446 else |
|
2447 { |
|
2448 iIdle = CIdle::NewL(CActive::EPriorityIdle); |
|
2449 iIdle->Start(TCallBack(EnableAutolockEmulation, this)); |
|
2450 } |
|
2451 } |
|
2452 else |
|
2453 { |
|
2454 if (iIdle) // Cancel enabling autolock. |
|
2455 { |
|
2456 delete iIdle; |
|
2457 iIdle = 0; |
|
2458 } |
|
2459 } |
|
2460 |
|
2461 #ifdef _DEBUG |
|
2462 _LIT(KDmsg,"AknGlobalNote (HandleAutolockStatusNotificationL), AutolockStatus: %d"); |
|
2463 RDebug::Print(KDmsg, iAutoLock); |
|
2464 #endif |
|
2465 } |
|
2466 |
|
2467 // ----------------------------------------------------------------------------- |
|
2468 // CAknGlobalNoteSubject::CSubscriber::CSubscriber |
|
2469 // ----------------------------------------------------------------------------- |
|
2470 // |
|
2471 CAknGlobalNoteSubject::CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty) |
|
2472 : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) |
|
2473 { |
|
2474 CActiveScheduler::Add(this); |
|
2475 } |
|
2476 |
|
2477 // ----------------------------------------------------------------------------- |
|
2478 // CAknGlobalNoteSubject::CSubscriber::~CSubscriber |
|
2479 // ----------------------------------------------------------------------------- |
|
2480 // |
|
2481 CAknGlobalNoteSubject::CSubscriber::~CSubscriber() |
|
2482 { |
|
2483 Cancel(); |
|
2484 } |
|
2485 |
|
2486 // ----------------------------------------------------------------------------- |
|
2487 // CAknGlobalNoteSubject::CSubscriber::Subscribe |
|
2488 // ----------------------------------------------------------------------------- |
|
2489 // |
|
2490 void CAknGlobalNoteSubject::CSubscriber::Subscribe() |
|
2491 { |
|
2492 if (!IsActive()) |
|
2493 { |
|
2494 iProperty.Subscribe(iStatus); |
|
2495 SetActive(); |
|
2496 } |
|
2497 } |
|
2498 |
|
2499 // ----------------------------------------------------------------------------- |
|
2500 // CAknGlobalNoteSubject::CSubscriber::StopSubscribe |
|
2501 // ----------------------------------------------------------------------------- |
|
2502 // |
|
2503 void CAknGlobalNoteSubject::CSubscriber::StopSubscribe() |
|
2504 { |
|
2505 Cancel(); |
|
2506 } |
|
2507 |
|
2508 // ----------------------------------------------------------------------------- |
|
2509 // CAknGlobalNoteSubject::CSubscriber::RunL |
|
2510 // ----------------------------------------------------------------------------- |
|
2511 // |
|
2512 void CAknGlobalNoteSubject::CSubscriber::RunL() |
|
2513 { |
|
2514 if (iStatus.Int() == KErrNone) |
|
2515 { |
|
2516 iCallBack.CallBack(); |
|
2517 Subscribe(); |
|
2518 } |
|
2519 } |
|
2520 |
|
2521 // ----------------------------------------------------------------------------- |
|
2522 // CAknGlobalNoteSubject::CSubscriber::DoCancel |
|
2523 // ----------------------------------------------------------------------------- |
|
2524 // |
|
2525 void CAknGlobalNoteSubject::CSubscriber::DoCancel() |
|
2526 { |
|
2527 iProperty.Cancel(); |
|
2528 } |
|
2529 |
|
2530 // End of File |