32 #include <featmgr.h> |
32 #include <featmgr.h> |
33 #include <SCPClient.h> |
33 #include <SCPClient.h> |
34 #include <apgcli.h> |
34 #include <apgcli.h> |
35 |
35 |
36 // LOCAL CONSTANTS AND MACROS |
36 // LOCAL CONSTANTS AND MACROS |
37 /***************************************************** |
37 /***************************************************** |
38 * Series 60 Customer / TSY |
38 * Series 60 Customer / TSY |
39 * Needs customer TSY implementation |
39 * Needs customer TSY implementation |
40 *****************************************************/ |
40 *****************************************************/ |
41 |
41 |
42 const TInt KTriesToConnectServer( 2 ); |
42 const TInt KTriesToConnectServer( 2 ); |
43 const TInt KTimeBeforeRetryingServerConnection( 50000 ); |
43 const TInt KTimeBeforeRetryingServerConnection( 50000 ); |
44 const TInt PhoneIndex( 0 ); |
44 const TInt PhoneIndex( 0 ); |
45 const TInt KDelayPeriod(200000); |
45 const TInt KDelayPeriod(200000); |
223 // Initialize parameters and jump to RunL |
223 // Initialize parameters and jump to RunL |
224 // ---------------------------------------------------------- |
224 // ---------------------------------------------------------- |
225 // |
225 // |
226 void CSecurityNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReturnVal, const RMessagePtr2& aMessage) |
226 void CSecurityNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReturnVal, const RMessagePtr2& aMessage) |
227 { |
227 { |
228 /***************************************************** |
228 #if defined(_DEBUG) |
229 * Series 60 Customer / ETel |
229 RDebug::Printf( "%s %s (%u) searching for autolock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 ); |
230 * Series 60 ETel API |
230 #endif |
231 *****************************************************/ |
231 |
|
232 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
233 const TUid KAutolockUid = { 0x100059B5 }; |
|
234 TApaTask task( taskList.FindApp( KAutolockUid ) ); |
|
235 if ( !task.Exists() ) |
|
236 { |
|
237 #if defined(_DEBUG) |
|
238 RDebug::Printf( "%s %s (%u) autolock.exe not running. Starting now=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 ); |
|
239 #endif |
|
240 RApaLsSession ls; |
|
241 User::LeaveIfError(ls.Connect()); |
|
242 CleanupClosePushL(ls); |
|
243 |
|
244 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
245 commandLine->SetExecutableNameL( _L("autolock.exe" ) ); |
|
246 commandLine->SetCommandL( EApaCommandRun ); |
|
247 |
|
248 // Try to launch the application. |
|
249 TInt err = ls.StartApp(*commandLine); |
|
250 #if defined(_DEBUG) |
|
251 RDebug::Printf( "%s %s (%u) autolock.exe err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err ); |
|
252 #endif |
|
253 |
|
254 CleanupStack::PopAndDestroy(2); // commandLine, ls |
|
255 } |
|
256 |
|
257 /***************************************************** |
|
258 * Series 60 Customer / ETel |
|
259 * Series 60 ETel API |
|
260 *****************************************************/ |
232 iMessage = aMessage; |
261 iMessage = aMessage; |
233 iReturnVal = aReturnVal; |
262 iReturnVal = aReturnVal; |
234 TBool skipQuery = EFalse; // In some cases the query is handled by some other entity and SecurityNotifier should skip it. |
263 TBool skipQuery = EFalse; // In some cases the query is handled by some other entity and SecurityNotifier should skip it. |
235 |
264 |
236 #if defined(_DEBUG) |
265 #if defined(_DEBUG) |
237 RDebug::Print(_L("(SECURITYNOTIFIER)CSecurityNotifier::GetParamsL() Start BEGIN")); |
266 RDebug::Print(_L("(SECURITYNOTIFIER)CSecurityNotifier::GetParamsL() Start BEGIN")); |
238 #endif |
267 #endif |
239 |
268 |
240 |
269 |
241 TSecurityNotificationPckg pckg; |
270 TSecurityNotificationPckg pckg; |
242 pckg.Copy( aBuffer ); |
271 pckg.Copy( aBuffer ); |
243 iStartup = pckg().iStartup; |
272 iStartup = pckg().iStartup; |
244 iEvent = static_cast<RMobilePhone::TMobilePhoneSecurityEvent>(pckg().iEvent); |
273 iEvent = static_cast<RMobilePhone::TMobilePhoneSecurityEvent>(pckg().iEvent); |
245 |
274 |
246 #if defined(_DEBUG) |
|
247 RDebug::Printf( "%s %s (%u) searching for autolock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 ); |
|
248 RDebug::Printf( "%s %s (%u) iEvent=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iEvent ); |
|
249 RDebug::Printf( "%s %s (%u) 2 RMobilePhone::EPin1Required=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, RMobilePhone::EPin1Required ); |
|
250 #endif |
|
251 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
252 const TUid KAutolockUid = { 0x100059B5 }; |
|
253 TApaTask task( taskList.FindApp( KAutolockUid ) ); |
|
254 if ( !task.Exists() && iEvent != RMobilePhone::EPin1Required ) // PIN-request should not start autolock, to prevent that lock-code is secretly accepted by TARM. Rely on Startup. |
|
255 { |
|
256 #if defined(_DEBUG) |
|
257 RDebug::Printf( "%s %s (%u) autolock.exe not running. Starting now=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 ); |
|
258 #endif |
|
259 RApaLsSession ls; |
|
260 User::LeaveIfError(ls.Connect()); |
|
261 CleanupClosePushL(ls); |
|
262 |
|
263 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
264 commandLine->SetExecutableNameL( _L("autolock.exe" ) ); |
|
265 commandLine->SetCommandL( EApaCommandRun ); |
|
266 |
|
267 // Try to launch the application. |
|
268 User::LeaveIfError(ls.StartApp(*commandLine)); |
|
269 #if defined(_DEBUG) |
|
270 RDebug::Printf( "%s %s (%u) autolock.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x2 ); |
|
271 #endif |
|
272 |
|
273 CleanupStack::PopAndDestroy(2); // commandLine, ls |
|
274 } |
|
275 |
275 |
276 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
276 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
277 { |
277 { |
278 if(iEvent == RMobilePhone::EPhonePasswordRequired) |
278 if(iEvent == RMobilePhone::EPhonePasswordRequired) |
279 { |
279 { |
280 skipQuery = IsAdminCall(); // SCP handles the call. |
280 skipQuery = IsAdminCall(); // SCP handles the call. |
281 } |
281 } |
282 } |
282 } |
303 // CSecurityNotifier::RunL() |
303 // CSecurityNotifier::RunL() |
304 // Show query |
304 // Show query |
305 // ---------------------------------------------------------- |
305 // ---------------------------------------------------------- |
306 void CSecurityNotifier::RunL() |
306 void CSecurityNotifier::RunL() |
307 { |
307 { |
308 /***************************************************** |
308 /***************************************************** |
309 * Series 60 Customer / ETel |
309 * Series 60 Customer / ETel |
310 * Series 60 ETel API |
310 * Series 60 ETel API |
311 *****************************************************/ |
311 *****************************************************/ |
312 /***************************************************** |
312 /***************************************************** |
313 * Series 60 Customer / TSY |
313 * Series 60 Customer / TSY |
314 * Needs customer TSY implementation |
314 * Needs customer TSY implementation |
315 *****************************************************/ |
315 *****************************************************/ |
316 |
316 |
317 TInt err( KErrGeneral ); |
317 TInt err( KErrGeneral ); |
318 TInt thisTry( 0 ); |
318 TInt thisTry( 0 ); |
319 RTelServer::TPhoneInfo PhoneInfo; |
319 RTelServer::TPhoneInfo PhoneInfo; |
320 #if defined(_DEBUG) |
320 #if defined(_DEBUG) |
321 RDebug::Print(_L("CSecurityNotifier::RunL() Start")); |
321 RDebug::Print(_L("CSecurityNotifier::RunL() Start")); |
322 #endif |
322 #endif |
323 /*All server connections are tried to be made KTriesToConnectServer times because occasional |
323 /*All server connections are tried to be made KTriesToConnectServer times because occasional |
324 fails on connections are possible, at least on some servers*/ |
324 fails on connections are possible, at least on some servers*/ |
325 |
325 |
326 // connect to ETel server |
326 // connect to ETel server |
327 #if defined(_DEBUG) |
327 #if defined(_DEBUG) |
328 RDebug::Print(_L("CSecurityNotifier::RunL() connect to ETel server")); |
328 RDebug::Print(_L("CSecurityNotifier::RunL() connect to ETel server")); |
329 #endif |
329 #endif |
330 while ( ( err = iServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
330 while ( ( err = iServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
331 { |
331 { |
332 User::After( KTimeBeforeRetryingServerConnection ); |
332 User::After( KTimeBeforeRetryingServerConnection ); |
334 User::LeaveIfError( err ); |
334 User::LeaveIfError( err ); |
335 |
335 |
336 thisTry = 0; |
336 thisTry = 0; |
337 |
337 |
338 // load TSY |
338 // load TSY |
339 #if defined(_DEBUG) |
339 #if defined(_DEBUG) |
340 RDebug::Print(_L("CSecurityNotifier::RunL() load TSY")); |
340 RDebug::Print(_L("CSecurityNotifier::RunL() load TSY")); |
341 #endif |
341 #endif |
342 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
342 |
343 if ( err != KErrAlreadyExists ) |
343 if ( !iPhone.SubSessionHandle() ) |
|
344 { |
|
345 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
|
346 if ( err != KErrAlreadyExists ) |
344 { |
347 { |
345 // may also return KErrAlreadyExists if something |
348 // may also return KErrAlreadyExists if something |
346 // else has already loaded the TSY module. And that is |
349 // else has already loaded the TSY module. And that is |
347 // not an error. |
350 // not an error. |
348 User::LeaveIfError( err ); |
351 User::LeaveIfError( err ); |
349 } |
352 } |
350 |
353 |
351 // open phones |
354 // open phones |
352 #if defined(_DEBUG) |
355 #if defined(_DEBUG) |
353 RDebug::Print(_L("CSecurityNotifier::RunL() open phones")); |
356 RDebug::Print(_L("CSecurityNotifier::RunL() open phones")); |
354 #endif |
357 #endif |
355 User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
358 User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
356 User::LeaveIfError(iServer.GetPhoneInfo(PhoneIndex, PhoneInfo)); |
359 User::LeaveIfError(iServer.GetPhoneInfo(PhoneIndex, PhoneInfo)); |
357 User::LeaveIfError(iPhone.Open(iServer,PhoneInfo.iName)); |
360 User::LeaveIfError(iPhone.Open(iServer,PhoneInfo.iName)); |
|
361 } |
|
362 |
358 RProperty Property; |
363 RProperty Property; |
359 CleanupClosePushL( Property ); |
364 CleanupClosePushL( Property ); |
360 err = Property.Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); |
365 err = Property.Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); |
361 User::LeaveIfError( err ); |
366 User::LeaveIfError( err ); |
362 |
367 |
363 // initialize security ui |
368 // initialize security ui |
364 #if defined(_DEBUG) |
369 #if defined(_DEBUG) |
365 RDebug::Print(_L("CSecurityNotifier::RunL() initialize security ui")); |
370 RDebug::Print(_L("CSecurityNotifier::RunL() initialize security ui")); |
366 #endif |
371 #endif |
367 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
372 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
368 CleanupStack::PushL(handler); |
373 CleanupStack::PushL(handler); |
369 TSecUi::InitializeLibL(); |
374 TSecUi::InitializeLibL(); |
405 if(wcdmaSupported || upinSupported) |
410 if(wcdmaSupported || upinSupported) |
406 { |
411 { |
407 iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); |
412 iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); |
408 } |
413 } |
409 break; |
414 break; |
410 case RMobilePhone::EPin1Required: |
415 case RMobilePhone::EPin1Required: |
411 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
416 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
412 break; |
417 break; |
413 case RMobilePhone::EPuk1Required: |
418 case RMobilePhone::EPuk1Required: |
414 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); |
419 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); |
415 break; |
420 break; |
416 case RMobilePhone::EPin2Required: |
421 case RMobilePhone::EPin2Required: |
417 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); |
422 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); |
418 break; |
423 break; |
419 case RMobilePhone::EPuk2Required: |
424 case RMobilePhone::EPuk2Required: |
420 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); |
425 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); |
421 break; |
426 break; |
422 case RMobilePhone::EPhonePasswordRequired: |
427 case RMobilePhone::EPhonePasswordRequired: |
423 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
428 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
424 break; |
429 break; |
425 default: |
430 default: |
426 break; |
431 break; |
427 } |
432 } |
447 iMessage.Write( iReturnVal, TPckgBuf<TInt>( result ) ); |
452 iMessage.Write( iReturnVal, TPckgBuf<TInt>( result ) ); |
448 iMessage.Complete(KErrNone); |
453 iMessage.Complete(KErrNone); |
449 iReturnVal = KErrNone; |
454 iReturnVal = KErrNone; |
450 //Leave the window group to foreground for a short time to absorb key presses so that autolock has time to activate. |
455 //Leave the window group to foreground for a short time to absorb key presses so that autolock has time to activate. |
451 if(!StartUp) |
456 if(!StartUp) |
452 User::After(KDelayPeriod); |
457 User::After(KDelayPeriod); |
453 ( CEikonEnv::Static() )->BringForwards(EFalse); |
458 ( CEikonEnv::Static() )->BringForwards(EFalse); |
454 #if defined(_DEBUG) |
459 #if defined(_DEBUG) |
455 RDebug::Print(_L("CSecurityNotifier::RunL() End")); |
460 RDebug::Print(_L("CSecurityNotifier::RunL() End")); |
456 #endif |
461 #endif |
457 } |
462 } |
458 |
463 |
459 // ---------------------------------------------------------- |
464 // ---------------------------------------------------------- |