1 /* |
|
2 * Copyright (c) 2007 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: Sleeping note with timeout |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappsleepingnote.h" |
|
20 #include <avkon.rsg> // avkon animation resources |
|
21 #include <aknnotpi.rsg> // keyguard note resources |
|
22 #include <aknnotecontrol.h> // access to note control |
|
23 #include "lockapputils.h" |
|
24 #include <GlobalWindowPriorities.h> |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Pointer to parent (implements MEikCommandObserver) is given in construction. |
|
28 // --------------------------------------------------------------------------- |
|
29 CLockAppSleepingNote::CLockAppSleepingNote( MEikCommandObserver* aCommandObserver ) : |
|
30 iCommandObserver(aCommandObserver) |
|
31 { |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Note construction on startup. |
|
36 // Sleeping note owns a timer that controls the note timeout. |
|
37 // --------------------------------------------------------------------------- |
|
38 void CLockAppSleepingNote::ConstructSleepingNoteL( TInt aResourceId ) |
|
39 { |
|
40 iResourceId = aResourceId; |
|
41 CAknNoteDialog::ConstructSleepingDialogL( aResourceId ); |
|
42 // Construct now rather than in PreLayoutDynInit |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // In destruction set reference value (is note shown) to not true. |
|
47 // --------------------------------------------------------------------------- |
|
48 CLockAppSleepingNote::~CLockAppSleepingNote( ) |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Show note with timeout. |
|
54 // --------------------------------------------------------------------------- |
|
55 TInt CLockAppSleepingNote::ShowNote( const TInt aTimeout, const TTone aTone ) |
|
56 { |
|
57 ReportUserActivity( ); |
|
58 iTimeoutInMicroseconds = aTimeout; |
|
59 iTone = aTone; |
|
60 return RouseSleepingDialog( ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Key events are handled here. |
|
65 // --------------------------------------------------------------------------- |
|
66 TKeyResponse CLockAppSleepingNote::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
67 { |
|
68 //return CAknNoteDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
69 return EKeyWasConsumed; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Always called when note exists, the reason (command) for exit |
|
74 // is delivered to parent. |
|
75 // --------------------------------------------------------------------------- |
|
76 TBool CLockAppSleepingNote::OkToExitL( TInt aCommand ) |
|
77 { |
|
78 if ( iCommandObserver ) |
|
79 { |
|
80 iCommandObserver->ProcessCommandL( aCommand ); |
|
81 } |
|
82 return ETrue; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // Always called when note exists, the reason (command) for exit |
|
87 // is delivered to parent. |
|
88 // --------------------------------------------------------------------------- |
|
89 void CLockAppSleepingNote::HandleResourceChange( TInt aType ) |
|
90 { |
|
91 if ( aType == KAknsMessageSkinChange ) |
|
92 { |
|
93 TInt animationRes(0); |
|
94 switch ( iResourceId ) |
|
95 { |
|
96 case R_KEYLOCK_NOTE_KEYLOCKED: |
|
97 animationRes = R_QGN_NOTE_INFO_ANIM; |
|
98 break; |
|
99 case R_KEYLOCK_NOTE_UNLOCK_CONFIRM: |
|
100 animationRes = R_QGN_NOTE_QUERY_ANIM; |
|
101 break; |
|
102 case R_KEYLOCK_NOTE_UNLOCK_ASTERISK: |
|
103 animationRes = R_QGN_NOTE_INFO_ANIM; |
|
104 break; |
|
105 case R_KEYLOCK_NOTE_LOCK_ON: |
|
106 animationRes = R_QGN_NOTE_KEYGUARD_LOCKED_ANIM; |
|
107 break; |
|
108 case R_KEYLOCK_NOTE_LOCK_OFF: |
|
109 animationRes = R_QGN_NOTE_KEYGUARD_OPEN_ANIM; |
|
110 break; |
|
111 case R_KEYLOCK_OFFER_LOCK_NOTE: |
|
112 animationRes = R_QGN_NOTE_QUERY_ANIM; |
|
113 break; |
|
114 default: |
|
115 break; |
|
116 } // end of switch |
|
117 |
|
118 if ( animationRes ) |
|
119 { |
|
120 CAknNoteControl* ctrl = NoteControl( ); |
|
121 if ( ctrl ) |
|
122 { |
|
123 TRAP_IGNORE(ctrl->SetAnimationL( animationRes )); |
|
124 } |
|
125 } |
|
126 } |
|
127 CAknNoteDialog::HandleResourceChange( aType ); |
|
128 } |
|