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 #if defined(_DEBUG) |
228 /***************************************************** |
229 RDebug::Printf( "%s %s (%u) searching for autolock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 ); |
229 * Series 60 Customer / ETel |
230 #endif |
230 * Series 60 ETel API |
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 *****************************************************/ |
|
261 iMessage = aMessage; |
232 iMessage = aMessage; |
262 iReturnVal = aReturnVal; |
233 iReturnVal = aReturnVal; |
263 TBool skipQuery = EFalse; // In some cases the query is handled by some other entity and SecurityNotifier should skip it. |
234 TBool skipQuery = EFalse; // In some cases the query is handled by some other entity and SecurityNotifier should skip it. |
264 |
235 |
265 #if defined(_DEBUG) |
236 #if defined(_DEBUG) |
266 RDebug::Print(_L("(SECURITYNOTIFIER)CSecurityNotifier::GetParamsL() Start BEGIN")); |
237 RDebug::Print(_L("(SECURITYNOTIFIER)CSecurityNotifier::GetParamsL() Start BEGIN")); |
267 #endif |
238 #endif |
268 |
239 |
269 |
240 |
270 TSecurityNotificationPckg pckg; |
241 TSecurityNotificationPckg pckg; |
271 pckg.Copy( aBuffer ); |
242 pckg.Copy( aBuffer ); |
272 iStartup = pckg().iStartup; |
243 iStartup = pckg().iStartup; |
273 iEvent = static_cast<RMobilePhone::TMobilePhoneSecurityEvent>(pckg().iEvent); |
244 iEvent = static_cast<RMobilePhone::TMobilePhoneSecurityEvent>(pckg().iEvent); |
274 |
245 |
|
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 |
342 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
343 if ( !iPhone.SubSessionHandle() ) |
343 if ( err != KErrAlreadyExists ) |
344 { |
|
345 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
|
346 if ( err != KErrAlreadyExists ) |
|
347 { |
344 { |
348 // may also return KErrAlreadyExists if something |
345 // may also return KErrAlreadyExists if something |
349 // else has already loaded the TSY module. And that is |
346 // else has already loaded the TSY module. And that is |
350 // not an error. |
347 // not an error. |
351 User::LeaveIfError( err ); |
348 User::LeaveIfError( err ); |
352 } |
349 } |
353 |
350 |
354 // open phones |
351 // open phones |
355 #if defined(_DEBUG) |
352 #if defined(_DEBUG) |
356 RDebug::Print(_L("CSecurityNotifier::RunL() open phones")); |
353 RDebug::Print(_L("CSecurityNotifier::RunL() open phones")); |
357 #endif |
354 #endif |
358 User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
355 User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
359 User::LeaveIfError(iServer.GetPhoneInfo(PhoneIndex, PhoneInfo)); |
356 User::LeaveIfError(iServer.GetPhoneInfo(PhoneIndex, PhoneInfo)); |
360 User::LeaveIfError(iPhone.Open(iServer,PhoneInfo.iName)); |
357 User::LeaveIfError(iPhone.Open(iServer,PhoneInfo.iName)); |
361 } |
|
362 |
|
363 RProperty Property; |
358 RProperty Property; |
364 CleanupClosePushL( Property ); |
359 CleanupClosePushL( Property ); |
365 err = Property.Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); |
360 err = Property.Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive); |
366 User::LeaveIfError( err ); |
361 User::LeaveIfError( err ); |
367 |
362 |
368 // initialize security ui |
363 // initialize security ui |
369 #if defined(_DEBUG) |
364 #if defined(_DEBUG) |
370 RDebug::Print(_L("CSecurityNotifier::RunL() initialize security ui")); |
365 RDebug::Print(_L("CSecurityNotifier::RunL() initialize security ui")); |
371 #endif |
366 #endif |
372 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
367 CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone); |
373 CleanupStack::PushL(handler); |
368 CleanupStack::PushL(handler); |
374 TSecUi::InitializeLibL(); |
369 TSecUi::InitializeLibL(); |
410 if(wcdmaSupported || upinSupported) |
405 if(wcdmaSupported || upinSupported) |
411 { |
406 { |
412 iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); |
407 iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk); |
413 } |
408 } |
414 break; |
409 break; |
415 case RMobilePhone::EPin1Required: |
410 case RMobilePhone::EPin1Required: |
416 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
411 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1); |
417 break; |
412 break; |
418 case RMobilePhone::EPuk1Required: |
413 case RMobilePhone::EPuk1Required: |
419 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); |
414 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1); |
420 break; |
415 break; |
421 case RMobilePhone::EPin2Required: |
416 case RMobilePhone::EPin2Required: |
422 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); |
417 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2); |
423 break; |
418 break; |
424 case RMobilePhone::EPuk2Required: |
419 case RMobilePhone::EPuk2Required: |
425 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); |
420 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2); |
426 break; |
421 break; |
427 case RMobilePhone::EPhonePasswordRequired: |
422 case RMobilePhone::EPhonePasswordRequired: |
428 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
423 iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword); |
429 break; |
424 break; |
430 default: |
425 default: |
431 break; |
426 break; |
432 } |
427 } |
452 iMessage.Write( iReturnVal, TPckgBuf<TInt>( result ) ); |
447 iMessage.Write( iReturnVal, TPckgBuf<TInt>( result ) ); |
453 iMessage.Complete(KErrNone); |
448 iMessage.Complete(KErrNone); |
454 iReturnVal = KErrNone; |
449 iReturnVal = KErrNone; |
455 //Leave the window group to foreground for a short time to absorb key presses so that autolock has time to activate. |
450 //Leave the window group to foreground for a short time to absorb key presses so that autolock has time to activate. |
456 if(!StartUp) |
451 if(!StartUp) |
457 User::After(KDelayPeriod); |
452 User::After(KDelayPeriod); |
458 ( CEikonEnv::Static() )->BringForwards(EFalse); |
453 ( CEikonEnv::Static() )->BringForwards(EFalse); |
459 #if defined(_DEBUG) |
454 #if defined(_DEBUG) |
460 RDebug::Print(_L("CSecurityNotifier::RunL() End")); |
455 RDebug::Print(_L("CSecurityNotifier::RunL() End")); |
461 #endif |
456 #endif |
462 } |
457 } |
463 |
458 |
464 // ---------------------------------------------------------- |
459 // ---------------------------------------------------------- |