|
1 /* |
|
2 * Copyright (c) 2002 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 Lock interface |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32property.h> |
|
21 #include <PSVariables.h> // Property values |
|
22 #include <coreapplicationuisdomainpskeys.h> |
|
23 #include "SecUiSystemLock.h" |
|
24 #include <eikenv.h> |
|
25 #include <AknNotifierController.h> |
|
26 #include <rmmcustomapi.h> |
|
27 #include "secuisecuritysettings.h" |
|
28 #include "SecUiWait.h" |
|
29 #include <mmtsy_names.h> |
|
30 #include <e32property.h> |
|
31 #include <ctsydomainpskeys.h> |
|
32 #include <securityuisprivatepskeys.h> |
|
33 /***************************************************** |
|
34 * Series 60 Customer / TSY |
|
35 * Needs customer TSY implementation |
|
36 *****************************************************/ |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 const TInt KTriesToConnectServer( 2 ); |
|
40 const TInt KTimeBeforeRetryingServerConnection( 50000 ); |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 // |
|
44 // ---------------------------------------------------------- |
|
45 // CSystemLock::NewL() |
|
46 // |
|
47 // ---------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CSystemLock* CSystemLock::NewL() |
|
50 { |
|
51 CSystemLock* self = new(ELeave) CSystemLock(); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 } |
|
57 // |
|
58 // ---------------------------------------------------------- |
|
59 // CSystemLock::ConstructL() |
|
60 // |
|
61 // ---------------------------------------------------------- |
|
62 // |
|
63 void CSystemLock::ConstructL() |
|
64 { |
|
65 /***************************************************** |
|
66 * Series 60 Customer / ETel |
|
67 * Series 60 ETel API |
|
68 *****************************************************/ |
|
69 /***************************************************** |
|
70 * Series 60 Customer / TSY |
|
71 * Needs customer TSY implementation |
|
72 *****************************************************/ |
|
73 #if defined(_DEBUG) |
|
74 RDebug::Print(_L("(SECUI)CSystemLock::ConstructL()")); |
|
75 #endif |
|
76 TInt err( KErrGeneral ); |
|
77 TInt thisTry( 0 ); |
|
78 |
|
79 /* All server connections are tried to be made KTiesToConnectServer times because occasional |
|
80 fails on connections are possible, at least on some servers */ |
|
81 thisTry = 0; |
|
82 |
|
83 // connect to ETel server |
|
84 while ( ( err = iServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
85 { |
|
86 User::After( KTimeBeforeRetryingServerConnection ); |
|
87 } |
|
88 User::LeaveIfError( err ); |
|
89 |
|
90 // load TSY |
|
91 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
|
92 if ( err != KErrAlreadyExists ) |
|
93 { |
|
94 // May also return KErrAlreadyExists if something else |
|
95 // has already loaded the TSY module. And that is |
|
96 // not an error. |
|
97 User::LeaveIfError( err ); |
|
98 } |
|
99 |
|
100 // open phones |
|
101 User::LeaveIfError(iPhone.Open(iServer, KMmTsyPhoneName)); |
|
102 CActiveScheduler::Add(this); |
|
103 } |
|
104 // ---------------------------------------------------------- |
|
105 // CSystemLock::CSystemLock() |
|
106 // C++ constructor |
|
107 // ---------------------------------------------------------- |
|
108 // |
|
109 CSystemLock::CSystemLock() : CActive(0) |
|
110 { |
|
111 } |
|
112 // |
|
113 // ---------------------------------------------------------- |
|
114 // CSystemLock::CSystemLock() |
|
115 // Destructor |
|
116 // ---------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C CSystemLock::~CSystemLock() |
|
119 { |
|
120 /***************************************************** |
|
121 * Series 60 Customer / ETel |
|
122 * Series 60 ETel API |
|
123 *****************************************************/ |
|
124 /***************************************************** |
|
125 * Series 60 Customer / TSY |
|
126 * Needs customer TSY implementation |
|
127 *****************************************************/ |
|
128 |
|
129 Cancel(); |
|
130 |
|
131 // close phone |
|
132 if (iPhone.SubSessionHandle()) |
|
133 iPhone.Close(); |
|
134 //close ETel connection |
|
135 if (iServer.Handle()) |
|
136 { |
|
137 iServer.UnloadPhoneModule(KMmTsyModuleName); |
|
138 iServer.Close(); |
|
139 } |
|
140 } |
|
141 // |
|
142 // ---------------------------------------------------------- |
|
143 // CSystemLock::SetLockedL() |
|
144 // Activates system lock |
|
145 // ---------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C void CSystemLock::SetLockedL() |
|
148 { |
|
149 /***************************************************** |
|
150 * Series 60 Customer / ETel |
|
151 * Series 60 ETel API |
|
152 *****************************************************/ |
|
153 #if defined(_DEBUG) |
|
154 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL()")); |
|
155 #endif |
|
156 // close fast-swap window |
|
157 CEikonEnv::Static()->DismissTaskList(); |
|
158 |
|
159 #ifdef __WINS__ |
|
160 // can not verify security code in emulator ---> lock system |
|
161 #ifdef RD_REMOTELOCK |
|
162 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked); |
|
163 #else// !RD_REMOTELOCK |
|
164 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn); |
|
165 #endif//RD_REMOTELOCK |
|
166 #else //__WINS__ |
|
167 |
|
168 if(IsActive()) |
|
169 return; |
|
170 |
|
171 |
|
172 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
173 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
174 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
175 RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); |
|
176 CWait* wait = CWait::NewL(); |
|
177 CleanupStack::PushL( wait ); |
|
178 #if defined(_DEBUG) |
|
179 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() GetLockInfo")); |
|
180 #endif |
|
181 iPhone.GetLockInfo(wait->iStatus, lockType, lockInfoPkg); |
|
182 if (wait->WaitForRequestL() == KErrNone) |
|
183 { |
|
184 #if defined(_DEBUG) |
|
185 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() KErrNone")); |
|
186 #endif |
|
187 if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled) |
|
188 { |
|
189 #if defined(_DEBUG) |
|
190 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() ELockSetDisabled")); |
|
191 #endif |
|
192 // ask code |
|
193 #if defined(_DEBUG) |
|
194 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() SetLockSetting")); |
|
195 #endif |
|
196 //iCustomPhone.CheckSecurityCode(iStatus, RMmCustomAPI::ESecurityCodePassPhrase); |
|
197 lockChange = RMobilePhone::ELockSetEnabled; |
|
198 RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated); |
|
199 iPhone.SetLockSetting(iStatus, lockType, lockChange); |
|
200 SetActive(); |
|
201 } |
|
202 else |
|
203 { |
|
204 #if defined(_DEBUG) |
|
205 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() Lock System")); |
|
206 #endif |
|
207 // lock system |
|
208 #ifdef RD_REMOTELOCK |
|
209 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked); |
|
210 #else// !RD_REMOTELOCK |
|
211 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn); |
|
212 #endif //RD_REMOTELOCK |
|
213 |
|
214 #if defined(_DEBUG) |
|
215 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() Lock System OK")); |
|
216 #endif |
|
217 } |
|
218 } |
|
219 else |
|
220 { |
|
221 // ask code |
|
222 #if defined(_DEBUG) |
|
223 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() ask code (SLS) ")); |
|
224 #endif |
|
225 lockChange = RMobilePhone::ELockSetEnabled; |
|
226 RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated); |
|
227 iPhone.SetLockSetting(iStatus, lockType, lockChange); |
|
228 SetActive(); |
|
229 } |
|
230 CleanupStack::PopAndDestroy(); |
|
231 #if defined(_DEBUG) |
|
232 RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() END")); |
|
233 #endif // DEBUG |
|
234 #endif // WINS |
|
235 } |
|
236 // |
|
237 // ---------------------------------------------------------- |
|
238 // CSystemLock::RunL() |
|
239 // Handles query result |
|
240 // ---------------------------------------------------------- |
|
241 // |
|
242 void CSystemLock::RunL() |
|
243 { |
|
244 #if defined(_DEBUG) |
|
245 TInt status(iStatus.Int()); |
|
246 RDebug::Print(_L("(SECUI)CSystemLock::RunL(): %d"), status); |
|
247 #endif |
|
248 //lower the flag |
|
249 RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated); |
|
250 if (iStatus == KErrNone) |
|
251 { |
|
252 TInt callState; |
|
253 RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); |
|
254 //If there is ann ongoing call, phone is not locked. |
|
255 if (callState == EPSCTsyCallStateNone) |
|
256 { |
|
257 #if defined(_DEBUG) |
|
258 RDebug::Print(_L("(SECUI)CSystemLock::RunL() KErrNone")); |
|
259 #endif |
|
260 // clear notifiers |
|
261 AknNotifierController::HideAllNotifications(ETrue); |
|
262 // query approved -> lock system |
|
263 #ifdef RD_REMOTELOCK |
|
264 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked); |
|
265 #else// !RD_REMOTELOCK |
|
266 iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn); |
|
267 #endif//RD_REMOTELOCK |
|
268 AknNotifierController::HideAllNotifications(EFalse); |
|
269 } |
|
270 } |
|
271 else if((iStatus != KErrCancel) && (iStatus != KErrAbort)) |
|
272 { //Code error or something like that. Show the dialog again. |
|
273 #if defined(_DEBUG) |
|
274 RDebug::Print(_L("(SECUI)CSystemLock::RunL() Code Error")); |
|
275 #endif |
|
276 SetLockedL(); |
|
277 } |
|
278 else |
|
279 { |
|
280 //User canceled the dialog; do nothing... |
|
281 } |
|
282 |
|
283 |
|
284 #if defined(_DEBUG) |
|
285 RDebug::Print(_L("(SECUI)CSystemLock::RunL() END")); |
|
286 #endif |
|
287 } |
|
288 // |
|
289 // ---------------------------------------------------------- |
|
290 // CSecObsNotify::StartNotifier |
|
291 // Cancels code request |
|
292 // ---------------------------------------------------------- |
|
293 // |
|
294 void CSystemLock::DoCancel() |
|
295 { |
|
296 /***************************************************** |
|
297 * Series 60 Customer / ETel |
|
298 * Series 60 ETel API |
|
299 *****************************************************/ |
|
300 #if defined(_DEBUG) |
|
301 RDebug::Print(_L("(SECUI)CSystemLock::DoCancel")); |
|
302 #endif |
|
303 iPhone.CancelAsyncRequest(EMobilePhoneSetLockSetting); |
|
304 } |
|
305 |
|
306 // End of file |