|
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: Provides emergency call support for keyguard/devicelock |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappecsdetector.h" |
|
20 #include "lockappecsnote.h" |
|
21 #include "lockapputils.h" |
|
22 #include <aknappui.h> |
|
23 #include <avkon.rsg> |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Standard Symbian OS construction sequence |
|
27 // --------------------------------------------------------------------------- |
|
28 CLockAppEcsDetector* CLockAppEcsDetector::NewL( ) |
|
29 { |
|
30 CLockAppEcsDetector* self = new (ELeave) CLockAppEcsDetector(); |
|
31 CleanupStack::PushL( self ); |
|
32 self->ConstructL( ); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Standard C++ constructor |
|
39 // --------------------------------------------------------------------------- |
|
40 CLockAppEcsDetector::CLockAppEcsDetector( ) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Constructs the emergency detector and the note. |
|
46 // --------------------------------------------------------------------------- |
|
47 void CLockAppEcsDetector::ConstructL( ) |
|
48 { |
|
49 // emergency call support |
|
50 iEcsDetector = CAknEcsDetector::NewL( ); |
|
51 iEcsDetector->SetObserver( this ); |
|
52 |
|
53 // emergency call note |
|
54 iEcsNote = new (ELeave) CLockAppEcsNote(); |
|
55 iEcsNote->ConstructSleepingNoteL( R_AVKON_EMERGENCY_CALL_NOTE ); |
|
56 iEcsNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 ); |
|
57 |
|
58 // needs to be called for ecs detector to work/receive events. |
|
59 iAvkonAppUi->EventMonitor()->Enable( ETrue ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Destructor. |
|
64 // --------------------------------------------------------------------------- |
|
65 CLockAppEcsDetector::~CLockAppEcsDetector( ) |
|
66 { |
|
67 delete iEcsDetector; |
|
68 delete iEcsNote; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Detector starts/stops listening to key events if keys are locked/unlocked. |
|
73 // The detector key event queue is always reseted when lock status is changed. |
|
74 // --------------------------------------------------------------------------- |
|
75 void CLockAppEcsDetector::HandleLockStatusChangedL( TLockStatus aLockStatus ) |
|
76 { |
|
77 iEcsDetector->Reset( ); |
|
78 switch ( aLockStatus ) |
|
79 { |
|
80 case ELockNotActive: |
|
81 { |
|
82 iEcsDetector->CloseEventSource( ); |
|
83 } |
|
84 break; |
|
85 case EKeyguardActive: |
|
86 case EDevicelockActive: |
|
87 { |
|
88 iEcsDetector->ConnectToEventSource( ); |
|
89 } |
|
90 break; |
|
91 default: |
|
92 DoPanic( ELockUnknownValue ); |
|
93 break; |
|
94 } |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // The main state controller needs to know if emergency call note is |
|
99 // on the screen. |
|
100 // --------------------------------------------------------------------------- |
|
101 TBool CLockAppEcsDetector::EcsNoteOnScreen( ) const |
|
102 { |
|
103 return iEcsNote->iNoteOnScreen; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // From @c MAknEcsObserver.. Handles changes in emergency the emergency number |
|
108 // queue (i.e. if the user has dialed emergency numbers or not). |
|
109 // --------------------------------------------------------------------------- |
|
110 void CLockAppEcsDetector::HandleEcsEvent( CAknEcsDetector* aEcsDetector, |
|
111 CAknEcsDetector::TState aState ) |
|
112 { |
|
113 switch ( aState ) |
|
114 { |
|
115 case CAknEcsDetector::ECompleteMatchThenSendKey: |
|
116 // Do nothing since note will be removed on ECallAttempted event |
|
117 break; |
|
118 // user has successfully dialed emergency numbers |
|
119 case CAknEcsDetector::ECompleteMatch: |
|
120 iEcsNote->SetEmergencyNumber( aEcsDetector->CurrentMatch( ) ); |
|
121 // Tell sysAp to switch lights on |
|
122 SendMessageToSysAp( EEikEcsQueryLights ); |
|
123 iEcsNote->ShowNote( ); |
|
124 break; |
|
125 case CAknEcsDetector::EPartialMatch: |
|
126 iEcsNote->SleepNote( ); |
|
127 break; |
|
128 case CAknEcsDetector::ECallAttempted: |
|
129 iEcsNote->SleepNote( ); |
|
130 break; |
|
131 case CAknEcsDetector::EEmpty: |
|
132 iEcsNote->SleepNote( ); |
|
133 break; |
|
134 case CAknEcsDetector::ENoMatch: |
|
135 iEcsNote->SleepNote( ); |
|
136 break; |
|
137 default: |
|
138 break; |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // Tests the emergency note ui. Only used for testing purposes, |
|
144 // Created, because emergency detector does not work in emulator. |
|
145 // --------------------------------------------------------------------------- |
|
146 TInt CLockAppEcsDetector::TestEcsNote( ) |
|
147 { |
|
148 #ifdef _DEBUG |
|
149 HandleEcsEvent( iEcsDetector, CAknEcsDetector::EEmpty ); |
|
150 HandleEcsEvent( iEcsDetector, CAknEcsDetector::ENoMatch ); |
|
151 HandleEcsEvent( iEcsDetector, CAknEcsDetector::EPartialMatch ); |
|
152 HandleEcsEvent( iEcsDetector, CAknEcsDetector::ECompleteMatch ); |
|
153 _LIT( NText, "112Test"); |
|
154 iEcsNote->SetEmergencyNumber( NText ); |
|
155 SendMessageToSysAp( EEikEcsQueryLights ); |
|
156 iEcsNote->ShowNote( ); |
|
157 #endif |
|
158 return KErrNone; |
|
159 } |