|
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: LockApp Application UI class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappappui.h" |
|
20 #include "lockappstatecontrol.h" |
|
21 #include "lockappserver.h" |
|
22 #include "lockapptrace.h" |
|
23 #include <lockappclientserver.h> |
|
24 #include <aknglobalpopupprioritycontroller.h> |
|
25 #include <apgcli.h> |
|
26 |
|
27 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
28 #include <SCPClient.h> |
|
29 #endif // __SAP_TERMINAL_CONTROL_FW |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // Second phase constructor |
|
33 // --------------------------------------------------------------------------- |
|
34 void CLockAppAppUi::ConstructL( ) |
|
35 { |
|
36 #if defined(_DEBUG) |
|
37 INFO_4( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x8 ); |
|
38 #endif |
|
39 |
|
40 // default appui constructor has to be called |
|
41 BaseConstructL( ); |
|
42 |
|
43 TInt use_old_autolock=1; |
|
44 if(use_old_autolock) |
|
45 { |
|
46 // start autolock instead of lockapp . This is a backup solution to use in case that not all SysAp and Avkon changes are implemented |
|
47 #if defined(_DEBUG) |
|
48 INFO_4( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 ); |
|
49 #endif |
|
50 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
51 TApaTask task( taskList.FindApp( _L("autolock.exe" )) ); |
|
52 if ( !task.Exists() ) |
|
53 { |
|
54 RApaLsSession ls; |
|
55 User::LeaveIfError(ls.Connect()); |
|
56 CleanupClosePushL(ls); |
|
57 |
|
58 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
59 commandLine->SetExecutableNameL( _L("autolock.exe" ) ); |
|
60 commandLine->SetCommandL( EApaCommandRun ); |
|
61 |
|
62 // Try to launch the application. |
|
63 User::LeaveIfError(ls.StartApp(*commandLine)); |
|
64 #if defined(_DEBUG) |
|
65 INFO_4( "%s %s (%u) autolock.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x7 ); |
|
66 #endif |
|
67 |
|
68 CleanupStack::PopAndDestroy(2); // commandLine, ls |
|
69 } |
|
70 Exit(); |
|
71 } |
|
72 |
|
73 #if defined(_DEBUG) |
|
74 INFO( "CLockAppAppUi::ConstructL started" ); |
|
75 #endif |
|
76 |
|
77 // start the server with the specified name |
|
78 iLockServer = CLockAppServer::NewL( KLockAppServerName ); |
|
79 |
|
80 // status pane is should not be visible |
|
81 StatusPane()->MakeVisible( EFalse ); |
|
82 |
|
83 // we need high priority even if lockapp is not in the foreground |
|
84 iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); |
|
85 RThread().SetProcessPriority( EPriorityHigh ); |
|
86 |
|
87 /* |
|
88 * LockApp is set as system application (Symbian terminology). |
|
89 * This means it does not get closed when system is asked to close applications. |
|
90 */ |
|
91 iEikonEnv->SetSystem( ETrue ); |
|
92 |
|
93 #ifdef _GLOBAL_PRIORITY_SUPPORTED |
|
94 // Enable global popup notes |
|
95 AknGlobalPopupPriorityController::EnablePriorityControlL(); |
|
96 AknGlobalPopupPriorityController::AllowGlobalPopups( ETrue ); |
|
97 #endif |
|
98 |
|
99 // main control storing and controling phone keylock/devicelock status |
|
100 iStateControl = CLockAppStateControl::NewL( ); |
|
101 |
|
102 // the main control is given high stack priority |
|
103 // ECoeStackPriorityEnvironmentFilter-1 used to allow hw keys for keyfiler even if keypad is locked. |
|
104 AddToStackL( iStateControl, ECoeStackPriorityEnvironmentFilter-1, ECoeStackFlagStandard ); |
|
105 #if defined(_DEBUG) |
|
106 INFO( "CLockAppAppUi::ConstructL finished" ); |
|
107 #endif |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Default Constructor |
|
112 // --------------------------------------------------------------------------- |
|
113 CLockAppAppUi::CLockAppAppUi( ) |
|
114 { |
|
115 // no implementation required |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Destructor |
|
120 // --------------------------------------------------------------------------- |
|
121 CLockAppAppUi::~CLockAppAppUi( ) |
|
122 { |
|
123 if ( iLockServer ) |
|
124 { |
|
125 delete iLockServer; |
|
126 iLockServer = NULL; |
|
127 } |
|
128 if ( iStateControl ) |
|
129 { |
|
130 // remove main control from stack |
|
131 RemoveFromStack( iStateControl ); |
|
132 delete iStateControl; |
|
133 iStateControl = NULL; |
|
134 } |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // Returns interface to LockAppServer sessions for changing lock states |
|
139 // --------------------------------------------------------------------------- |
|
140 MLockAppStateControl* CLockAppAppUi::StateControl( ) |
|
141 { |
|
142 return iStateControl; |
|
143 } |
|
144 |
|
145 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
146 // --------------------------------------------------------------- |
|
147 // Handles the TARM command to unlock the phone from WindowServer. |
|
148 // --------------------------------------------------------------- |
|
149 MCoeMessageObserver::TMessageResponse CLockAppAppUi::HandleMessageL( |
|
150 TUint32 aClientHandleOfTargetWindowGroup, |
|
151 TUid aMessageUid, |
|
152 const TDesC8& aMessageParameters ) |
|
153 { |
|
154 MCoeMessageObserver::TMessageResponse messageResponse( EMessageHandled); |
|
155 if ( aMessageUid.iUid == SCP_CMDUID_UNLOCK) |
|
156 { |
|
157 // For security reasons we must check from the SCP server |
|
158 // did this command originate from it. |
|
159 RSCPClient scpClient; |
|
160 if ( scpClient.Connect() == KErrNone ) |
|
161 { |
|
162 CleanupClosePushL( scpClient ); |
|
163 if ( scpClient.QueryAdminCmd( ESCPCommandUnlockPhone ) ) |
|
164 { |
|
165 #if defined(_DEBUG) |
|
166 INFO( "CLockAppAppUi::HandleMessageL(): Admin command received, unlocking" ); |
|
167 #endif |
|
168 iStateControl->DisableDevicelockL(); |
|
169 } |
|
170 else |
|
171 { |
|
172 #if defined(_DEBUG) |
|
173 INFO( "CLockAppAppUi::HandleMessageL(): Unauthorized attempt to unlock" ); |
|
174 #endif |
|
175 } |
|
176 CleanupStack::PopAndDestroy(); // calls Close() on scpClient |
|
177 } |
|
178 else |
|
179 { |
|
180 #if defined(_DEBUG) |
|
181 INFO( "CLockAppAppUi::HandleMessageL(): Failed to connect to SCP, ignoring unlock-message." ); |
|
182 #endif |
|
183 } |
|
184 } |
|
185 else // aMessageUid.iUid != SCP_CMDUID_UNLOCK |
|
186 { |
|
187 messageResponse = CAknAppUi::HandleMessageL( |
|
188 aClientHandleOfTargetWindowGroup, |
|
189 aMessageUid, |
|
190 aMessageParameters); |
|
191 } |
|
192 return messageResponse; |
|
193 } |
|
194 #endif // __SAP_TERMINAL_CONTROL_FW |
|
195 |
|
196 // ---------------------------------------------------------- |
|
197 // Handle window-server events |
|
198 // ---------------------------------------------------------- |
|
199 void CLockAppAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination ) |
|
200 { |
|
201 #if defined(_DEBUG) |
|
202 INFO_4( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
203 #endif |
|
204 if ( aEvent.Type() == TRawEvent::EKeyDown ) |
|
205 { |
|
206 #if defined(_DEBUG) |
|
207 INFO_1("CLockAppAppUi::HandleWsEventL() - aEvent.Key()->iCode: %d", aEvent.Key()->iCode ); |
|
208 #endif |
|
209 } |
|
210 |
|
211 // call super-class |
|
212 CAknAppUi::HandleWsEventL( aEvent, aDestination ); |
|
213 // propagate call |
|
214 iStateControl->HandleWsEventL( aEvent, aDestination); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // From @c CAknAppUiBase. Overriden the parent method, because otherwise |
|
219 // the main lock state control would not receive the call, because is is not |
|
220 // window-owning control (=without window->not visible). The call is needed |
|
221 // because the main state control owns window-owning child controls. |
|
222 // --------------------------------------------------------------------------- |
|
223 void CLockAppAppUi::HandleResourceChangeL( TInt aType ) |
|
224 { |
|
225 // call super-class |
|
226 CAknAppUi::HandleResourceChangeL( aType ); |
|
227 // propagate call - since does not own window |
|
228 iStateControl->HandleResourceChange( aType ); |
|
229 } |