1 /* |
1 /* |
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Provides api for handling security events. |
14 * Description: Provides api for handling security events. |
15 * |
15 * |
16 * |
16 * |
17 */ |
17 */ |
18 #include <e32notif.h> |
18 |
|
19 |
19 #include <aknnotedialog.h> |
20 #include <aknnotedialog.h> |
20 #include <etelmm.h> |
21 #include <etelmm.h> |
21 // #include <SecUi.rsg> |
22 #include <SecUi.rsg> |
22 #include <exterror.h> |
23 #include <exterror.h> |
23 #include <textresolver.h> |
24 #include <textresolver.h> |
24 |
25 |
25 #ifdef __COVER_DISPLAY |
26 #ifdef __COVER_DISPLAY |
26 #include <aknmediatorfacade.h> |
27 #include <aknmediatorfacade.h> |
|
28 #include <secondarydisplay/SecondaryDisplayStartupAPI.h> |
27 #endif //__COVER_DISPLAY |
29 #endif //__COVER_DISPLAY |
|
30 |
28 #include <centralrepository.h> |
31 #include <centralrepository.h> |
|
32 #include <starterclient.h> //used for RemoveSplashScreen |
29 #include <e32property.h> |
33 #include <e32property.h> |
30 |
|
31 #include <PSVariables.h> // Property values |
34 #include <PSVariables.h> // Property values |
32 #include <coreapplicationuisdomainpskeys.h> |
35 #include <coreapplicationuisdomainpskeys.h> |
33 #include <startupdomainpskeys.h> |
36 #include <startupdomainpskeys.h> |
34 // #include <uikon/eiksrvui.h> |
37 #include <uikon/eiksrvui.h> |
35 #include <settingsinternalcrkeys.h> |
38 #include <settingsinternalcrkeys.h> |
36 #include <securityuisprivatepskeys.h> |
39 #include <securityuisprivatepskeys.h> |
37 // #include <AknNotiferAppServerApplication.h> |
40 #include <AknNotiferAppServerApplication.h> |
38 |
41 |
39 #include <SCPClient.h> |
42 #include <SCPClient.h> |
40 #include <securitynotification.h> |
43 #include <securitynotification.h> |
41 #include "secui.hrh" |
44 #include "secui.hrh" |
42 #include "SecUi.h" |
|
43 #include "secuisecurityhandler.h" |
45 #include "secuisecurityhandler.h" |
44 #include "secuicodequerydialog.h" |
46 #include "secuicodequerydialog.h" |
45 #include "secuisecuritysettings.h" |
47 #include "secuisecuritysettings.h" |
46 #include "SecUiWait.h" |
48 #include "SecUiWait.h" |
47 // #include "SecUiLockObserver.h" |
49 #include "SecUiLockObserver.h" |
|
50 #ifdef RD_REMOTELOCK |
48 #include <RemoteLockSettings.h> |
51 #include <RemoteLockSettings.h> |
|
52 #endif // RD_REMOTELOCK |
49 #include <StringLoader.h> |
53 #include <StringLoader.h> |
50 #include <featmgr.h> |
54 #include <featmgr.h> |
51 #include <hb/hbcore/hbtextresolversymbian.h> |
|
52 |
|
53 #include "SecQueryUi.h" |
|
54 |
|
55 // LOCAL CONSTANTS AND MACROS |
55 // LOCAL CONSTANTS AND MACROS |
56 const TInt KMaxNumberOfPUKAttempts(10); |
56 const TInt KMaxNumberOfPUKAttempts(10); |
57 const TInt KMaxNumberOfPINAttempts(3); |
57 const TInt KMaxNumberOfPINAttempts(3); |
58 // not used |
58 const TInt KLastRemainingInputAttempt(1); |
59 // const TInt KLastRemainingInputAttempt(1); |
59 |
60 |
60 const TInt KTriesToConnectServer( 2 ); |
61 const TInt KTriesToConnectServer(2); |
61 const TInt KTimeBeforeRetryingRequest( 50000 ); |
62 const TInt KTimeBeforeRetryingRequest(50000); |
|
63 |
62 |
64 // ================= MEMBER FUNCTIONS ======================= |
63 // ================= MEMBER FUNCTIONS ======================= |
65 // |
64 // |
66 // ---------------------------------------------------------- |
65 // ---------------------------------------------------------- |
67 // CSecurityHandler::CSecurityHandler() |
66 // CSecurityHandler::CSecurityHandler() |
68 // C++ constructor |
67 // C++ constructor |
69 // ---------------------------------------------------------- |
68 // ---------------------------------------------------------- |
70 // qtdone |
69 // |
71 EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone) : |
70 EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone): |
72 iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL) |
71 iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL) |
73 { |
72 { |
74 RDEBUG("0", 0); |
73 TInt result = iCustomPhone.Open(aPhone); |
75 |
74 TRAP_IGNORE( FeatureManager::InitializeLibL() ); //Shouldn't this panic if FM does not initialise?? |
76 TInt result = iCustomPhone.Open(aPhone); |
|
77 RDEBUG("result", result); |
|
78 TRAP_IGNORE(FeatureManager::InitializeLibL()); //Shouldn't this panic if FM does not initialise?? |
|
79 |
|
80 _LIT(KFileName, "secui_"); |
|
81 _LIT(KPath, "z:/resource/qt/translations/"); |
|
82 RDEBUG("HbTextResolverSymbian", 0); |
|
83 result = HbTextResolverSymbian::Init(KFileName, KPath); |
|
84 RDEBUG("result", result); |
|
85 } |
75 } |
86 |
76 |
87 // |
77 // |
88 // ---------------------------------------------------------- |
78 // ---------------------------------------------------------- |
89 // CSecurityHandler::~CSecurityHandler() |
79 // CSecurityHandler::~CSecurityHandler() |
90 // Destructor |
80 // Destructor |
91 // ---------------------------------------------------------- |
81 // ---------------------------------------------------------- |
92 // qtdone |
82 // |
93 EXPORT_C CSecurityHandler::~CSecurityHandler() |
83 EXPORT_C CSecurityHandler::~CSecurityHandler() |
94 { |
84 { |
95 RDEBUG("0", 0); |
85 #if defined(_DEBUG) |
96 |
86 RDebug::Print(_L("CSecurityHandler::~CSecurityHandler()")); |
97 if (iDestroyedPtr) |
87 #endif |
|
88 if ( iDestroyedPtr ) |
98 { |
89 { |
99 *iDestroyedPtr = ETrue; |
90 *iDestroyedPtr = ETrue; |
100 iDestroyedPtr = NULL; |
91 iDestroyedPtr = NULL; |
101 } |
92 } |
102 RDEBUG("calling CancelOpenQuery", 0); |
93 CancelSecCodeQuery(); |
103 TInt err = CancelOpenQuery(-1); |
|
104 RDEBUG("err", err); |
|
105 iCustomPhone.Close(); |
94 iCustomPhone.Close(); |
106 FeatureManager::UnInitializeLib(); |
95 FeatureManager::UnInitializeLib(); |
107 RDEBUG("1", 1); |
|
108 } |
96 } |
109 // |
97 // |
110 // ---------------------------------------------------------- |
98 // ---------------------------------------------------------- |
111 // CSecurityHandler::HandleEventL() |
99 // CSecurityHandler::HandleEventL() |
112 // Handles different security events |
100 // Handles different security events |
113 // ---------------------------------------------------------- |
101 // ---------------------------------------------------------- |
114 // qtdone |
102 // |
115 EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent) |
103 EXPORT_C void CSecurityHandler::HandleEventL( |
|
104 RMobilePhone::TMobilePhoneSecurityEvent aEvent ) |
116 { |
105 { |
117 RDEBUG("0", 0); |
|
118 |
|
119 TInt result = KErrNone; |
106 TInt result = KErrNone; |
120 HandleEventL(aEvent, result); |
107 HandleEventL( aEvent, result ); |
121 } |
108 } |
122 |
109 |
123 // |
110 // |
124 // ---------------------------------------------------------- |
111 // ---------------------------------------------------------- |
125 // CSecurityHandler::HandleEventL() |
112 // CSecurityHandler::HandleEventL() |
126 // Handles different security events |
113 // Handles different security events |
127 // ---------------------------------------------------------- |
114 // ---------------------------------------------------------- |
128 // qtdone |
115 // |
129 EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TBool aStartup, TInt& aResult) |
116 EXPORT_C void CSecurityHandler::HandleEventL( |
|
117 RMobilePhone::TMobilePhoneSecurityEvent aEvent, |
|
118 TBool aStartup, TInt& aResult ) |
130 { |
119 { |
131 RDEBUG("0", 0); |
|
132 |
|
133 iStartup = aStartup; |
120 iStartup = aStartup; |
134 HandleEventL(aEvent, aResult); |
121 HandleEventL( aEvent, aResult ); |
135 } |
122 } |
136 |
123 |
137 // |
124 // |
138 // ---------------------------------------------------------- |
125 // ---------------------------------------------------------- |
139 // CSecurityHandler::HandleEventL() |
126 // CSecurityHandler::HandleEventL() |
140 // Handles different security events |
127 // Handles different security events |
141 // ---------------------------------------------------------- |
128 // ---------------------------------------------------------- |
142 // qtdone |
129 // |
143 EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult) |
130 EXPORT_C void CSecurityHandler::HandleEventL( |
|
131 RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult ) |
144 { |
132 { |
145 RDEBUG("0", 0); |
|
146 |
|
147 /***************************************************** |
133 /***************************************************** |
148 * Series 60 Customer / ETel |
134 * Series 60 Customer / ETel |
149 * Series 60 ETel API |
135 * Series 60 ETel API |
150 *****************************************************/ |
136 *****************************************************/ |
151 TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)); |
137 #if defined(_DEBUG) |
152 TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin)); |
138 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL()")); |
153 RDEBUG("aEvent", aEvent); |
139 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() EVENT: %d"), aEvent); |
154 |
140 #endif |
155 switch (aEvent) |
141 TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma )); |
156 { |
142 TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin )); |
157 case RMobilePhone::EPin1Required: |
143 |
158 RDEBUG("RMobilePhone::EPin1Required", 0) |
144 switch(aEvent) |
159 ; |
145 { |
160 aResult = Pin1RequiredL(); |
146 case RMobilePhone::EPin1Required: |
161 break; |
147 #if defined(_DEBUG) |
162 case RMobilePhone::EPuk1Required: |
148 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() Pin1Required")); |
163 RDEBUG("RMobilePhone::EPuk1Required", 0) |
149 #endif |
164 ; |
150 aResult = Pin1RequiredL(); |
165 Puk1RequiredL(); |
151 break; |
166 break; |
152 case RMobilePhone::EPuk1Required: |
167 case RMobilePhone::EPin2Required: |
153 #if defined(_DEBUG) |
168 Pin2RequiredL(); |
154 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() PUK1Required")); |
169 break; |
155 #endif |
170 case RMobilePhone::EPuk2Required: |
156 ((CAknNotifierAppServerAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(ETrue); |
171 Puk2RequiredL(); |
157 TRAPD(err,aResult = Puk1RequiredL()); |
172 break; |
158 ((CAknNotifierAppServerAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(EFalse); |
173 case RMobilePhone::EUniversalPinRequired: |
159 User::LeaveIfError(err); |
174 if (wcdmaSupported || upinSupported) |
160 break; |
175 { |
161 case RMobilePhone::EPin2Required: |
176 aResult = UPinRequiredL(); |
162 Pin2RequiredL(); |
177 } |
163 break; |
178 else |
164 case RMobilePhone::EPuk2Required: |
179 aResult = KErrNotSupported; |
165 Puk2RequiredL(); |
180 break; |
166 break; |
181 case RMobilePhone::EUniversalPukRequired: |
167 case RMobilePhone::EUniversalPinRequired: |
182 if (wcdmaSupported || upinSupported) |
168 if(wcdmaSupported || upinSupported) |
183 { |
169 { |
184 aResult = UPukRequiredL(); |
170 aResult = UPinRequiredL(); |
185 } |
171 } |
186 else |
172 else |
187 aResult = KErrNotSupported; |
173 aResult = KErrNotSupported; |
188 break; |
174 break; |
189 case RMobilePhone::EPhonePasswordRequired: |
175 case RMobilePhone::EUniversalPukRequired: |
190 aResult = PassPhraseRequiredL(); |
176 if(wcdmaSupported || upinSupported) |
191 break; |
177 { |
192 case RMobilePhone::EICCTerminated: |
178 aResult = UPukRequiredL(); |
193 SimLockEventL(); |
179 } |
194 break; |
180 else |
195 default: |
181 aResult = KErrNotSupported; |
196 RDEBUG("default", aEvent) |
182 break; |
197 ; |
183 case RMobilePhone::EPhonePasswordRequired: |
198 break; |
184 aResult = PassPhraseRequiredL(); |
199 } |
185 break; |
200 RDEBUG("aResult", aResult); |
186 case RMobilePhone::EICCTerminated: |
|
187 SimLockEventL(); |
|
188 break; |
|
189 default: |
|
190 break; |
|
191 } |
|
192 #if defined(_DEBUG) |
|
193 RDebug::Print( _L( "CSecurityHandler::HandleEventL() returning %d." ), aResult ); |
|
194 #endif |
201 } |
195 } |
202 // |
196 // |
203 // ---------------------------------------------------------- |
197 // ---------------------------------------------------------- |
204 // CSecurityHandler::AskSecCodeL() |
198 // CSecurityHandler::AskSecCodeL() |
205 // For asking security code e.g in settings |
199 // For asking security code e.g in settings |
206 // ---------------------------------------------------------- |
200 // ---------------------------------------------------------- |
207 // qtdone |
201 // |
208 EXPORT_C TBool CSecurityHandler::AskSecCodeL() |
202 EXPORT_C TBool CSecurityHandler::AskSecCodeL() |
209 { |
203 { |
210 /***************************************************** |
204 /***************************************************** |
211 * Series 60 Customer / ETel |
205 * Series 60 Customer / ETel |
212 * Series 60 ETel API |
206 * Series 60 ETel API |
213 *****************************************************/ |
207 *****************************************************/ |
214 RDEBUG("0", 0); |
208 #if defined(_DEBUG) |
215 // if code is still not initialized, then there's no need to ask it. This fixes the error when the RFS requests the code. |
209 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeL()")); |
216 const TUid KCRUidSCPLockCode = |
210 #endif |
217 { |
211 |
218 0x2002677B |
212 /* if code is still not initialized, then there's no need to ask it. This fixes the error when the RFS requests the code */ |
219 }; |
213 const TUid KCRUidSCPLockCode = {0x2002677B}; |
220 const TUint32 KSCPLockCodeDefaultLockCode = 0x00000001; |
214 const TUint32 KSCPLockCodeDefaultLockCode = 0x00000001; |
221 |
215 |
222 CRepository* repository = CRepository::NewL(KCRUidSCPLockCode); |
216 CRepository* repository = CRepository::NewL(KCRUidSCPLockCode); |
223 TInt currentLockStatus = -1; |
217 TInt currentLockStatus = -1; |
224 TInt res = -1; |
218 TInt res=-1; |
225 TInt lAlphaSupported = 0; |
219 |
226 TInt lCancelSupported = 0; |
220 res = repository->Get(KSCPLockCodeDefaultLockCode , currentLockStatus); |
227 RMobilePhone::TMobilePassword iSecUi_password; |
221 #if defined(_DEBUG) |
228 |
222 RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res ); |
229 res = repository->Get(KSCPLockCodeDefaultLockCode, currentLockStatus); // 0x3039 = 12345 |
223 RDebug::Printf( "%s %s (%u) currentLockStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, currentLockStatus ); |
230 RDEBUG("res", res); |
224 #endif |
231 RDEBUG("currentLockStatus", currentLockStatus); |
|
232 delete repository; |
225 delete repository; |
233 if (res == 0 && (currentLockStatus == 1 || currentLockStatus == 12345) ) |
226 if(res==0 && currentLockStatus>=1 ) |
234 { |
227 { |
235 // code is the default one |
228 // code is the default one; no need to request it. |
236 RDEBUG("code is the default one; supply as default", 1); |
229 return ETrue; |
237 iSecUi_password.Copy(_L("12345")); |
230 } |
238 // RDEBUG("code is the default one; no need to request it", 1); |
231 /* end check for default code */ |
239 // return ETrue; |
232 |
240 } |
233 // Destructor sets thisDestroyed to ETrue |
241 // end check for default code |
234 TBool thisDestroyed( EFalse ); |
242 |
235 iDestroyedPtr = &thisDestroyed; |
|
236 |
|
237 iQueryCanceled = EFalse; |
|
238 RMobilePhone::TMobilePassword password; |
243 RMobilePhone::TMobilePassword required_fourth; |
239 RMobilePhone::TMobilePassword required_fourth; |
244 |
240 |
245 TInt ret = KErrNone; |
241 TInt ret = KErrNone; |
|
242 TInt err = KErrNone; |
246 TInt status = KErrNone; |
243 TInt status = KErrNone; |
247 |
244 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
248 TInt queryAccepted = KErrCancel; |
245 FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
249 |
246 { |
250 while (queryAccepted != KErrNone) |
247 // Connect to the SCP server, and request the code query |
251 { |
248 RSCPClient scpClient; |
252 RMobilePhone::TMobilePhoneSecurityCode secCodeType; |
249 User::LeaveIfError( scpClient.Connect() ); |
253 secCodeType = RMobilePhone::ESecurityCodePhonePassword; |
250 CleanupClosePushL( scpClient ); |
254 |
251 status = scpClient.SecCodeQuery( password, |
255 /* request PIN using QT */ |
252 RSCPClient::SCP_OK_CANCEL, |
256 CSecQueryUi *iSecQueryUi; |
253 EFalse, |
257 RDEBUG("CSecQueryUi", 0); |
254 0 ); |
258 iSecQueryUi = CSecQueryUi::NewL(); |
255 |
259 iQueryCanceled = EFalse; |
256 if ( status != KErrCancel ) |
260 lAlphaSupported = ESecUiAlphaSupported; |
257 { |
261 lCancelSupported = ESecUiCancelSupported; |
258 // Set this "true" to indicate that the input wasn't cancelled |
262 TBuf<0x100> title; |
259 ret = ETrue; |
263 title.Zero(); |
260 } |
264 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_sec_code")); |
261 else |
265 title.Append(stringHolder->Des()); |
|
266 CleanupStack::PopAndDestroy(stringHolder); |
|
267 title.Append(_L("$")); |
|
268 title.AppendNum(-1); // Don't know the number of remaining attempts |
|
269 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, ESecUiSecretSupported | lAlphaSupported |
|
270 | lCancelSupported | secCodeType); |
|
271 RDEBUG("iSecUi_password", 0); |
|
272 RDEBUGSTR(iSecUi_password); |
|
273 RDEBUG("delete", 0); |
|
274 iQueryCanceled = ETrue; |
|
275 delete iSecQueryUi; |
|
276 RDEBUG("queryAccepted", queryAccepted); |
|
277 /* end request PIN using QT */ |
|
278 if (queryAccepted != KErrNone) |
|
279 { |
262 { |
280 ret = EFalse; |
263 ret = EFalse; |
281 return ret; |
264 } |
282 } |
265 |
283 |
266 CleanupStack::PopAndDestroy(); //scpClient |
284 CWait* wait = CWait::NewL(); |
267 } |
285 RDEBUG("VerifySecurityCode", 0); |
268 else |
286 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); |
269 { |
287 RDEBUG("WaitForRequestL", 0); |
270 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone); |
288 status = wait->WaitForRequestL(); |
271 #ifdef __COVER_DISPLAY |
289 RDEBUG("status", status); |
272 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
290 delete wait; |
273 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
291 #ifdef __WINS__ |
274 if (covercl) // returns null if __COVER_DISPLAY is not defined |
292 if (status == KErrNotSupported || status == KErrTimedOut) |
275 { |
293 { |
276 // … - add data that cover ui is interested in |
294 RDEBUG("status", status); |
277 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode);// adds int to additional data to be posted to cover ui |
295 status = KErrNone; |
278 covercl->BufStream().CommitL(); // no more data to send so commit buf |
296 } |
279 } |
297 #endif |
280 #endif //__COVER_DISPLAY |
298 |
281 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
299 ret = ETrue; |
282 CleanupStack::PushL(deviceLockStatusObserver); |
300 queryAccepted = KErrCancel; // because it's not yet validated |
283 err =KErrNone; |
301 switch (status) |
284 TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY)); |
302 { |
285 CleanupStack::PopAndDestroy(deviceLockStatusObserver); |
303 case KErrNone: |
286 } |
|
287 |
|
288 // check if CSecurityHandler has been "killed" |
|
289 if ( thisDestroyed ) |
|
290 { |
|
291 return EFalse; |
|
292 } |
|
293 |
|
294 iDestroyedPtr = NULL; |
|
295 iSecurityDlg = NULL; |
|
296 |
|
297 if (err != KErrNone) |
|
298 { |
|
299 User::Leave(err); |
|
300 } |
|
301 |
|
302 if (ret) |
|
303 { |
|
304 while (!iQueryCanceled) |
|
305 { |
|
306 if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
307 { |
|
308 RMobilePhone::TMobilePhoneSecurityCode secCodeType; |
|
309 secCodeType = RMobilePhone::ESecurityCodePhonePassword; |
|
310 CWait* wait = CWait::NewL(); |
|
311 iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth); |
|
312 status = wait->WaitForRequestL(); |
|
313 delete wait; |
|
314 |
|
315 } |
|
316 |
|
317 switch(status) |
|
318 { |
|
319 case KErrNone: |
|
320 { |
|
321 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
|
322 !(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))) |
|
323 { |
|
324 RSCPClient scpClient; |
|
325 User::LeaveIfError( scpClient.Connect() ); |
|
326 CleanupClosePushL( scpClient ); |
|
327 |
|
328 TSCPSecCode newCode; |
|
329 newCode.Copy( password ); |
|
330 scpClient.StoreCode( newCode ); |
|
331 |
|
332 CleanupStack::PopAndDestroy(); //scpClient |
|
333 } |
|
334 |
|
335 iQueryCanceled = ETrue; |
|
336 return ETrue; |
|
337 } |
|
338 case KErrGsmSSPasswordAttemptsViolation: |
|
339 case KErrLocked: |
|
340 { |
|
341 iDestroyedPtr = &thisDestroyed; |
|
342 // security code blocked! |
|
343 iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg)); |
|
344 iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
345 iNoteDlg->SetTone(CAknNoteDialog::EErrorTone); |
|
346 err =KErrNone; |
|
347 TRAP(err,iNoteDlg->ExecuteLD(R_SEC_BLOCKED)); |
|
348 |
|
349 // check if CSecurityHandler has been "killed" |
|
350 if ( thisDestroyed ) |
|
351 { |
|
352 return EFalse; |
|
353 } |
|
354 |
|
355 iDestroyedPtr = NULL; |
|
356 iNoteDlg = NULL; |
|
357 |
|
358 if (err != KErrNone) |
|
359 { |
|
360 User::Leave(err); |
|
361 } |
|
362 break; |
|
363 } |
|
364 case KErrGsm0707IncorrectPassword: |
|
365 case KErrAccessDenied: |
|
366 { |
|
367 iDestroyedPtr = &thisDestroyed; |
|
368 // code was entered erroneusly |
|
369 iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg)); |
|
370 iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
371 iNoteDlg->SetTone(CAknNoteDialog::EErrorTone); |
|
372 err =KErrNone; |
|
373 TRAP(err,iNoteDlg->ExecuteLD(R_CODE_ERROR)); |
|
374 |
|
375 // check if CSecurityHandler has been "killed" |
|
376 if ( thisDestroyed ) |
|
377 { |
|
378 return EFalse; |
|
379 } |
|
380 |
|
381 iDestroyedPtr = NULL; |
|
382 iNoteDlg = NULL; |
|
383 |
|
384 if (err != KErrNone) |
|
385 { |
|
386 User::Leave(err); |
|
387 } |
|
388 break; |
|
389 } |
|
390 default: |
|
391 { |
|
392 iDestroyedPtr = &thisDestroyed; |
|
393 err =KErrNone; |
|
394 TRAP(err,ShowGenericErrorNoteL(status)); |
|
395 |
|
396 // check if CSecurityHandler has been "killed" |
|
397 if ( thisDestroyed ) |
|
398 { |
|
399 return EFalse; |
|
400 } |
|
401 |
|
402 iDestroyedPtr = NULL; |
|
403 iNoteDlg = NULL; |
|
404 |
|
405 if (err != KErrNone) |
|
406 { |
|
407 User::Leave(err); |
|
408 } |
|
409 break; |
|
410 } |
|
411 } |
|
412 |
|
413 if (iQueryCanceled) |
304 { |
414 { |
305 if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw) && !(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))) |
415 ret = EFalse; |
|
416 break; |
|
417 } |
|
418 |
|
419 password = _L(""); |
|
420 iDestroyedPtr = &thisDestroyed; |
|
421 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
|
422 FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
423 { |
|
424 // Connect to the SCP server, and request the code query |
|
425 RSCPClient scpClient; |
|
426 User::LeaveIfError( scpClient.Connect() ); |
|
427 CleanupClosePushL( scpClient ); |
|
428 status = scpClient.SecCodeQuery( password, |
|
429 RSCPClient::SCP_OK_CANCEL, |
|
430 EFalse, |
|
431 0 ); |
|
432 |
|
433 if ( status != KErrCancel ) |
306 { |
434 { |
307 RDEBUG("calling RSCPClient", 0); |
435 // Set this "true" to indicate that the input wasn't cancelled |
308 RSCPClient scpClient; |
436 ret = ETrue; |
309 User::LeaveIfError(scpClient.Connect()); |
|
310 CleanupClosePushL(scpClient); |
|
311 |
|
312 TSCPSecCode newCode; |
|
313 RDEBUG("iSecUi_password", 1); |
|
314 RDEBUGSTR(iSecUi_password); |
|
315 newCode.Copy(iSecUi_password); |
|
316 RDEBUG( |
|
317 "!!!!!!! ***** deprecated **** !!!!! scpClient.StoreCode", |
|
318 0); |
|
319 scpClient.StoreCode(newCode); |
|
320 RDEBUG("called StoreCode", 1); |
|
321 |
|
322 CleanupStack::PopAndDestroy(); //scpClient |
|
323 queryAccepted = KErrNone; |
|
324 } |
437 } |
325 |
438 else |
326 iQueryCanceled = ETrue; |
439 { |
327 return ETrue; |
440 ret = EFalse; |
|
441 } |
|
442 |
|
443 CleanupStack::PopAndDestroy(); //scpClient |
|
444 } |
|
445 else |
|
446 { |
|
447 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone); |
|
448 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
|
449 CleanupStack::PushL(deviceLockStatusObserver); |
|
450 err =KErrNone; |
|
451 TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY)); |
|
452 CleanupStack::PopAndDestroy(deviceLockStatusObserver); |
|
453 } |
|
454 |
|
455 // check if CSecurityHandler has been "killed" |
|
456 if ( thisDestroyed ) |
|
457 { |
|
458 return EFalse; |
328 } |
459 } |
329 case KErrGsmSSPasswordAttemptsViolation: |
460 |
330 case KErrLocked: |
461 iDestroyedPtr = NULL; |
|
462 iSecurityDlg = NULL; |
|
463 |
|
464 if (err != KErrNone) |
331 { |
465 { |
332 // security code blocked! |
466 User::Leave(err); |
333 CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); |
467 } |
|
468 |
|
469 if (!ret) |
334 break; |
470 break; |
335 } |
|
336 case KErrGsm0707IncorrectPassword: |
|
337 case KErrAccessDenied: |
|
338 { |
|
339 // code was entered erroneusly |
|
340 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
|
341 break; |
|
342 } |
|
343 default: |
|
344 { |
|
345 CSecuritySettings::ShowResultNoteL(status, CAknNoteDialog::EErrorTone); |
|
346 } |
|
347 } |
|
348 } // while |
471 } // while |
|
472 } // if |
349 |
473 |
350 iQueryCanceled = ETrue; |
474 iQueryCanceled = ETrue; |
351 return ret; |
475 return ret; |
352 } |
476 } |
353 // |
477 // |
354 // ---------------------------------------------------------- |
478 // ---------------------------------------------------------- |
355 // Cancels all security code queries |
479 // CSecurityHandler::CancelSecCodeQuery() |
356 // aStatus = -1 from destructor |
480 // Cancels PIN2 and security code queries |
357 // aStatus = 1 from API. Will kill all dialogs through signal P&S |
481 // ---------------------------------------------------------- |
358 // ---------------------------------------------------------- |
482 // |
359 // qtdone |
483 EXPORT_C void CSecurityHandler::CancelSecCodeQuery() |
360 TInt CSecurityHandler::CancelOpenQuery(TInt aStatus) |
|
361 { |
484 { |
362 RDEBUG("aStatus", aStatus); |
485 #if defined(_DEBUG) |
363 RDEBUG("iQueryCanceled", iQueryCanceled); |
486 RDebug::Print(_L("(SECUI)CSecurityHandler::CancelSecCodeQuery()")); |
364 TInt res = 0; |
487 #endif |
365 |
|
366 if (aStatus == 1) // also signal all other dialogs |
|
367 { |
|
368 RDEBUG( |
|
369 "set KSecurityUIsDismissDialog to ESecurityUIsDismissDialogOn", |
|
370 ESecurityUIsDismissDialogOn); |
|
371 TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn); |
|
372 RDEBUG("err", err); |
|
373 res += 1; |
|
374 } |
|
375 |
|
376 if (!iQueryCanceled) |
488 if (!iQueryCanceled) |
377 { |
489 { |
378 // notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged |
|
379 // this will cancel only the dialog which was opened by same client. |
|
380 res += 0x10; |
|
381 iQueryCanceled = ETrue; |
490 iQueryCanceled = ETrue; |
382 if (iSecurityDlg != NULL) |
491 if (iSecurityDlg != NULL) |
383 { |
492 { |
384 RDEBUG("deleting iSecurityDlg", 0); |
|
385 res += 0x100; |
|
386 delete iSecurityDlg; |
493 delete iSecurityDlg; |
387 } |
494 } |
388 if (iNoteDlg != NULL) |
495 if (iNoteDlg != NULL) |
389 { |
496 { |
390 RDEBUG("deleting iNoteDlg", 0); |
|
391 res += 0x1000; |
|
392 delete iNoteDlg; |
497 delete iNoteDlg; |
393 } |
498 } |
394 iNoteDlg = NULL; |
499 iNoteDlg = NULL; |
395 iSecurityDlg = NULL; |
500 iSecurityDlg = NULL; |
396 } |
501 } |
397 res += 0x10000; |
|
398 RDEBUG("res", res); |
|
399 return res; |
|
400 } |
|
401 |
|
402 // |
|
403 // ---------------------------------------------------------- |
|
404 // CSecurityHandler::CancelSecCodeQuery() |
|
405 // Cancels PIN2 and security code queries |
|
406 // this is used by rfsHandler |
|
407 // ---------------------------------------------------------- |
|
408 // qtdone |
|
409 EXPORT_C void CSecurityHandler::CancelSecCodeQuery() |
|
410 { |
|
411 RDEBUG("0", 0); |
|
412 |
|
413 TInt err = CancelOpenQuery(1); |
|
414 |
|
415 RDEBUG("err", err); |
|
416 } |
502 } |
417 // |
503 // |
418 // ---------------------------------------------------------- |
504 // ---------------------------------------------------------- |
419 // CSecurityHandler::AskSecCodeInAutoLock() |
505 // CSecurityHandler::AskSecCodeInAutoLock() |
420 // for asking security code in autolock |
506 // for asking security code in autolock |
421 // ---------------------------------------------------------- |
507 // ---------------------------------------------------------- |
422 // qtdone |
508 // |
423 EXPORT_C TBool CSecurityHandler::AskSecCodeInAutoLockL() |
509 EXPORT_C TBool CSecurityHandler::AskSecCodeInAutoLockL() |
424 { |
510 { |
425 /***************************************************** |
511 /***************************************************** |
426 * Series 60 Customer / ETel |
512 * Series 60 Customer / ETel |
427 * Series 60 ETel API |
513 * Series 60 ETel API |
428 *****************************************************/ |
514 *****************************************************/ |
429 |
515 |
430 RDEBUG("0", 0); |
516 #ifdef __WINS__ |
|
517 return ETrue; |
|
518 #else |
|
519 #if defined(_DEBUG) |
|
520 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL()")); |
|
521 #endif |
431 TInt res; |
522 TInt res; |
432 CWait* wait; |
523 CWait* wait; |
433 |
524 |
434 RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); |
525 RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); |
435 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
526 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
527 |
|
528 #if defined(_DEBUG) |
|
529 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() get autolock period")); |
|
530 #endif |
436 |
531 |
437 // get autolock period from Central Repository. |
532 // get autolock period from Central Repository. |
438 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
533 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
439 TInt period = 0; |
534 TInt period = 0; |
440 res = repository->Get(KSettingsAutoLockTime, period); |
535 res = repository->Get(KSettingsAutoLockTime, period); |
441 delete repository; |
536 delete repository; |
442 |
537 |
443 RDEBUG("res", res); |
538 #if defined(_DEBUG) |
444 RDEBUG("period", period); |
539 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() autolock period:%d"), res); |
445 |
540 #endif |
446 if (res == KErrNone) |
541 if (res == KErrNone) |
447 { |
542 { |
448 // disable autolock in Domestic OS side too if autolock period is 0. |
543 // disable autolock in Domestic OS side too if autolock period is 0. |
449 if (period == 0) |
544 if (period == 0 ) |
450 { |
545 { |
451 RDEBUG("period", period); |
546 #if defined(_DEBUG) |
|
547 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting")); |
|
548 #endif |
|
549 |
|
550 #ifdef RD_REMOTELOCK |
452 |
551 |
453 // If remote lock is enabled, don't disable the domestic OS device lock |
552 // If remote lock is enabled, don't disable the domestic OS device lock |
454 // since that would render the RemoteLock useless. |
553 // since that would render the RemoteLock useless. |
455 // Instead just re-set the DOS lock to enabled which as a side effect |
554 // Instead just re-set the DOS lock to enabled which as a side effect |
456 // requests the security code from the user. |
555 // requests the security code from the user. |
457 |
556 |
458 TBool remoteLockStatus(EFalse); |
557 TBool remoteLockStatus( EFalse ); |
459 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
558 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
460 |
559 |
461 if (remoteLockSettings->GetEnabled(remoteLockStatus)) |
560 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
462 { |
561 { |
463 RDEBUG("0", 0); |
562 if ( remoteLockStatus ) |
464 if (remoteLockStatus) |
|
465 { |
563 { |
466 // Remote lock is enabled |
564 // Remote lock is enabled |
|
565 #ifdef _DEBUG |
|
566 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) ); |
|
567 #endif // _DEBUG |
|
568 |
467 lockChange = RMobilePhone::ELockSetEnabled; |
569 lockChange = RMobilePhone::ELockSetEnabled; |
468 RDEBUG("lockChange", lockChange); |
|
469 } |
570 } |
470 else |
571 else |
471 { |
572 { |
472 // Remote lock is disabled |
573 // Remote lock is disabled |
|
574 #ifdef _DEBUG |
|
575 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) ); |
|
576 #endif // _DEBUG |
|
577 |
473 lockChange = RMobilePhone::ELockSetDisabled; |
578 lockChange = RMobilePhone::ELockSetDisabled; |
474 RDEBUG("lockChange", lockChange); |
|
475 } |
579 } |
476 } |
580 } |
477 else |
581 else |
478 { |
582 { |
479 // Failed to get remote lock status |
583 // Failed to get remote lock status |
480 RDEBUG("Failed", lockChange); |
584 #ifdef _DEBUG |
|
585 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get RemoteLock status" ) ); |
|
586 #endif // _DEBUG |
481 } |
587 } |
482 |
588 |
483 delete remoteLockSettings; |
589 delete remoteLockSettings; |
484 remoteLockSettings = NULL; |
590 remoteLockSettings = NULL; |
485 |
591 |
486 RDEBUG("lockChange", lockChange); |
592 #else // not defined RD_REMOTELOCK |
487 wait = CWait::NewL(); |
593 |
488 RDEBUG("0", 0); |
594 lockChange = RMobilePhone::ELockSetDisabled; |
489 // this also calls PassPhraseRequiredL ??? |
595 |
490 RDEBUG("SetLockSetting", 1); |
596 #endif // RD_REMOTELOCK |
491 iPhone.SetLockSetting(wait->iStatus, lockType, lockChange); |
597 |
492 res = KErrNone; |
598 wait = CWait::NewL(); |
493 RDEBUG("WaitForRequestL", 0); |
599 iPhone.SetLockSetting(wait->iStatus,lockType,lockChange); |
494 res = wait->WaitForRequestL(); |
600 res = wait->WaitForRequestL(); |
495 RDEBUG("res", res); |
601 delete wait; |
496 delete wait; |
602 #if defined(_DEBUG) |
497 } // from period == 0 |
603 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() SetLockSetting RESULT:%d"), res); |
|
604 #endif |
|
605 } |
498 else |
606 else |
499 { // ask security code |
607 { // ask security code |
500 RDEBUG("codeQueryNotifier 0", 0); |
608 #if defined(_DEBUG) |
501 RNotifier codeQueryNotifier; |
609 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Ask sec code via notifier")); |
502 User::LeaveIfError(codeQueryNotifier.Connect()); |
610 #endif |
503 CWait* wait = CWait::NewL(); |
611 RNotifier codeQueryNotifier; |
504 CleanupStack::PushL(wait); |
612 User::LeaveIfError(codeQueryNotifier.Connect()); |
505 TInt queryResponse = 0; |
613 CWait* wait = CWait::NewL(); |
506 TPckg<TInt> response(queryResponse); |
614 CleanupStack::PushL(wait); |
507 RDEBUG("0", 0); |
615 TInt queryResponse = 0; |
508 TSecurityNotificationPckg params; |
616 TPckg<TInt> response(queryResponse); |
509 params().iEvent = static_cast<TInt> (RMobilePhone::EPhonePasswordRequired); |
617 TSecurityNotificationPckg params; |
510 params().iStartup = EFalse; |
618 params().iEvent = static_cast<TInt>(RMobilePhone::EPhonePasswordRequired); |
511 |
619 params().iStartup = EFalse; |
512 RDEBUG("StartNotifierAndGetResponse", 0); |
620 #if defined(_DEBUG) |
513 codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid, params, response); |
621 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Start Notifier")); |
514 // this will eventually call PassPhraseRequiredL |
622 #endif |
515 RDEBUG("WaitForRequestL", 0); |
623 codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid,params, response); |
516 res = wait->WaitForRequestL(); |
624 res = wait->WaitForRequestL(); |
517 RDEBUG("WaitForRequestL", 1); |
625 CleanupStack::PopAndDestroy(); // wait |
518 RDEBUG("res", res); |
626 #if defined(_DEBUG) |
519 CleanupStack::PopAndDestroy(); // wait |
627 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() results:")); |
520 if (res == KErrNone) |
628 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() res:%d"), res); |
521 res = queryResponse; |
629 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() queryResponse:%d"), queryResponse); |
522 } // from else period == 0 |
630 #endif |
523 RDEBUG("0", 0); |
631 if(res == KErrNone) |
|
632 res = queryResponse; |
|
633 } |
524 } |
634 } |
525 else |
635 else |
526 { // can't read repository for KSettingsAutoLockTime |
636 { |
527 RDEBUG("KERRSOMETHING:Call SetLockSetting", 0); |
637 #if defined(_DEBUG) |
|
638 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KERRSOMETHING:Call SetLockSetting")); |
|
639 #endif |
|
640 |
|
641 #ifdef RD_REMOTELOCK |
528 |
642 |
529 // If remote lock is enabled, don't disable the domestic OS device lock |
643 // If remote lock is enabled, don't disable the domestic OS device lock |
530 // since that would render the RemoteLock useless. |
644 // since that would render the RemoteLock useless. |
531 // Instead just re-set the DOS lock to enabled which as a side effect |
645 // Instead just re-set the DOS lock to enabled which as a side effect |
532 // requests the security code from the user. |
646 // requests the security code from the user. |
533 |
647 |
534 TBool remoteLockStatus(EFalse); |
648 TBool remoteLockStatus( EFalse ); |
535 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
649 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
536 |
650 |
537 if (remoteLockSettings->GetEnabled(remoteLockStatus)) |
651 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
538 { |
652 { |
539 if (remoteLockStatus) |
653 if ( remoteLockStatus ) |
540 { |
654 { |
541 // Remote lock is enabled |
655 // Remote lock is enabled |
|
656 #ifdef _DEBUG |
|
657 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) ); |
|
658 #endif // _DEBUG |
|
659 |
542 lockChange = RMobilePhone::ELockSetEnabled; |
660 lockChange = RMobilePhone::ELockSetEnabled; |
543 RDEBUG("lockChange", lockChange); |
|
544 } |
661 } |
545 else |
662 else |
546 { |
663 { |
547 // Remote lock is disabled |
664 // Remote lock is disabled |
|
665 #ifdef _DEBUG |
|
666 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) ); |
|
667 #endif // _DEBUG |
|
668 |
548 lockChange = RMobilePhone::ELockSetDisabled; |
669 lockChange = RMobilePhone::ELockSetDisabled; |
549 RDEBUG("lockChange", lockChange); |
|
550 } |
670 } |
551 } |
671 } |
552 else |
672 else |
553 { |
673 { |
554 // Failed to get remote lock status |
674 // Failed to get remote lock status |
555 RDEBUG("Failed", lockChange); |
675 #ifdef _DEBUG |
|
676 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and failed to get RemoteLock status" ) ); |
|
677 #endif // _DEBUG |
556 } |
678 } |
557 |
679 |
558 delete remoteLockSettings; |
680 delete remoteLockSettings; |
559 remoteLockSettings = NULL; |
681 remoteLockSettings = NULL; |
560 |
682 |
561 RDEBUG("0", 0); |
683 #else // not defined RD_REMOTELOCK |
|
684 |
|
685 // could not get the current autolock time... disable autolock in Domestic OS side. |
|
686 lockChange = RMobilePhone::ELockSetDisabled; |
|
687 |
|
688 #endif // RD_REMOTELOCK |
|
689 |
562 wait = CWait::NewL(); |
690 wait = CWait::NewL(); |
563 RDEBUG("SetLockSetting", 0); |
691 iPhone.SetLockSetting(wait->iStatus,lockType,lockChange); |
564 iPhone.SetLockSetting(wait->iStatus, lockType, lockChange); |
|
565 RDEBUG("WaitForRequestL", 0); |
|
566 res = wait->WaitForRequestL(); |
692 res = wait->WaitForRequestL(); |
567 RDEBUG("WaitForRequestL res", res); |
|
568 delete wait; |
693 delete wait; |
569 } |
694 #if defined(_DEBUG) |
570 |
695 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KES: SetLockSetting RESULT:%d"), res); |
571 RDEBUG("res", res); |
696 #endif |
|
697 } |
|
698 |
572 switch (res) |
699 switch (res) |
573 { |
700 { |
574 case KErrNone: |
701 case KErrNone: |
575 { |
702 { |
576 return ETrue; |
703 return ETrue; |
577 } |
704 } |
|
705 |
578 case KErrGsmSSPasswordAttemptsViolation: |
706 case KErrGsmSSPasswordAttemptsViolation: |
579 case KErrLocked: |
707 case KErrLocked: |
580 case KErrGsm0707IncorrectPassword: |
708 case KErrGsm0707IncorrectPassword: |
581 case KErrAccessDenied: |
709 case KErrAccessDenied: |
582 { |
710 { |
583 RDEBUG("KErrAccessDenied", KErrAccessDenied); |
711 return AskSecCodeInAutoLockL(); |
584 return AskSecCodeInAutoLockL(); |
|
585 } |
|
586 case KErrInUse: |
|
587 { |
|
588 RDEBUG("KErrInUse", KErrInUse); |
|
589 return EFalse; |
|
590 } |
|
591 case KErrDied: |
|
592 { |
|
593 RDEBUG("KErrDied ", KErrDied); |
|
594 return EFalse; |
|
595 } |
|
596 case KErrServerTerminated: |
|
597 { |
|
598 RDEBUG("KErrServerTerminated ", KErrServerTerminated); |
|
599 return EFalse; |
|
600 } |
|
601 case KErrServerBusy: |
|
602 { |
|
603 RDEBUG("KErrServerBusy ", KErrServerBusy); |
|
604 return EFalse; |
|
605 } |
712 } |
606 case KErrAbort: |
713 case KErrAbort: |
607 { |
|
608 RDEBUG("KErrAbort", KErrAbort); |
|
609 return EFalse; |
|
610 } |
|
611 case KErrCancel: |
714 case KErrCancel: |
612 { |
|
613 RDEBUG("KErrCancel", KErrCancel); |
|
614 // user pressed "cancel" |
715 // user pressed "cancel" |
615 return EFalse; |
716 return EFalse; |
616 } |
|
617 default: |
717 default: |
618 { |
718 { |
619 RDEBUG("default", res); |
|
620 return AskSecCodeInAutoLockL(); |
719 return AskSecCodeInAutoLockL(); |
621 } |
720 } |
622 } |
721 } |
|
722 #endif // WINS |
623 } |
723 } |
624 // |
724 // |
625 // ---------------------------------------------------------- |
725 // ---------------------------------------------------------- |
626 // CSecurityHandler::PassPhraseRequired() |
726 // CSecurityHandler::PassPhraseRequired() |
627 // Handles PassPhraseRequired event |
727 // Handles PassPhraseRequired event |
628 // ---------------------------------------------------------- |
728 // ---------------------------------------------------------- |
629 // qtdone |
729 // |
630 TInt CSecurityHandler::PassPhraseRequiredL() |
730 TInt CSecurityHandler::PassPhraseRequiredL() |
631 { |
731 { |
632 /***************************************************** |
732 /***************************************************** |
633 * Series 60 Customer / ETel |
733 * Series 60 Customer / ETel |
634 * Series 60 ETel API |
734 * Series 60 ETel API |
635 *****************************************************/ |
735 *****************************************************/ |
636 RDEBUG("0", 0); |
736 #if defined(_DEBUG) |
|
737 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()")); |
|
738 #endif |
637 TBool StartUp = iStartup; |
739 TBool StartUp = iStartup; |
638 |
740 |
639 RMobilePhone::TMobilePassword iSecUi_password; |
741 RMobilePhone::TMobilePassword password; |
640 RMobilePhone::TMobilePassword required_fourth; |
742 RMobilePhone::TMobilePassword required_fourth; |
641 TInt queryAccepted = KErrCancel; |
743 TInt status; |
642 |
744 TInt autolockState; |
643 TInt autolockState = 0; |
745 TInt err( KErrGeneral ); |
644 TInt lCancelSupported = 0; |
|
645 TInt lEmergencySupported = 0; |
|
646 |
|
647 TInt err(KErrGeneral); |
|
648 err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
746 err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
649 RDEBUG("StartUp", StartUp); |
747 #if defined(_DEBUG) |
650 RDEBUG("err", err); |
748 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Autolock Status result: %d"), err); |
651 if (!StartUp) |
749 #endif |
652 { |
750 if(!StartUp) |
653 RDebug::Printf("%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err); |
751 User::LeaveIfError( err ); |
654 User::LeaveIfError(err); |
752 TBool isConditionSatisfied = EFalse; |
655 } |
753 TInt tarmFlag=0; |
656 TBool isConditionSatisfied = EFalse; |
754 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
657 TInt tarmFlag = 0; |
755 { |
658 if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) |
756 TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
659 { |
757 |
660 TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); |
758 if ( tRet != KErrNone ) |
661 |
759 { |
662 if (tRet != KErrNone) |
760 #if defined(_DEBUG) |
663 { |
761 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\ |
664 RDEBUG("Warning: failed to get TARM Admin Flag state", tRet); |
762 Warning: failed to get TARM Admin Flag state")); |
665 } |
763 #endif |
|
764 } |
|
765 else |
|
766 { |
|
767 #if defined(_DEBUG) |
|
768 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL(): TARM flag: %d"), tarmFlag ); |
|
769 #endif |
|
770 } |
|
771 |
|
772 if ( ( StartUp ) || ( tarmFlag & KSCPFlagResyncQuery ) ) |
|
773 isConditionSatisfied = ETrue; |
|
774 } |
|
775 else |
|
776 { |
|
777 if (StartUp) |
|
778 isConditionSatisfied = ETrue; |
|
779 } |
|
780 |
|
781 // call TARM so that it verifies that configuration is in sync. This might internally accept the (default) lock code, but doesn't dismiss the query. |
|
782 #if defined(_DEBUG) |
|
783 RDebug::Printf( "%s %s (%u) pre isConditionSatisfied=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, isConditionSatisfied ); |
|
784 #endif |
|
785 RSCPClient scpClientConfiguration; |
|
786 User::LeaveIfError( scpClientConfiguration.Connect() ); |
|
787 CleanupClosePushL( scpClientConfiguration ); |
|
788 #if defined(_DEBUG) |
|
789 RDebug::Printf( "%s %s (%u) calling CheckConfiguration KSCPComplete=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KSCPComplete ); |
|
790 #endif |
|
791 TInt finalConfStatus = scpClientConfiguration.CheckConfiguration( KSCPComplete ); |
|
792 #if defined(_DEBUG) |
|
793 RDebug::Printf( "%s %s (%u) finalConfStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, finalConfStatus ); |
|
794 RDebug::Printf( "%s %s (%u) isConditionSatisfied=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, isConditionSatisfied ); |
|
795 #endif |
|
796 CleanupStack::PopAndDestroy(); // scpClientConfiguration |
|
797 |
|
798 if (isConditionSatisfied) |
|
799 { |
|
800 #if defined(_DEBUG) |
|
801 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1")); |
|
802 #endif |
|
803 // Security code at bootup: No "cancel" softkey; Emergency calls enabled. |
|
804 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
|
805 FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
806 { |
|
807 // Connect to the SCP server, and request the code query |
|
808 RSCPClient scpClient; |
|
809 User::LeaveIfError( scpClient.Connect() ); |
|
810 CleanupClosePushL( scpClient ); |
|
811 |
|
812 status = scpClient.SecCodeQuery( password, |
|
813 RSCPClient::SCP_OK_ETEL, |
|
814 ETrue, |
|
815 KSCPEtelRequest ); |
|
816 // Note that SecCodeQuery doesn't indicate the return value from the dialog |
|
817 |
|
818 CleanupStack::PopAndDestroy(); //scpClient |
|
819 } |
|
820 else |
|
821 { |
|
822 CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiCodeEtelReqest); |
|
823 if(AknLayoutUtils::PenEnabled()) |
|
824 securityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
666 else |
825 else |
667 { |
826 securityDlg->SetEmergencyCallSupport(ETrue); |
668 RDEBUG("TARM flag", tarmFlag); |
827 #ifdef __COVER_DISPLAY |
669 } |
828 securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
670 |
829 CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided |
671 if ((StartUp) || (tarmFlag & KSCPFlagResyncQuery)) |
830 if (covercl) // returns null if __COVER_DISPLAY is not defined |
672 isConditionSatisfied = ETrue; |
831 { |
673 } |
832 // … - add data that cover ui is interested in |
674 else |
833 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui |
675 { |
834 covercl->BufStream().CommitL(); // no more data to send so commit buf |
676 if (StartUp) |
835 } |
677 isConditionSatisfied = ETrue; |
836 #endif //__COVER_DISPLAY |
678 } |
837 status = securityDlg->ExecuteLD(R_SECURITY_REQUEST_QUERY); |
679 |
838 } |
680 // Security code at bootup: No "cancel" softkey; Emergency calls enabled. |
839 } |
681 RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = RMobilePhone::ESecurityCodePhonePassword; |
840 else if ( (autolockState > EAutolockOff)) |
682 RDEBUG("isConditionSatisfied", isConditionSatisfied); |
841 { |
683 if (isConditionSatisfied) |
842 #if defined(_DEBUG) |
684 { |
843 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 2")); |
685 // starter or special TARM. NoCancel+Emergency |
844 #endif |
686 lCancelSupported = ESecUiCancelNotSupported; |
845 // Autolock is On. Security event came from user pressing "unlock". |
687 lEmergencySupported = ESecUiEmergencySupported; |
846 // Emergency call support must be enabled and there must be a "cancel" softkey. |
688 } |
847 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
689 else if (autolockState > EAutolockOff) |
848 FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
690 { |
849 { |
691 // from unlock. Cancel+Emergency |
850 // Connect to the SCP server, and request the code query |
692 lCancelSupported = ESecUiCancelSupported; |
851 RSCPClient scpClient; |
693 lEmergencySupported = ESecUiEmergencySupported; |
852 User::LeaveIfError( scpClient.Connect() ); |
694 } |
853 CleanupClosePushL( scpClient ); |
695 else |
854 |
696 { |
855 status = scpClient.SecCodeQuery( password, |
697 // from settings. Cancel+NoEmergency |
856 RSCPClient::SCP_OK_CANCEL, |
698 lCancelSupported = ESecUiCancelSupported; |
857 ETrue, |
699 lEmergencySupported = ESecUiEmergencyNotSupported; |
858 KSCPEtelRequest ); |
700 } |
859 // Note that SecCodeQuery doesn't indicate the return value from the dialog |
701 |
860 |
702 CSecQueryUi *iSecQueryUi; |
861 CleanupStack::PopAndDestroy(); //scpClient |
703 iSecQueryUi = CSecQueryUi::NewL(); |
862 } |
704 iQueryCanceled = EFalse; |
863 else |
705 TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported | lCancelSupported | lEmergencySupported | secCodeTypeToAsk; |
864 { |
706 RDEBUG("lType", lType); |
865 CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone); |
707 TBuf<0x100> title; |
866 if(AknLayoutUtils::PenEnabled()) |
708 title.Zero(); |
867 securityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
709 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_sec_code")); |
868 else |
710 title.Append(stringHolder->Des()); |
869 securityDlg->SetEmergencyCallSupport(ETrue); |
711 CleanupStack::PopAndDestroy(stringHolder); |
870 #ifdef __COVER_DISPLAY |
712 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, lType); |
871 securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
713 RDEBUG("iSecUi_password", 0); |
872 CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided |
714 RDEBUGSTR(iSecUi_password); |
873 if (covercl) // returns null if __COVER_DISPLAY is not defined |
715 RDEBUG("queryAccepted", queryAccepted); |
874 { |
716 iQueryCanceled = ETrue; |
875 // … - add data that cover ui is interested in |
717 delete iSecQueryUi; |
876 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui |
718 |
877 covercl->BufStream().CommitL(); // no more data to send so commit buf |
719 TBool wasCancelledOrEmergency = EFalse; |
878 } |
720 RDEBUG("KFeatureIdSapDeviceLockEnhancements", |
879 #endif //__COVER_DISPLAY |
721 KFeatureIdSapDeviceLockEnhancements); |
880 status = securityDlg->ExecuteLD(R_SECURITY_QUERY); |
722 if ((queryAccepted == KErrAbort /* =emergency */) || (queryAccepted == KErrCancel)) |
881 } |
723 wasCancelledOrEmergency = ETrue; |
882 } |
724 RDEBUG("wasCancelledOrEmergency", wasCancelledOrEmergency); |
883 else |
725 if (wasCancelledOrEmergency) |
884 { |
726 { |
885 #if defined(_DEBUG) |
727 RDEBUG("StartUp", StartUp); |
886 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 3")); |
|
887 #endif |
|
888 // Code query due to a setting change; "Cancel" softkey active; |
|
889 // no emergency call support. |
|
890 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) && |
|
891 FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
892 { |
|
893 // Connect to the SCP server, and request the code query |
|
894 RSCPClient scpClient; |
|
895 User::LeaveIfError( scpClient.Connect() ); |
|
896 CleanupClosePushL( scpClient ); |
|
897 |
|
898 status = scpClient.SecCodeQuery( password, |
|
899 RSCPClient::SCP_OK_CANCEL, |
|
900 EFalse, |
|
901 KSCPEtelRequest ); |
|
902 // Note that SecCodeQuery doesn't indicate the return value from the dialog |
|
903 |
|
904 CleanupStack::PopAndDestroy(); //scpClient |
|
905 } |
|
906 else |
|
907 { |
|
908 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone); |
|
909 #ifdef __COVER_DISPLAY |
|
910 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
|
911 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
|
912 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
913 { |
|
914 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui |
|
915 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
916 } |
|
917 #endif //__COVER_DISPLAY |
|
918 // read a flag to see whether the query is SecUi originated. |
|
919 TInt secUiOriginatedQuery(ESecurityUIsETelAPIOriginated); |
|
920 RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
|
921 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
|
922 CleanupStack::PushL(deviceLockStatusObserver); |
|
923 CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver); |
|
924 CleanupStack::PushL(queryStatusObserver); |
|
925 CSecUiLockObserver* callStatusObserver = NULL; |
|
926 if(secUiOriginatedQuery == ESecurityUIsSystemLockOriginated) |
|
927 { |
|
928 callStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiCallStateObserver); |
|
929 CleanupStack::PushL(callStatusObserver); |
|
930 } |
|
931 status = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY); |
|
932 |
|
933 if(callStatusObserver == NULL) |
|
934 CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver |
|
935 else |
|
936 CleanupStack::PopAndDestroy(3); //deviceLockStatusObserver, queryStatusObserver, callStatusObserver |
|
937 iSecurityDlg = NULL; |
|
938 } |
|
939 } |
|
940 TBool isCondition = EFalse; |
|
941 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
942 { |
|
943 if (!status || (status == ESecUiEmergencyCall) |
|
944 || (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked)) |
|
945 isCondition = ETrue; |
|
946 } |
|
947 else |
|
948 { |
|
949 if ( ( status == KErrCancel ) || (status == ESecUiEmergencyCall) || |
|
950 (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked)) |
|
951 isCondition = ETrue; |
|
952 } |
|
953 if (isCondition) |
|
954 { |
|
955 #if defined(_DEBUG) |
|
956 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DIALOG ERROR")); |
|
957 #endif |
728 if (!StartUp) |
958 if (!StartUp) |
729 { |
959 { |
730 RDEBUG("AbortSecurityCode", 0); |
960 #if defined(_DEBUG) |
|
961 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() ABORT CALLED!!!!!!")); |
|
962 #endif |
731 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
963 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
732 RDEBUG("AbortSecurityCode", 1); |
|
733 } |
964 } |
734 return KErrCancel; |
965 return KErrCancel; |
735 } |
966 } |
736 |
967 |
737 RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword; |
968 RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword; |
738 CWait* wait = NULL; |
969 CWait* wait = NULL; |
739 TInt status = KErrNone; |
970 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
740 |
971 { |
741 // Validate the code using SCP. This is needed to check expiration |
972 #if defined(_DEBUG) |
742 RDEBUG("AbortSecurityCode", 0); |
973 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode")); |
743 RSCPClient scpClient; |
974 #endif |
744 RDEBUG("scpClient.Connect", 0); |
|
745 TInt tRet = scpClient.Connect(); |
|
746 RDEBUG("tRet", tRet); |
|
747 |
|
748 CleanupClosePushL(scpClient); |
|
749 |
|
750 RArray<TDevicelockPolicies> aFailedPolicies; |
|
751 TDevicelockPolicies failedPolicy; |
|
752 TInt retLockcode = KErrNone; |
|
753 RMobilePhone::TMobilePassword aISACode; |
|
754 TInt aFlags = 0; |
|
755 RDEBUG("scpClient.VerifyCurrentLockcode", 0); |
|
756 // this validate on ISA . No need to do iPhone.VerifySecurityCode |
|
757 retLockcode = scpClient.VerifyCurrentLockcode(iSecUi_password, aISACode, aFailedPolicies, aFlags); |
|
758 RDEBUG("retLockcode", retLockcode); |
|
759 |
|
760 RDEBUG("aISACode", 0); |
|
761 RDEBUGSTR(aISACode); |
|
762 |
|
763 RDEBUG("aFailedPolicies.Count()", aFailedPolicies.Count()); |
|
764 RDEBUG("EDeviceLockPasscodeExpiration", EDeviceLockPasscodeExpiration); // 8 |
|
765 TInt failedEDeviceLockPasscodeExpiration = 0; |
|
766 for (TInt i = 0; i < aFailedPolicies.Count(); i++) |
|
767 { |
|
768 failedPolicy = aFailedPolicies[i]; |
|
769 RDEBUG("failedPolicy", failedPolicy); |
|
770 if (failedPolicy == EDeviceLockPasscodeExpiration) |
|
771 failedEDeviceLockPasscodeExpiration = EDeviceLockPasscodeExpiration; |
|
772 } |
|
773 RDEBUG("Close", 0); |
|
774 scpClient.Close(); |
|
775 RDEBUG("PopAndDestroy", 0); |
|
776 CleanupStack::PopAndDestroy(); //scpClient |
|
777 |
|
778 RDEBUG("failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration); |
|
779 if (failedEDeviceLockPasscodeExpiration > 0) |
|
780 { |
|
781 // the password has expired. Note that it has NOT been validated. It will be revalidated inside ChangeSecCodeParamsL |
|
782 RMobilePhone::TMobilePassword iNewPassword; |
|
783 TInt iFlags = 0; |
|
784 iNewPassword.Copy(_L("")); |
|
785 TBuf<0x80> iCaption; |
|
786 iCaption.Copy(_L("ChangeSecCodeL")); // no need to translate because it's not used |
|
787 TInt iShowError = 1; |
|
788 CSecuritySettings* iSecSettings; |
|
789 iSecSettings = CSecuritySettings::NewL(); |
|
790 TSecUi::InitializeLibL(); |
|
791 RDEBUG("calling ChangeSecCodeParamsL", 0); |
|
792 status = iSecSettings->ChangeSecCodeParamsL(iSecUi_password, iNewPassword, iFlags, iCaption, iShowError); |
|
793 // note that it might have been aborted. The error KErrAbort is shown in this method, not inside ChangeSecCodeParamsL |
|
794 if(status==KErrAccessDenied || status==KErrGsm0707IncorrectPassword) |
|
795 { |
|
796 // the password expired, but the user typed wrongly. The error was already displayed. |
|
797 RDEBUG("SCP returned ", KErrAccessDenied); |
|
798 status=R_CODES_DONT_MATCH; |
|
799 RDEBUG("SCP changed to R_CODES_DONT_MATCH", R_CODES_DONT_MATCH); |
|
800 } |
|
801 RDEBUG("status", status); |
|
802 RDEBUG("iNewPassword", 0); |
|
803 RDEBUGSTR(iNewPassword); |
|
804 TSecUi::UnInitializeLib(); |
|
805 RDEBUG("deleting iSecSettings", 0); |
|
806 delete iSecSettings; |
|
807 RDEBUG("deleted iSecSettings", 1); |
|
808 } |
|
809 else |
|
810 { |
|
811 RDEBUG( "wait", 0 ); |
|
812 wait = CWait::NewL(); |
975 wait = CWait::NewL(); |
813 RDEBUG("VerifySecurityCode", 0); |
976 iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth); |
814 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); |
|
815 RDEBUG("WaitForRequestL", |
|
816 0); |
|
817 status = wait->WaitForRequestL(); |
977 status = wait->WaitForRequestL(); |
818 RDEBUG("WaitForRequestL status", |
978 #if defined(_DEBUG) |
819 status); |
979 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode STATUS: %d"), status); |
|
980 #endif |
820 delete wait; |
981 delete wait; |
821 #ifdef __WINS__ |
982 } |
822 if (status == KErrNotSupported || status == KErrTimedOut) |
983 else |
823 { |
984 { |
824 RDEBUG( "status", status ); |
985 wait = NULL; |
825 status = KErrNone; |
986 } |
826 } |
987 |
827 #endif |
|
828 } |
|
829 |
|
830 TInt returnValue = status; |
988 TInt returnValue = status; |
831 RDEBUG("tarmFlag", tarmFlag); |
989 switch(status) |
832 RDEBUG("StartUp", StartUp); |
990 { |
833 RDEBUG("status", status); |
|
834 switch (status) |
|
835 { |
|
836 case KErrNone: |
991 case KErrNone: |
837 // code approved |
992 #if defined(_DEBUG) |
838 { |
993 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrNone")); |
839 RDEBUG("KErrNone", KErrNone); |
994 #endif |
840 if( failedEDeviceLockPasscodeExpiration > 0) |
995 // code approved |
841 { |
996 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) |
842 RDEBUG("code has just been changed. No need to show Confirmation note. failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration); |
997 { |
843 } |
|
844 else |
|
845 { |
|
846 CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); |
|
847 } |
|
848 RDEBUG("R_CONFIRMATION_NOTE", R_CONFIRMATION_NOTE); |
|
849 if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) |
|
850 { |
|
851 RDEBUG("KFeatureIdSapTerminalControlFw", |
|
852 KFeatureIdSapTerminalControlFw); |
|
853 // Unset the admin flag if set |
998 // Unset the admin flag if set |
854 if (tarmFlag & KSCPFlagResyncQuery) |
999 if ( tarmFlag & KSCPFlagResyncQuery ) |
855 { |
1000 { |
856 TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); |
1001 TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
857 |
1002 |
858 if (tRet == KErrNone) |
1003 if ( tRet == KErrNone ) |
|
1004 { |
|
1005 tarmFlag &= ~KSCPFlagResyncQuery; |
|
1006 tRet = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
1007 } |
|
1008 |
|
1009 if ( tRet != KErrNone ) |
859 { |
1010 { |
860 tarmFlag &= ~KSCPFlagResyncQuery; |
1011 #if defined(_DEBUG) |
861 tRet = RProperty::Set(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); |
1012 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\ |
862 } |
1013 FAILED to unset TARM Admin Flag")); |
863 |
1014 #endif |
864 if (tRet != KErrNone) |
1015 } |
865 { |
1016 } |
866 RDEBUG( |
1017 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
867 "FAILED to unset TARM Admin Flag tRet=", |
1018 { |
868 tRet); |
1019 RSCPClient scpClient; |
869 } |
1020 User::LeaveIfError( scpClient.Connect() ); |
870 } |
1021 CleanupClosePushL( scpClient ); |
871 if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
1022 TSCPSecCode newCode; |
872 { |
1023 newCode.Copy( password ); |
873 RDEBUG("KFeatureIdSapDeviceLockEnhancements", KFeatureIdSapDeviceLockEnhancements); |
1024 scpClient.StoreCode( newCode ); |
874 RSCPClient scpClient; |
1025 CleanupStack::PopAndDestroy(); //scpClient |
875 RDEBUG("scpClient.Connect", 0); |
|
876 TInt tRet = scpClient.Connect(); |
|
877 RDEBUG("tRet", tRet); |
|
878 User::LeaveIfError(tRet); |
|
879 RDEBUG("scpClient.Connect", 1); |
|
880 CleanupClosePushL(scpClient); |
|
881 TSCPSecCode newCode; |
|
882 newCode.Copy(iSecUi_password); |
|
883 RDEBUG( |
|
884 "!!!!!!! ***** TODO deprecated **** !!!!! scpClient.StoreCode", |
|
885 0); |
|
886 scpClient.StoreCode(newCode); |
|
887 RDEBUG("scpClient.StoreCode", 1); |
|
888 // TODO check whether code is expired. |
|
889 // This should be done by TARM, and they should ask to change the code |
|
890 CleanupStack::PopAndDestroy(); //scpClient |
|
891 } |
|
892 |
|
893 } |
1026 } |
894 RDEBUG("StartUp", StartUp); |
1027 |
|
1028 } |
|
1029 |
895 if (StartUp) |
1030 if (StartUp) |
896 { |
1031 { |
|
1032 #if defined(_DEBUG) |
|
1033 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; get autolock period.")); |
|
1034 #endif |
|
1035 |
897 // get autolock period from Central Repository. |
1036 // get autolock period from Central Repository. |
898 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
1037 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
899 TInt period = 0; |
1038 TInt period = 0; |
900 TInt res = repository->Get(KSettingsAutoLockTime, period); |
1039 TInt res = repository->Get(KSettingsAutoLockTime, period); |
901 delete repository; |
1040 delete repository; |
902 RDEBUG("res", res); |
1041 |
903 RDEBUG("period", period); |
1042 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
904 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
1043 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
905 _LIT_SECURITY_POLICY_C1(KWritePolicy, |
1044 RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); |
906 ECapabilityWriteDeviceData); |
|
907 RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); |
|
908 RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); |
1045 RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); |
909 RDEBUG("KCoreAppUIsAutolockStatus", |
1046 #if defined(_DEBUG) |
910 KCoreAppUIsAutolockStatus); |
1047 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() EAutolockOff")); |
|
1048 #endif |
911 |
1049 |
912 if (res == KErrNone) |
1050 if (res == KErrNone) |
913 { |
1051 { |
914 // disable autolock in Domestic OS side too if autolock period is 0. |
1052 // disable autolock in Domestic OS side too if autolock period is 0. |
915 if (period == 0) |
1053 if (period == 0 ) |
916 { |
1054 { |
917 // Don't disable the domestic OS device lock |
1055 #ifdef RD_REMOTELOCK |
|
1056 // If remote lock is enabled, don't disable the domestic OS device lock |
918 // since that would render the RemoteLock useless. |
1057 // since that would render the RemoteLock useless. |
919 |
1058 |
920 TBool remoteLockStatus(EFalse); |
1059 TBool remoteLockStatus( EFalse ); |
921 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
1060 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
922 |
1061 |
923 if (remoteLockSettings->GetEnabled(remoteLockStatus)) |
1062 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
924 { |
1063 { |
925 if (!remoteLockStatus) |
1064 if ( !remoteLockStatus ) |
926 { |
1065 { |
927 // Remote lock is disabled |
1066 // Remote lock is disabled |
928 RDEBUG( |
1067 #ifdef _DEBUG |
929 "Autolock and RemoteLock are disabled -> disable DOS device lock", |
1068 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) ); |
930 0); |
1069 #endif // _DEBUG |
|
1070 |
931 // Disable DOS device lock setting |
1071 // Disable DOS device lock setting |
932 RDEBUG( |
|
933 "iCustomPhone.DisablePhoneLock", |
|
934 0); |
|
935 wait = CWait::NewL(); |
1072 wait = CWait::NewL(); |
936 iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password); |
1073 iCustomPhone.DisablePhoneLock(wait->iStatus,password); |
937 RDEBUG("WaitForRequestL", 0); |
1074 wait->WaitForRequestL(); |
938 status = wait->WaitForRequestL(); |
|
939 RDEBUG("WaitForRequestL", status); |
|
940 delete wait; |
1075 delete wait; |
941 } |
1076 } |
942 } |
1077 } |
943 else |
1078 else |
944 { |
1079 { |
945 // Failed to get remote lock status |
1080 // Failed to get remote lock status |
946 RDEBUG( |
1081 #ifdef _DEBUG |
947 "Autolock is disabled, but failed to get RemoteLock status, so do nothing", |
1082 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock is disabled, but failed to get RemoteLock status, so do nothing." ) ); |
948 0); |
1083 #endif // _DEBUG |
949 } |
1084 } |
950 |
1085 |
951 delete remoteLockSettings; |
1086 delete remoteLockSettings; |
952 remoteLockSettings = NULL; |
1087 remoteLockSettings = NULL; |
953 |
1088 |
|
1089 #else // not defined RD_REMOTELOCK |
|
1090 |
|
1091 #if defined(_DEBUG) |
|
1092 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock.")); |
|
1093 #endif |
|
1094 wait = CWait::NewL(); |
|
1095 iCustomPhone.DisablePhoneLock(wait->iStatus,password); |
|
1096 wait->WaitForRequestL(); |
|
1097 #if defined(_DEBUG) |
|
1098 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock completed.")); |
|
1099 #endif |
|
1100 delete wait; |
|
1101 #endif // RD_REMOTELOCK |
954 } |
1102 } |
955 } |
1103 } |
956 else // error getting repository |
1104 else |
957 { |
1105 { |
958 RDEBUG("error getting repository", 0); |
1106 #ifdef RD_REMOTELOCK |
959 // Don't disable the domestic OS device lock |
1107 // If remote lock is enabled, don't disable the domestic OS device lock |
960 // since that would render the RemoteLock useless. |
1108 // since that would render the RemoteLock useless. |
961 |
1109 |
962 TBool remoteLockStatus(EFalse); |
1110 TBool remoteLockStatus( EFalse ); |
963 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
1111 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
964 |
1112 |
965 if (remoteLockSettings->GetEnabled(remoteLockStatus)) |
1113 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
966 { |
1114 { |
967 if (!remoteLockStatus) |
1115 if ( !remoteLockStatus ) |
968 { |
1116 { |
969 // Remote lock is disabled |
1117 // Remote lock is disabled |
970 RDEBUG("iCustomPhone.DisablePhoneLock", 0); |
1118 #ifdef _DEBUG |
|
1119 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock is disabled -> disable DOS device lock" ) ); |
|
1120 #endif // _DEBUG |
|
1121 |
971 wait = CWait::NewL(); |
1122 wait = CWait::NewL(); |
972 iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password); |
1123 iCustomPhone.DisablePhoneLock(wait->iStatus,password); |
973 RDEBUG("WaitForRequestL", 0); |
1124 wait->WaitForRequestL(); |
974 status = wait->WaitForRequestL(); |
|
975 RDEBUG("WaitForRequestL status", status); |
|
976 delete wait; |
1125 delete wait; |
977 } |
1126 } |
978 } |
1127 } |
979 else |
1128 else |
980 { |
1129 { |
981 // Failed to get remote lock status |
1130 // Failed to get remote lock status |
982 RDEBUG( |
1131 #ifdef _DEBUG |
983 "Failed to get Autolock period and RemoteLock status, so do nothing", |
1132 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock status, so do nothing." ) ); |
984 0); |
1133 #endif // _DEBUG |
985 } |
1134 } |
986 |
1135 |
987 delete remoteLockSettings; |
1136 delete remoteLockSettings; |
988 remoteLockSettings = NULL; |
1137 remoteLockSettings = NULL; |
989 |
1138 |
|
1139 #else // not defined RD_REMOTELOCK |
|
1140 |
|
1141 #if defined(_DEBUG) |
|
1142 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; Could not get autolock period.")); |
|
1143 #endif |
|
1144 // could not get the current autolock time... disable autolock in Domestic OS side. |
|
1145 wait = CWait::NewL(); |
|
1146 iCustomPhone.DisablePhoneLock(wait->iStatus,password); |
|
1147 wait->WaitForRequestL(); |
|
1148 #if defined(_DEBUG) |
|
1149 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; NO AUTOLOCK PERIOD; DisablePhoneLock completed.")); |
|
1150 #endif |
|
1151 delete wait; |
|
1152 |
|
1153 #endif // RD_REMOTELOCK |
990 } |
1154 } |
991 |
1155 |
992 } // no Startup |
1156 } |
993 } |
1157 |
994 break; |
1158 break; |
995 case KErrGsmSSPasswordAttemptsViolation: |
1159 case KErrGsmSSPasswordAttemptsViolation: |
996 case KErrLocked: |
1160 case KErrLocked: |
997 { |
|
998 // security code blocked! |
1161 // security code blocked! |
999 RDEBUG("KErrLocked", KErrLocked) |
1162 #if defined(_DEBUG) |
1000 ; |
1163 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() ErrGsmSSPasswordAttemptsViolation")); |
|
1164 #endif |
1001 CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); |
1165 CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); |
1002 } |
|
1003 break; |
1166 break; |
1004 case KErrGsm0707IncorrectPassword: |
1167 case KErrGsm0707IncorrectPassword: |
1005 case KErrAccessDenied: |
1168 case KErrAccessDenied: |
1006 { |
1169 #if defined(_DEBUG) |
1007 RDEBUG("KErrAccessDenied", KErrAccessDenied); |
1170 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword")); |
1008 // The Settings caller might retry |
1171 #endif |
1009 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1172 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1010 } |
|
1011 break; |
|
1012 case R_CODES_DONT_MATCH: // if password was supposed to be changed, but it failed (the initial verification) |
|
1013 { |
|
1014 RDEBUG("R_CODES_DONT_MATCH", R_CODES_DONT_MATCH); |
|
1015 // Error was already displayed |
|
1016 returnValue = KErrAccessDenied; |
|
1017 } |
|
1018 break; |
1173 break; |
1019 default: |
1174 default: |
1020 { |
1175 #if defined(_DEBUG) |
1021 RDEBUG("default", status); |
1176 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DEFAULT")); |
|
1177 #endif |
1022 CSecuritySettings::ShowErrorNoteL(status); |
1178 CSecuritySettings::ShowErrorNoteL(status); |
1023 // The Settings caller might retry |
|
1024 } |
|
1025 break; |
1179 break; |
1026 } |
1180 } |
1027 RDEBUG("returnValue", returnValue); |
1181 |
1028 return returnValue; |
1182 return returnValue; |
1029 } |
1183 } |
1030 // |
1184 // |
1031 // ---------------------------------------------------------- |
1185 // ---------------------------------------------------------- |
1032 // CSecurityHandler::Pin1Required() |
1186 // CSecurityHandler::Pin1Required() |
1033 // Handles Pin1Required event |
1187 // Handles Pin1Required event |
1034 // ---------------------------------------------------------- |
1188 // ---------------------------------------------------------- |
1035 // qtdone |
1189 // |
1036 TInt CSecurityHandler::Pin1RequiredL() |
1190 TInt CSecurityHandler::Pin1RequiredL() |
1037 { |
1191 { |
1038 /***************************************************** |
1192 /***************************************************** |
1039 * Series 60 Customer / ETel |
1193 * Series 60 Customer / ETel |
1040 * Series 60 ETel API |
1194 * Series 60 ETel API |
1041 *****************************************************/ |
1195 *****************************************************/ |
1042 RDEBUG("0", 0); |
1196 |
1043 |
1197 RMobilePhone::TMobilePassword password; |
1044 RMobilePhone::TMobilePassword iSecUi_password; |
|
1045 TInt lCancelSupported = ESecUiCancelNotSupported; |
|
1046 TInt lEmergencySupported = ESecUiEmergencyNotSupported; |
|
1047 TInt queryAccepted = KErrCancel; |
|
1048 TInt lAlphaSupported = 0; |
|
1049 RMobilePhone::TMobilePassword required_fourth; |
1198 RMobilePhone::TMobilePassword required_fourth; |
1050 RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1; |
1199 RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1; |
1051 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1200 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1052 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1201 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1053 TBool StartUp = ETrue; |
1202 TBool StartUp = ETrue; |
1054 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
1203 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
1055 TInt err = KErrNone; |
1204 TInt err = KErrNone; |
1056 TInt res = KErrGeneral; |
1205 TInt res = KErrGeneral; |
1057 CWait* wait = CWait::NewL(); |
1206 CWait* wait = CWait::NewL(); |
1058 CleanupStack::PushL(wait); |
1207 CleanupStack::PushL(wait); |
1059 RDEBUG("0", 0); |
1208 |
1060 |
1209 |
1061 StartUp = iStartup; |
1210 StartUp = iStartup; |
1062 |
1211 |
1063 RDEBUG("StartUp", StartUp); |
1212 #if defined(_DEBUG) |
1064 if (!StartUp) |
1213 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL()")); |
1065 { |
1214 #endif |
1066 // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL |
1215 |
|
1216 if(!StartUp) |
|
1217 { |
|
1218 // read a flag to see whether the query is SecUi originated. |
1067 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
1219 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
1068 if (err != KErrNone) |
1220 |
1069 { |
1221 if ( err != KErrNone ) |
1070 RDEBUG("FAILED to get the SECUI query Flag err", err); |
1222 { |
1071 } |
1223 #if defined(_DEBUG) |
1072 } |
1224 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\ |
1073 RDEBUG("err", err); |
1225 FAILED to get the SECUI query Flag: %d"), err); |
1074 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
1226 #endif |
1075 RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated); |
|
1076 if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone)) |
|
1077 { |
|
1078 RDEBUG("0", 0); |
|
1079 lCancelSupported = ESecUiCancelNotSupported; |
|
1080 lEmergencySupported = ESecUiEmergencySupported; |
|
1081 } |
1227 } |
1082 else |
1228 else |
1083 { |
1229 { |
1084 lCancelSupported = ESecUiCancelSupported; |
1230 #if defined(_DEBUG) |
1085 lEmergencySupported = ESecUiEmergencyNotSupported; |
1231 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\ |
1086 // it will be RMobilePhone::ESecurityCodePin1 , equivalent to ESecUiNone |
1232 SECUI query Flag: %d"), secUiOriginatedQuery); |
1087 } |
1233 #endif |
1088 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1234 } |
1089 RDEBUG("GetSecurityCodeInfo", 0); |
1235 } |
1090 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
1236 #if defined(_DEBUG) |
|
1237 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg")); |
|
1238 #endif |
|
1239 |
|
1240 if(StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone)) |
|
1241 { |
|
1242 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiCodeEtelReqest); |
|
1243 if(AknLayoutUtils::PenEnabled()) |
|
1244 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
|
1245 else |
|
1246 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
|
1247 #ifdef __COVER_DISPLAY |
|
1248 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
|
1249 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
|
1250 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1251 { |
|
1252 // … - add data that cover ui is interested in |
|
1253 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui |
|
1254 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1255 } |
|
1256 #endif //__COVER_DISPLAY |
|
1257 |
|
1258 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
|
1259 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
|
1260 res = wait->WaitForRequestL(); |
|
1261 #if defined(_DEBUG) |
|
1262 TInt attempts(codeInfo.iRemainingEntryAttempts); |
|
1263 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts query status: %d"), res); |
|
1264 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts: %d"), attempts); |
|
1265 #endif |
|
1266 User::LeaveIfError(res); |
|
1267 |
|
1268 if( codeInfo.iRemainingEntryAttempts >= KMaxNumberOfPINAttempts ) |
|
1269 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY); |
|
1270 else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt) |
|
1271 { |
|
1272 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts); |
|
1273 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt); |
|
1274 CleanupStack::PopAndDestroy(queryPrompt); |
|
1275 } |
|
1276 else |
|
1277 { |
|
1278 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT); |
|
1279 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt); |
|
1280 CleanupStack::PopAndDestroy(queryPrompt); |
|
1281 } |
|
1282 |
|
1283 iSecurityDlg = NULL; |
|
1284 #if defined(_DEBUG) |
|
1285 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg RESULT: %d"), res); |
|
1286 #endif |
|
1287 if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1288 { |
|
1289 #if defined(_DEBUG) |
|
1290 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!")); |
|
1291 #endif |
|
1292 CleanupStack::PopAndDestroy(wait); |
|
1293 return KErrCancel; |
|
1294 } |
|
1295 } |
|
1296 else |
|
1297 { |
|
1298 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone); |
|
1299 #ifdef __COVER_DISPLAY |
|
1300 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
|
1301 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
|
1302 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1303 { |
|
1304 // … - add data that cover ui is interested in |
|
1305 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui |
|
1306 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1307 } |
|
1308 #endif //__COVER_DISPLAY |
|
1309 |
|
1310 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
|
1311 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
|
1312 res = wait->WaitForRequestL(); |
|
1313 User::LeaveIfError(res); |
|
1314 |
|
1315 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
|
1316 CleanupStack::PushL(deviceLockStatusObserver); |
|
1317 CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver); |
|
1318 CleanupStack::PushL(queryStatusObserver); |
|
1319 |
|
1320 if( codeInfo.iRemainingEntryAttempts >= KMaxNumberOfPINAttempts ) |
|
1321 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY); |
|
1322 else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt) |
|
1323 { |
|
1324 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts ); |
|
1325 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt); |
|
1326 CleanupStack::PopAndDestroy(queryPrompt); |
|
1327 } |
|
1328 else |
|
1329 { |
|
1330 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT); |
|
1331 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt); |
|
1332 CleanupStack::PopAndDestroy(queryPrompt); |
|
1333 } |
|
1334 |
|
1335 CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver |
|
1336 iSecurityDlg = NULL; |
|
1337 if( !res || (res == ESecUiDeviceLocked)) |
|
1338 { |
|
1339 #if defined(_DEBUG) |
|
1340 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_QUERY cancel!")); |
|
1341 #endif |
|
1342 // cancel code request |
|
1343 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
|
1344 CleanupStack::PopAndDestroy(wait); |
|
1345 return KErrCancel; |
|
1346 } |
|
1347 } |
|
1348 #if defined(_DEBUG) |
|
1349 RDebug::Print(_L("CSecurityNotifier::Pin1RequiredL()VerifySecurityCode")); |
|
1350 #endif |
|
1351 iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth); |
1091 res = wait->WaitForRequestL(); |
1352 res = wait->WaitForRequestL(); |
1092 |
1353 CleanupStack::PopAndDestroy(wait); |
1093 RDEBUG("res", res); |
1354 #if defined(_DEBUG) |
1094 #ifdef __WINS__ |
1355 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL() VerifySecurityCode STATUS: %d"), res); |
1095 RDEBUG("emulator can't read PIN attempts", res); |
1356 #endif |
1096 res = KErrNone; |
|
1097 codeInfo.iRemainingEntryAttempts = 3; |
|
1098 #endif |
|
1099 User::LeaveIfError(res); |
|
1100 |
|
1101 RDEBUG("codeInfo.iRemainingEntryAttempts", |
|
1102 codeInfo.iRemainingEntryAttempts); |
|
1103 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) |
|
1104 codeInfo.iRemainingEntryAttempts = -1; |
|
1105 |
|
1106 /* request PIN using QT */ |
|
1107 CSecQueryUi *iSecQueryUi; |
|
1108 RDEBUG("CSecQueryUi", 0); |
|
1109 iSecQueryUi = CSecQueryUi::NewL(); |
|
1110 iQueryCanceled = EFalse; |
|
1111 RDEBUG("SecQueryDialog", 1); |
|
1112 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
|
1113 lAlphaSupported = ESecUiAlphaNotSupported; |
|
1114 TBuf<0x100> title; |
|
1115 title.Zero(); |
|
1116 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin_code")); |
|
1117 title.Append(stringHolder->Des()); |
|
1118 CleanupStack::PopAndDestroy(stringHolder); |
|
1119 title.Append(_L("$")); |
|
1120 title.AppendNum(codeInfo.iRemainingEntryAttempts); |
|
1121 TInt amode = ESecUiSecretSupported | lAlphaSupported | lCancelSupported | lEmergencySupported | secCodeType; |
|
1122 RDEBUG("amode", amode); |
|
1123 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode); |
|
1124 RDEBUG("iSecUi_password", 0); |
|
1125 RDEBUGSTR(iSecUi_password); |
|
1126 iQueryCanceled = ETrue; |
|
1127 delete iSecQueryUi; |
|
1128 RDEBUG("queryAccepted", queryAccepted); |
|
1129 /* end request PIN using QT */ |
|
1130 |
|
1131 if (queryAccepted == KErrAbort) // emergency call |
|
1132 { |
|
1133 RDEBUG("queryAccepted", queryAccepted); |
|
1134 CleanupStack::PopAndDestroy(wait); // this is needed |
|
1135 return KErrCancel; |
|
1136 } |
|
1137 if (lCancelSupported && (queryAccepted == KErrCancel)) |
|
1138 { |
|
1139 // cancel code request |
|
1140 RDEBUG("AbortSecurityCode", 0); |
|
1141 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
|
1142 RDEBUG("AbortSecurityCode", 1); |
|
1143 CleanupStack::PopAndDestroy(wait); // this is needed |
|
1144 return KErrCancel; |
|
1145 } |
|
1146 |
|
1147 RDEBUG("iSecUi_password", 0); |
|
1148 RDEBUGSTR(iSecUi_password); |
|
1149 RDEBUG("VerifySecurityCode", 0); |
|
1150 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); |
|
1151 RDEBUG("WaitForRequestL", 0); |
|
1152 res = wait->WaitForRequestL(); |
|
1153 RDEBUG("WaitForRequestL res", res); |
|
1154 CleanupStack::PopAndDestroy(wait); |
|
1155 |
|
1156 TInt returnValue = res; |
1357 TInt returnValue = res; |
1157 switch (res) |
1358 switch(res) |
1158 { |
1359 { |
1159 case KErrNone: |
1360 case KErrNone: |
1160 // code approved |
1361 // code approved |
1161 RDEBUG("code approved", res) |
1362 #if defined(_DEBUG) |
1162 ; |
1363 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL()code approved ")); |
1163 if (lCancelSupported == ESecUiCancelNotSupported) |
1364 #endif |
1164 { // OK note is not displayed in boot-up, to make things faster |
1365 CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); |
1165 CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); |
|
1166 } |
|
1167 break; |
1366 break; |
1168 case KErrGsm0707IncorrectPassword: |
1367 case KErrGsm0707IncorrectPassword: |
1169 case KErrAccessDenied: |
1368 case KErrAccessDenied: |
1170 // code was entered erroneously |
1369 // code was entered erroneously |
1171 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1370 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1172 if (StartUp) |
1371 if(StartUp) |
1173 { |
1372 { |
1174 returnValue = Pin1RequiredL(); |
1373 returnValue = Pin1RequiredL(); |
1175 } |
1374 } |
1176 break; |
1375 break; |
1177 case KErrGsmSSPasswordAttemptsViolation: |
1376 case KErrGsmSSPasswordAttemptsViolation: |
1178 case KErrLocked: |
1377 case KErrLocked: |
1179 // code blocked; show error note and terminate. |
1378 // code blocked; show error note and terminate. |
1180 // what if not during Startup? Probably it's Ok since the SIM would had also failed at StartUp |
1379 // code blocked |
1181 if (StartUp) |
1380 if(StartUp) |
1182 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1381 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1183 break; |
1382 break; |
1184 case KErrGsm0707SimWrong: |
1383 case KErrGsm0707SimWrong: |
1185 // sim lock active |
1384 // sim lock active |
1186 // no error? This is strange |
|
1187 break; |
1385 break; |
1188 default: |
1386 default: |
1189 { |
1387 CSecuritySettings::ShowErrorNoteL(res); |
1190 CSecuritySettings::ShowErrorNoteL(res); |
1388 if(StartUp) |
1191 if (StartUp) |
1389 { |
1192 { |
1390 returnValue = Pin1RequiredL(); |
1193 returnValue = Pin1RequiredL(); |
|
1194 } |
|
1195 } |
1391 } |
1196 break; |
1392 break; |
1197 } |
1393 } |
1198 return returnValue; |
1394 return returnValue; |
1199 } |
1395 } |
1200 // |
1396 // |
1201 // ---------------------------------------------------------- |
1397 // ---------------------------------------------------------- |
1202 // CSecurityHandler::Puk1Required() |
1398 // CSecurityHandler::Puk1Required() |
1203 // Handles Puk1Required event |
1399 // Handles Puk1Required event |
1204 // First asks the PUK1, then verifies, then the newPIN + re-type , and then writes . This is odd, but the API needs the PUK and newPIN in same step. |
1400 // ---------------------------------------------------------- |
1205 // Afterwards, the PIN1 might be asked (because the initial program still needs it) |
1401 // |
1206 // ---------------------------------------------------------- |
|
1207 // qtdone |
|
1208 TInt CSecurityHandler::Puk1RequiredL() |
1402 TInt CSecurityHandler::Puk1RequiredL() |
1209 { |
1403 { |
1210 /***************************************************** |
1404 /***************************************************** |
1211 * Series 60 Customer / ETel |
1405 * Series 60 Customer / ETel |
1212 * Series 60 ETel API |
1406 * Series 60 ETel API |
1213 *****************************************************/ |
1407 *****************************************************/ |
1214 RDEBUG("0", 0); |
1408 #if defined(_DEBUG) |
1215 TInt queryAccepted = KErrCancel; |
1409 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL()")); |
1216 RMobilePhone::TMobilePassword puk1_password; |
1410 #endif |
1217 RMobilePhone::TMobilePassword aNewPinPassword; |
1411 RMobilePhone::TMobilePassword aPassword; |
|
1412 RMobilePhone::TMobilePassword aNewPassword; |
1218 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1413 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1219 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1414 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1220 RMobilePhone::TMobilePhoneSecurityCode blockCodeType; |
1415 RMobilePhone::TMobilePhoneSecurityCode blockCodeType; |
1221 blockCodeType = RMobilePhone::ESecurityCodePuk1; |
1416 blockCodeType = RMobilePhone::ESecurityCodePuk1; |
1222 CWait* wait = CWait::NewL(); |
1417 CWait* wait = CWait::NewL(); |
1223 CleanupStack::PushL(wait); |
1418 CleanupStack::PushL(wait); |
1224 |
1419 |
1225 TBool StartUp(ETrue); |
1420 TBool StartUp(ETrue); |
1226 StartUp = iStartup; |
1421 StartUp = iStartup; |
1227 |
1422 |
1228 TInt res(KErrCancel); // for the first try |
1423 TInt res(KErrNone); |
1229 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1424 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1230 |
1425 #if defined(_DEBUG) |
|
1426 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Get Code info")); |
|
1427 #endif |
|
1428 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
|
1429 res = wait->WaitForRequestL(); |
|
1430 |
1231 TInt thisTry = 0; |
1431 TInt thisTry = 0; |
1232 |
1432 |
1233 // If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times. |
1433 // If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times. |
1234 while (res != KErrNone && (thisTry++) <= KTriesToConnectServer) |
1434 while ( res != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
1235 { |
1435 { |
1236 if (thisTry > 0) |
1436 User::After( KTimeBeforeRetryingRequest ); |
1237 User::After(KTimeBeforeRetryingRequest); |
|
1238 RDEBUG("GetSecurityCodeInfo", 0); |
|
1239 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
1437 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
1240 RDEBUG("WaitForRequestL", 0); |
|
1241 res = wait->WaitForRequestL(); |
1438 res = wait->WaitForRequestL(); |
1242 RDEBUG("WaitForRequestL res", res); |
1439 } |
1243 } |
1440 #if defined(_DEBUG) |
1244 RDEBUG("res", res); |
1441 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Get Code info result: %d"), res); |
1245 // If there's still an error we're doomed. Bail out. |
1442 #endif |
|
1443 //If there's still an error we're doomed. Bail out. |
1246 User::LeaveIfError(res); |
1444 User::LeaveIfError(res); |
1247 |
1445 |
1248 RDEBUG("StartUp", StartUp); |
1446 #if defined(_DEBUG) |
1249 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1447 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Show last note")); |
1250 codeInfo.iRemainingEntryAttempts); |
1448 #endif |
1251 TInt attempts(codeInfo.iRemainingEntryAttempts); |
1449 //show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog |
1252 RDEBUG("attempts", attempts); |
1450 if(!StartUp && (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts)) |
1253 // show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog |
|
1254 if (!StartUp && (attempts == KMaxNumberOfPUKAttempts)) |
|
1255 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1451 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1256 |
1452 |
1257 if (attempts == KMaxNumberOfPINAttempts) |
1453 // ask PUK code |
1258 attempts = -1; |
1454 iSecurityDlg = new (ELeave) CCodeQueryDialog (aPassword,SEC_C_PUK_CODE_MIN_LENGTH,SEC_C_PUK_CODE_MAX_LENGTH,ESecUiPukRequired); |
1259 |
1455 if(AknLayoutUtils::PenEnabled()) |
1260 CSecQueryUi *iSecQueryUi; |
1456 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
1261 RDEBUG("CSecQueryUi", 0); |
1457 else |
1262 iSecQueryUi = CSecQueryUi::NewL(); |
1458 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
1263 iQueryCanceled = EFalse; |
1459 #ifdef __COVER_DISPLAY |
1264 RDEBUG("SecQueryDialog", 1); |
1460 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
1265 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
1461 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
1266 TBuf<0x100> title; |
1462 if (covercl) // returns null if __COVER_DISPLAY is not defined |
1267 title.Zero(); |
1463 { |
1268 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_puk_code")); |
1464 // … - add data that cover ui is interested in |
1269 title.Append(stringHolder->Des()); |
1465 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPUK1); // adds int to additional data to be posted to cover ui |
1270 CleanupStack::PopAndDestroy(stringHolder); |
1466 covercl->BufStream().CommitL(); // no more data to send so commit buf |
1271 title.Append(_L("$")); |
1467 } |
1272 title.AppendNum(attempts); |
1468 #endif //__COVER_DISPLAY |
1273 TInt lSecUiCancelSupported = ESecUiCancelSupported | ESecUiEmergencyNotSupported; |
1469 |
1274 if (StartUp) // how to know whether PUK comes from failing at Starter, or failing at any other PIN (i.e. changing PIN, or changing PIN-request) ??? |
1470 #if defined(_DEBUG) |
1275 lSecUiCancelSupported = ESecUiCancelNotSupported | ESecUiEmergencySupported; |
1471 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Show dialog")); |
1276 queryAccepted = iSecQueryUi->SecQueryDialog(title, puk1_password, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported |
1472 #endif |
1277 | lSecUiCancelSupported | ESecUiPukRequired); |
1473 if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts) |
1278 RDEBUG("puk1_password", 0); |
1474 res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY); |
1279 RDEBUGSTR(puk1_password); |
1475 else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt) |
1280 iQueryCanceled = ETrue; |
1476 { |
1281 delete iSecQueryUi; |
1477 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PUK_ATTEMPTS, codeInfo.iRemainingEntryAttempts); |
1282 RDEBUG("queryAccepted", queryAccepted); |
1478 res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY, *queryPrompt); |
1283 |
1479 CleanupStack::PopAndDestroy(queryPrompt); |
1284 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
1480 } |
1285 { |
1481 else |
1286 CleanupStack::PopAndDestroy(wait); // this is needed |
1482 { |
|
1483 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PUK_ATTEMPT); |
|
1484 res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY, *queryPrompt); |
|
1485 CleanupStack::PopAndDestroy(queryPrompt); |
|
1486 } |
|
1487 |
|
1488 if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1489 { |
|
1490 CleanupStack::PopAndDestroy(wait); |
1287 return KErrCancel; |
1491 return KErrCancel; |
1288 } |
1492 } |
1289 |
1493 |
|
1494 RMobilePhone::TMobilePassword verifcationPassword; |
|
1495 // new pin code query |
|
1496 iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired); |
|
1497 if(AknLayoutUtils::PenEnabled()) |
|
1498 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
|
1499 else |
|
1500 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
|
1501 res = iSecurityDlg->ExecuteLD(R_NEW_PIN_CODE_REQUEST_QUERY); |
|
1502 if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1503 { |
|
1504 CleanupStack::PopAndDestroy(wait); |
|
1505 return KErrCancel; |
|
1506 } |
|
1507 |
|
1508 // verification code query |
|
1509 iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired); |
|
1510 if(AknLayoutUtils::PenEnabled()) |
|
1511 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
|
1512 else |
|
1513 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
|
1514 res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_REQUEST_QUERY); |
|
1515 if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1516 { |
|
1517 CleanupStack::PopAndDestroy(wait); |
|
1518 return KErrCancel; |
|
1519 } |
|
1520 |
|
1521 while (aNewPassword.CompareF(verifcationPassword) != 0) |
|
1522 { |
|
1523 // codes do not match -> note -> ask new pin and verification codes again |
|
1524 CSecuritySettings::ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone); |
|
1525 |
|
1526 verifcationPassword = _L(""); |
|
1527 aNewPassword = _L(""); |
|
1528 |
|
1529 // new pin code query |
|
1530 iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired); |
|
1531 if(AknLayoutUtils::PenEnabled()) |
|
1532 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
|
1533 else |
|
1534 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
|
1535 res = iSecurityDlg->ExecuteLD(R_NEW_PIN_CODE_REQUEST_QUERY); |
|
1536 if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1537 { |
|
1538 CleanupStack::PopAndDestroy(wait); |
|
1539 return KErrCancel; |
|
1540 } |
|
1541 |
|
1542 // verification code query |
|
1543 iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired); |
|
1544 if(AknLayoutUtils::PenEnabled()) |
|
1545 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue ); |
|
1546 else |
|
1547 iSecurityDlg->SetEmergencyCallSupport(ETrue); |
|
1548 res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_REQUEST_QUERY); |
|
1549 if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall)) |
|
1550 { |
|
1551 CleanupStack::PopAndDestroy(wait); |
|
1552 return KErrCancel; |
|
1553 } |
|
1554 } |
|
1555 |
1290 // send code |
1556 // send code |
1291 // first we verify the puk. For this, we reset the PIN to the same as the PUK |
1557 #if defined(_DEBUG) |
1292 // Hopefully this will never fail in the case "new PIN too long" |
1558 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Verify Code")); |
1293 RDEBUG("VerifySecurityCode", 0); |
1559 #endif |
1294 iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, puk1_password, puk1_password); |
1560 iPhone.VerifySecurityCode(wait->iStatus,blockCodeType,aNewPassword,aPassword); |
1295 RDEBUG("WaitForRequestL", 0); |
|
1296 res = wait->WaitForRequestL(); |
1561 res = wait->WaitForRequestL(); |
1297 RDEBUG("WaitForRequestL res", res); |
|
1298 CleanupStack::PopAndDestroy(wait); |
1562 CleanupStack::PopAndDestroy(wait); |
1299 |
1563 |
1300 TInt returnValue = res; |
1564 TInt returnValue = res; |
1301 switch (res) |
1565 switch(res) |
1302 { |
1566 { |
1303 case KErrNone: |
1567 case KErrNone: |
1304 // code approved -> note . The process continue and new-pin is requested |
1568 // code approved -> note |
1305 CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone); |
1569 CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
1306 break; |
1570 break; |
1307 case KErrGsm0707IncorrectPassword: |
1571 case KErrGsm0707IncorrectPassword: |
1308 case KErrAccessDenied: |
1572 case KErrAccessDenied: |
1309 // wrong PUK code -> note -> ask PUK code again |
1573 // wrong PUK code -> note -> ask PUK code again |
1310 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1574 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1311 returnValue = Puk1RequiredL(); |
1575 returnValue = Puk1RequiredL(); |
1312 break; |
1576 break; |
1313 case KErrGsm0707SimWrong: |
1577 case KErrGsm0707SimWrong: |
1314 // sim lock active |
1578 // sim lock active |
1315 // no message ? |
|
1316 break; |
1579 break; |
1317 case KErrGsmSSPasswordAttemptsViolation: |
1580 case KErrGsmSSPasswordAttemptsViolation: |
1318 case KErrLocked: |
1581 case KErrLocked: |
1319 // sim card rejected. |
1582 // sim card rejected. |
1320 break; |
1583 break; |
1321 default: |
1584 default: |
1322 CSecuritySettings::ShowErrorNoteL(res); |
1585 CSecuritySettings::ShowErrorNoteL(res); |
1323 returnValue = Puk1RequiredL(); |
1586 returnValue = Puk1RequiredL(); |
1324 break; |
1587 break; |
1325 } |
1588 } |
1326 |
1589 |
1327 // Now the PUK1 is validated. It's time for asking the new PIN1 |
1590 return returnValue; |
1328 RDEBUG("new wait", 0); |
|
1329 wait = CWait::NewL(); |
|
1330 CleanupStack::PushL(wait); |
|
1331 { |
|
1332 // new-pin query |
|
1333 CSecQueryUi * iSecQueryUi; |
|
1334 RDEBUG("CSecQueryUi", 0); |
|
1335 iSecQueryUi = CSecQueryUi::NewL(); |
|
1336 iQueryCanceled = EFalse; |
|
1337 RDEBUG("SecQueryDialog", 1); |
|
1338 TBuf<0x100> title; |
|
1339 title.Zero(); |
|
1340 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_pin_code")); |
|
1341 title.Append(stringHolder->Des()); |
|
1342 CleanupStack::PopAndDestroy(stringHolder); |
|
1343 title.Append(_L("|")); |
|
1344 HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_verify_new_pin_code")); |
|
1345 title.Append(stringHolder2->Des()); |
|
1346 CleanupStack::PopAndDestroy(stringHolder2); |
|
1347 queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPinPassword, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported |
|
1348 | ESecUiPukRequired); |
|
1349 RDEBUG("aNewPinPassword", 0); |
|
1350 RDEBUGSTR(aNewPinPassword); |
|
1351 iQueryCanceled = ETrue; |
|
1352 delete iSecQueryUi; |
|
1353 RDEBUG("queryAccepted", queryAccepted); |
|
1354 } |
|
1355 |
|
1356 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
|
1357 { |
|
1358 CleanupStack::PopAndDestroy(wait); |
|
1359 return KErrCancel; |
|
1360 } |
|
1361 |
|
1362 // send code again, now with the user pin |
|
1363 RDEBUG("VerifySecurityCode", 0); |
|
1364 iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPinPassword, puk1_password); |
|
1365 RDEBUG("WaitForRequestL", 0); |
|
1366 res = wait->WaitForRequestL(); |
|
1367 RDEBUG("WaitForRequestL res", res); |
|
1368 CleanupStack::PopAndDestroy(wait); |
|
1369 |
|
1370 returnValue = res; |
|
1371 switch (res) |
|
1372 { |
|
1373 case KErrNone: |
|
1374 // code approved -> note |
|
1375 CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
|
1376 break; |
|
1377 case KErrGsm0707IncorrectPassword: |
|
1378 case KErrAccessDenied: |
|
1379 // wrong PUK code -> note -> ask PUK code again |
|
1380 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
|
1381 returnValue = Puk1RequiredL(); |
|
1382 break; |
|
1383 case KErrGsm0707SimWrong: |
|
1384 // sim lock active |
|
1385 // no message ? |
|
1386 break; |
|
1387 case KErrGsmSSPasswordAttemptsViolation: |
|
1388 case KErrLocked: |
|
1389 // sim card rejected. |
|
1390 break; |
|
1391 default: |
|
1392 CSecuritySettings::ShowErrorNoteL(res); |
|
1393 returnValue = Puk1RequiredL(); |
|
1394 break; |
|
1395 } |
|
1396 RDEBUG("returnValue", returnValue); |
|
1397 return returnValue; |
|
1398 } |
1591 } |
1399 // |
1592 // |
1400 // ---------------------------------------------------------- |
1593 // ---------------------------------------------------------- |
1401 // CSecurityHandler::Pin2Required() |
1594 // CSecurityHandler::Pin2Required() |
1402 // Handles Pin2Required event |
1595 // Handles Pin2Required event |
1403 // ---------------------------------------------------------- |
1596 // ---------------------------------------------------------- |
1404 // qtdone |
1597 // |
1405 void CSecurityHandler::Pin2RequiredL() |
1598 void CSecurityHandler::Pin2RequiredL() |
1406 { |
1599 { |
1407 /***************************************************** |
1600 /***************************************************** |
1408 * Series 60 Customer / ETel |
1601 * Series 60 Customer / ETel |
1409 * Series 60 ETel API |
1602 * Series 60 ETel API |
1410 *****************************************************/ |
1603 *****************************************************/ |
1411 |
1604 #if defined(_DEBUG) |
1412 RDEBUG("0", 0); |
1605 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL() BEGIN")); |
1413 TInt queryAccepted = KErrCancel; |
1606 #endif |
1414 RMobilePhone::TMobilePassword iSecUi_password; |
1607 RMobilePhone::TMobilePassword password; |
1415 RMobilePhone::TMobilePassword required_fourth; |
1608 RMobilePhone::TMobilePassword required_fourth; |
1416 RMobilePhone::TMobilePhoneSecurityCode secCodeType(RMobilePhone::ESecurityCodePin2); |
1609 RMobilePhone::TMobilePhoneSecurityCode secCodeType(RMobilePhone::ESecurityCodePin2); |
1417 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1610 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1418 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1611 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1419 CWait* wait = CWait::NewL(); |
1612 CWait* wait = CWait::NewL(); |
1420 CleanupStack::PushL(wait); |
1613 CleanupStack::PushL(wait); |
1421 |
1614 |
1422 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1615 #if defined(_DEBUG) |
1423 RDEBUG("GetSecurityCodeInfo", 0); |
1616 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): create dialog")); |
|
1617 #endif |
|
1618 iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone); |
|
1619 #ifdef __COVER_DISPLAY |
|
1620 #if defined(_DEBUG) |
|
1621 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): publish dialog")); |
|
1622 #endif |
|
1623 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
|
1624 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
|
1625 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1626 { |
|
1627 // … - add data that cover ui is interested in |
|
1628 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN2); // adds int to additional data to be posted to cover ui |
|
1629 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1630 } |
|
1631 #endif //__COVER_DISPLAY |
|
1632 |
|
1633 #if defined(_DEBUG) |
|
1634 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): get PIN2 info")); |
|
1635 #endif |
|
1636 |
|
1637 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1424 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
1638 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
1425 RDEBUG("WaitForRequestL", 0); |
|
1426 TInt ret = wait->WaitForRequestL(); |
1639 TInt ret = wait->WaitForRequestL(); |
1427 RDEBUG("WaitForRequestL ret", ret); |
1640 |
|
1641 #if defined(_DEBUG) |
|
1642 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): get PIN2 info result: %d"), ret); |
|
1643 TInt attempts(codeInfo.iRemainingEntryAttempts); |
|
1644 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): attempts remaining: %d"), attempts); |
|
1645 #endif |
1428 User::LeaveIfError(ret); |
1646 User::LeaveIfError(ret); |
1429 |
1647 |
1430 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1648 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
1431 codeInfo.iRemainingEntryAttempts); |
1649 CleanupStack::PushL(deviceLockStatusObserver); |
1432 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) |
1650 CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver); |
1433 codeInfo.iRemainingEntryAttempts = -1; |
1651 CleanupStack::PushL(queryStatusObserver); |
1434 |
1652 |
1435 /* request PIN using QT */ |
1653 if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) |
1436 CSecQueryUi *iSecQueryUi; |
1654 ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY); |
1437 RDEBUG("CSecQueryUi", 0); |
1655 else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt) |
1438 iSecQueryUi = CSecQueryUi::NewL(); |
1656 { |
1439 iQueryCanceled = EFalse; |
1657 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN2_ATTEMPTS, codeInfo.iRemainingEntryAttempts ); |
1440 RDEBUG("SecQueryDialog", 1); |
1658 ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt); |
1441 // ESecUiCodeEtelReqest/ESecUiNone might be useful against KLastRemainingInputAttempt |
1659 CleanupStack::PopAndDestroy(queryPrompt); |
1442 |
1660 } |
1443 TBuf<0x100> title; |
1661 else |
1444 title.Zero(); |
1662 { |
1445 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin2_code")); |
1663 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN2_ATTEMPT); |
1446 title.Append(stringHolder->Des()); |
1664 ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt); |
1447 CleanupStack::PopAndDestroy(stringHolder); |
1665 CleanupStack::PopAndDestroy(queryPrompt); |
1448 title.Append(_L("$")); |
1666 } |
1449 title.AppendNum(codeInfo.iRemainingEntryAttempts); |
1667 CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver |
1450 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported |
1668 iSecurityDlg = NULL; |
1451 | ESecUiCancelSupported | secCodeType); |
1669 if (!ret || (ret == ESecUiDeviceLocked)) |
1452 RDEBUG("iSecUi_password", 0); |
1670 { |
1453 RDEBUGSTR(iSecUi_password); |
1671 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); |
1454 RDEBUG("queryAccepted", queryAccepted); |
|
1455 iQueryCanceled = ETrue; |
|
1456 delete iSecQueryUi; |
|
1457 |
|
1458 // If failed or device became locked, any pending request should be cancelled. |
|
1459 if (queryAccepted != KErrNone) |
|
1460 { |
|
1461 RDEBUG("AbortSecurityCode", 0); |
|
1462 iPhone.AbortSecurityCode(secCodeType); |
|
1463 RDEBUG("AbortSecurityCode", 1); |
|
1464 CleanupStack::PopAndDestroy(wait); |
1672 CleanupStack::PopAndDestroy(wait); |
1465 return; |
1673 return; |
1466 } |
1674 } |
1467 |
1675 |
1468 RDEBUG("VerifySecurityCode", 0); |
1676 #if defined(_DEBUG) |
1469 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); |
1677 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): Verify Code")); |
1470 RDEBUG("WaitForRequestL", 0); |
1678 #endif |
|
1679 iPhone.VerifySecurityCode(wait->iStatus,secCodeType,password,required_fourth); |
1471 TInt status = wait->WaitForRequestL(); |
1680 TInt status = wait->WaitForRequestL(); |
1472 RDEBUG("WaitForRequestL status", status); |
1681 #if defined(_DEBUG) |
|
1682 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): destroy wait")); |
|
1683 #endif |
1473 CleanupStack::PopAndDestroy(wait); |
1684 CleanupStack::PopAndDestroy(wait); |
1474 |
1685 |
1475 switch (status) |
1686 switch(status) |
1476 { |
1687 { |
1477 case KErrNone: |
1688 case KErrNone: |
1478 break; |
1689 break; |
1479 case KErrGsm0707IncorrectPassword: |
1690 case KErrGsm0707IncorrectPassword: |
1480 case KErrAccessDenied: |
1691 case KErrAccessDenied: |
1481 // code was entered erroneously |
1692 // code was entered erroneously |
1482 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1693 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1483 break; |
1694 break; |
1484 case KErrGsmSSPasswordAttemptsViolation: |
1695 case KErrGsmSSPasswordAttemptsViolation: |
1485 case KErrLocked: |
1696 case KErrLocked: |
1486 // blocked |
1697 // blocked |
1487 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1698 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
1488 break; |
1699 break; |
1489 default: |
1700 default: |
1490 CSecuritySettings::ShowErrorNoteL(status); |
1701 CSecuritySettings::ShowErrorNoteL(status); |
1491 break; |
1702 break; |
1492 } |
1703 } |
|
1704 #if defined(_DEBUG) |
|
1705 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): END")); |
|
1706 #endif |
1493 } |
1707 } |
1494 // |
1708 // |
1495 // ---------------------------------------------------------- |
1709 // ---------------------------------------------------------- |
1496 // CSecurityHandler::Puk2Required() |
1710 // CSecurityHandler::Puk2Required() |
1497 // Handles Puk2Required event |
1711 // Handles Puk2Required event |
1498 // ---------------------------------------------------------- |
1712 // ---------------------------------------------------------- |
1499 // qtdone |
1713 // |
1500 void CSecurityHandler::Puk2RequiredL() |
1714 void CSecurityHandler::Puk2RequiredL() |
1501 { |
1715 { |
1502 /***************************************************** |
1716 /***************************************************** |
1503 * Series 60 Customer / ETel |
1717 * Series 60 Customer / ETel |
1504 * Series 60 ETel API |
1718 * Series 60 ETel API |
1505 *****************************************************/ |
1719 *****************************************************/ |
1506 RDEBUG("0", 0); |
1720 RMobilePhone::TMobilePassword aPassword; |
1507 TInt queryAccepted = KErrCancel; |
|
1508 RMobilePhone::TMobilePassword iSecUi_password; |
|
1509 RMobilePhone::TMobilePassword aNewPassword; |
1721 RMobilePhone::TMobilePassword aNewPassword; |
1510 RMobilePhone::TMobilePassword verifcationPassword; |
1722 RMobilePhone::TMobilePassword verifcationPassword; |
1511 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1723 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1512 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1724 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1513 |
1725 |
1514 RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePuk2; |
1726 RMobilePhone::TMobilePhoneSecurityCode blockCodeType; |
|
1727 blockCodeType = RMobilePhone::ESecurityCodePuk2; |
1515 CWait* wait = CWait::NewL(); |
1728 CWait* wait = CWait::NewL(); |
1516 CleanupStack::PushL(wait); |
1729 CleanupStack::PushL(wait); |
1517 |
1730 |
|
1731 #if defined(_DEBUG) |
|
1732 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL()")); |
|
1733 #endif |
1518 // ask PUK2 |
1734 // ask PUK2 |
1519 |
1735 iSecurityDlg = new (ELeave) CCodeQueryDialog (aPassword,SEC_C_PUK2_CODE_MIN_LENGTH,SEC_C_PUK2_CODE_MAX_LENGTH,ESecUiNone); |
1520 TInt ret(KErrNone); |
1736 #ifdef __COVER_DISPLAY |
|
1737 iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup); |
|
1738 CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided |
|
1739 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1740 { |
|
1741 // … - add data that cover ui is interested in |
|
1742 covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPUK2); // adds int to additional data to be posted to cover ui |
|
1743 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1744 } |
|
1745 #endif //__COVER_DISPLAY |
|
1746 CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg); |
|
1747 CleanupStack::PushL(deviceLockStatusObserver); |
|
1748 |
|
1749 TInt ret(KErrNone); |
1521 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1750 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1522 RDEBUG("GetSecurityCodeInfo", 0); |
1751 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
1523 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
|
1524 RDEBUG("WaitForRequestL", 0); |
|
1525 ret = wait->WaitForRequestL(); |
1752 ret = wait->WaitForRequestL(); |
1526 RDEBUG("WaitForRequestL ret", ret); |
|
1527 User::LeaveIfError(ret); |
1753 User::LeaveIfError(ret); |
1528 |
1754 |
1529 /* request PIN using QT */ |
1755 if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts) |
1530 CSecQueryUi *iSecQueryUi; |
1756 ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY); |
1531 RDEBUG("CSecQueryUi", 0); |
1757 else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt) |
1532 iSecQueryUi = CSecQueryUi::NewL(); |
1758 { |
1533 iQueryCanceled = EFalse; |
1759 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PUK2_ATTEMPTS, codeInfo.iRemainingEntryAttempts); |
1534 RDEBUG("SecQueryDialog", 1); |
1760 ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY, *queryPrompt); |
1535 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
1761 CleanupStack::PopAndDestroy(queryPrompt); |
1536 |
1762 } |
1537 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1763 else |
1538 codeInfo.iRemainingEntryAttempts); |
1764 { |
1539 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) // TODO this might be 10 ? |
1765 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PUK2_ATTEMPT); |
1540 codeInfo.iRemainingEntryAttempts = -1; |
1766 ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY, *queryPrompt); |
1541 |
1767 CleanupStack::PopAndDestroy(queryPrompt); |
1542 TBuf<0x100> title; |
1768 } |
1543 title.Zero(); |
1769 |
1544 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_puk2_code")); |
1770 iSecurityDlg = NULL; |
1545 title.Append(stringHolder->Des()); |
1771 if(!ret || (ret == ESecUiDeviceLocked)) |
1546 CleanupStack::PopAndDestroy(stringHolder); |
1772 { |
1547 title.Append(_L("$")); |
1773 #if defined(_DEBUG) |
1548 title.AppendNum(codeInfo.iRemainingEntryAttempts); |
1774 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() PUK QUERY CANCEL")); |
1549 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PUK2_CODE_MIN_LENGTH, SEC_C_PUK2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported |
1775 #endif |
1550 | ESecUiCancelSupported | secCodeType); |
|
1551 RDEBUG("iSecUi_password", 0); |
|
1552 RDEBUGSTR(iSecUi_password); |
|
1553 iQueryCanceled = ETrue; |
|
1554 delete iSecQueryUi; |
|
1555 RDEBUG("queryAccepted", queryAccepted); |
|
1556 |
|
1557 if (queryAccepted != KErrNone) |
|
1558 { |
|
1559 // cancel "get security unblock code" request |
1776 // cancel "get security unblock code" request |
1560 RDEBUG("AbortSecurityCode", 0); |
1777 iPhone.AbortSecurityCode(blockCodeType); |
1561 iPhone.AbortSecurityCode(secCodeType); |
1778 CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver |
1562 RDEBUG("AbortSecurityCode", 1); |
|
1563 CleanupStack::PopAndDestroy(1); //wait |
|
1564 return; |
1779 return; |
1565 } |
1780 } |
1566 |
1781 #if defined(_DEBUG) |
1567 RDEBUG("VerifySecurityCode", 0); |
1782 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() NEW QUERY")); |
1568 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, iSecUi_password); |
1783 #endif |
1569 // this writes the newPIN2 with the value of PUK2. It's ok, since the user forgot it |
1784 // new pin2 code query |
1570 RDEBUG("WaitForRequestL", 0); |
1785 iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone); |
|
1786 deviceLockStatusObserver->SetAddress(iSecurityDlg); |
|
1787 ret = iSecurityDlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY); |
|
1788 if(!ret || (ret == ESecUiDeviceLocked)) |
|
1789 { |
|
1790 #if defined(_DEBUG) |
|
1791 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() NEW QUERY CANCEL")); |
|
1792 #endif |
|
1793 // cancel "get security unblock code" request |
|
1794 iPhone.AbortSecurityCode(blockCodeType); |
|
1795 CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver |
|
1796 return; |
|
1797 } |
|
1798 |
|
1799 // verification code query |
|
1800 iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone); |
|
1801 deviceLockStatusObserver->SetAddress(iSecurityDlg); |
|
1802 ret = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY); |
|
1803 if (!ret || (ret == ESecUiDeviceLocked)) |
|
1804 { |
|
1805 #if defined(_DEBUG) |
|
1806 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() VERIFY QUERY CANCEL")); |
|
1807 #endif |
|
1808 // cancel "get security unblock code" request |
|
1809 iPhone.AbortSecurityCode(blockCodeType); |
|
1810 CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver |
|
1811 return; |
|
1812 } |
|
1813 |
|
1814 while (aNewPassword.CompareF(verifcationPassword) != 0) |
|
1815 { |
|
1816 // codes do not match -> note -> ask new pin and verification codes again |
|
1817 CSecuritySettings::ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone); |
|
1818 |
|
1819 verifcationPassword = _L(""); |
|
1820 aNewPassword = _L(""); |
|
1821 |
|
1822 // new pin2 code query |
|
1823 iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone); |
|
1824 deviceLockStatusObserver->SetAddress(iSecurityDlg); |
|
1825 deviceLockStatusObserver->StartObserver(); |
|
1826 |
|
1827 ret = iSecurityDlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY); |
|
1828 |
|
1829 if(!ret || (ret == ESecUiDeviceLocked)) |
|
1830 { |
|
1831 // cancel "get security unblock code" request |
|
1832 iPhone.AbortSecurityCode(blockCodeType); |
|
1833 CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver |
|
1834 return; |
|
1835 } |
|
1836 |
|
1837 // verification code query |
|
1838 iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone); |
|
1839 deviceLockStatusObserver->SetAddress(iSecurityDlg); |
|
1840 deviceLockStatusObserver->StartObserver(); |
|
1841 ret = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY); |
|
1842 |
|
1843 if (!ret || (ret == ESecUiDeviceLocked)) |
|
1844 { |
|
1845 // cancel "get security unblock code" request |
|
1846 iPhone.AbortSecurityCode(blockCodeType); |
|
1847 CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver |
|
1848 return; |
|
1849 } |
|
1850 } |
|
1851 CleanupStack::PopAndDestroy(deviceLockStatusObserver); |
|
1852 // send code |
|
1853 |
|
1854 iPhone.VerifySecurityCode(wait->iStatus,blockCodeType,aNewPassword,aPassword); |
1571 TInt res = wait->WaitForRequestL(); |
1855 TInt res = wait->WaitForRequestL(); |
1572 RDEBUG("WaitForRequestL res", res); |
|
1573 CleanupStack::PopAndDestroy(wait); |
1856 CleanupStack::PopAndDestroy(wait); |
1574 |
1857 |
1575 switch (res) |
1858 switch(res) |
1576 { |
|
1577 case KErrNone: |
|
1578 // code approved -> note |
|
1579 CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone); |
|
1580 break; |
|
1581 case KErrGsm0707IncorrectPassword: |
|
1582 case KErrAccessDenied: |
|
1583 // wrong PUK2 code -> note -> ask PUK2 code again |
|
1584 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
|
1585 Puk2RequiredL(); |
|
1586 break; |
|
1587 case KErrGsmSSPasswordAttemptsViolation: |
|
1588 case KErrLocked: |
|
1589 // Pin2 features blocked permanently! |
|
1590 CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone); |
|
1591 break; |
|
1592 default: |
|
1593 CSecuritySettings::ShowErrorNoteL(res); |
|
1594 Puk2RequiredL(); |
|
1595 break; |
|
1596 } |
|
1597 |
|
1598 // now the PUK2 is valid. Time to get the new PIN2 |
|
1599 wait = CWait::NewL(); |
|
1600 CleanupStack::PushL(wait); |
|
1601 { |
|
1602 // new pin2 code query |
|
1603 CSecQueryUi * iSecQueryUi; |
|
1604 RDEBUG("CSecQueryUi", 0); |
|
1605 iSecQueryUi = CSecQueryUi::NewL(); |
|
1606 iQueryCanceled = EFalse; |
|
1607 TBuf<0x100> title; |
|
1608 title.Zero(); |
|
1609 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_pin2_code")); |
|
1610 title.Append(stringHolder->Des()); |
|
1611 CleanupStack::PopAndDestroy(stringHolder); |
|
1612 title.Append(_L("|")); |
|
1613 HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("Verify")); |
|
1614 title.Append(stringHolder2->Des()); |
|
1615 CleanupStack::PopAndDestroy(stringHolder2); |
|
1616 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
|
1617 queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPassword, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported |
|
1618 | secCodeType); |
|
1619 RDEBUG("aNewPassword", 0); |
|
1620 RDEBUGSTR(aNewPassword); |
|
1621 iQueryCanceled = ETrue; |
|
1622 delete iSecQueryUi; |
|
1623 RDEBUG("queryAccepted", queryAccepted); |
|
1624 if (queryAccepted != KErrNone) |
|
1625 { |
|
1626 // cancel "get security unblock code" request |
|
1627 RDEBUG("AbortSecurityCode", 0); |
|
1628 iPhone.AbortSecurityCode(secCodeType); |
|
1629 RDEBUG("AbortSecurityCode", 1); |
|
1630 CleanupStack::PopAndDestroy(1); //wait |
|
1631 return; |
|
1632 } |
|
1633 } |
|
1634 // send code. The code was temporarilly changed before. Thus, this really done to set the new-new one |
|
1635 RDEBUG("VerifySecurityCode", 0); |
|
1636 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, aNewPassword, iSecUi_password); |
|
1637 RDEBUG("WaitForRequestL", 0); |
|
1638 res = wait->WaitForRequestL(); |
|
1639 RDEBUG("WaitForRequestL res", res); |
|
1640 CleanupStack::PopAndDestroy(wait); |
|
1641 |
|
1642 switch (res) |
|
1643 { |
1859 { |
1644 case KErrNone: |
1860 case KErrNone: |
1645 // code approved -> note |
1861 // code approved -> note |
1646 CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
1862 CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
1647 break; |
1863 break; |