85 /* |
88 /* |
86 const TDesC& aAppName, |
89 const TDesC& aAppName, |
87 const TDesC& aIconFile, const TDesC& aAppVersion, TInt aAppSize, |
90 const TDesC& aIconFile, const TDesC& aAppVersion, TInt aAppSize, |
88 const TDesC& aAppDetails ) */ |
91 const TDesC& aAppDetails ) */ |
89 { |
92 { |
90 RDebug::Printf( "%s %s (%u) aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aType ); |
93 |
91 RDebug::Printf( "%s %s (%u) password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
94 RDEBUG( "This should never be called. Obsolete", 0 ); |
92 TInt ESecQueryUiInstallConfirmationQueryType=0x101; |
95 return KErrAbort ; |
93 ClearParamsAndSetNoteTypeL( ESecQueryUiInstallConfirmationQueryType ); |
96 } |
94 |
97 |
95 AddParamL( _L("KSecQueryUiApplicationName"), _L("SecUi") ); |
98 // --------------------------------------------------------------------------- |
|
99 // CSecQueryUi::SecQueryDialog() |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TInt CSecQueryUi::SecQueryDialog(const TDesC& aCaption, TDes& aDataText, TInt aMinLength,TInt aMaxLength,TInt aMode) |
|
103 { |
|
104 RDEBUG( "aCaption", 0 ); |
|
105 RDebug::Print( aCaption ); |
|
106 RDEBUG( "aMode", aMode ); |
|
107 |
|
108 ClearParamsAndSetNoteTypeL( aMode ); |
|
109 AddParamL( _L("KSecQueryUiApplicationName"), aCaption ); |
96 |
110 |
97 _LIT(KTitle, "title"); |
111 _LIT(KTitle, "title"); |
98 _LIT(KTitleValue1, "Enter PIN"); |
112 // _LIT(KTitleValue1, "Enter PIN"); |
99 _LIT(KTitleValue2, "Enter PIN with care"); |
113 AddParamL( KTitle, aCaption ); |
100 _LIT(KTitleValue3, "Enter PIN last"); |
114 AddParamL( _L("MinLength"), aMinLength ); |
101 if(aType==KMaxNumberOfPINAttempts) |
115 AddParamL( _L("MaxLength"), aMaxLength ); |
102 AddParamL( KTitle, KTitleValue1 ); |
|
103 else if(aType> KLastRemainingInputAttempt) |
|
104 AddParamL( KTitle, KTitleValue2 ); |
|
105 else |
|
106 AddParamL( KTitle, KTitleValue3 ); |
|
107 |
116 |
108 _LIT( KCodeTop, "codeTop" ); _LIT( KCodeTopValue, "codeTop" ); |
117 _LIT( KCodeTop, "codeTop" ); _LIT( KCodeTopValue, "codeTop" ); |
109 AddParamL( KCodeTop, KCodeTopValue ); |
118 AddParamL( KCodeTop, KCodeTopValue ); |
110 |
119 |
111 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
120 if( aCaption.Find(_L("|"))>0 ) |
|
121 { |
|
122 RDEBUG( "codeBottom aMode", aMode ); |
|
123 _LIT( KCodeBottom, "codeBottom" ); _LIT( KCodeBottomValue, "codeBottom" ); |
|
124 AddParamL( KCodeBottom, KCodeBottomValue ); |
|
125 } |
|
126 |
|
127 RDEBUG( "0", 0 ); |
112 DisplayDeviceDialogL(); |
128 DisplayDeviceDialogL(); |
113 User::LeaveIfError( WaitUntilDeviceDialogClosed() ); |
129 TInt error = WaitUntilDeviceDialogClosed(); |
114 password.Copy(iPassword); |
130 RDEBUG( "error", error ); |
115 return( iReturnValue == KErrNone ); |
131 User::LeaveIfError( error ); |
116 } |
132 |
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CSecQueryUi::SecQueryDialog() |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C TInt CSecQueryUi::SecQueryDialog(const TDesC& aCaption, TDes& aDataText, TInt aMinLength,TInt aMaxLength,TInt aMode) |
|
123 { |
|
124 RDebug::Printf( "%s %s (%u) aCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
125 RDebug::Print( aCaption ); |
|
126 RDebug::Printf( "%s %s (%u) aMode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aMode ); |
|
127 |
|
128 ClearParamsAndSetNoteTypeL( aMode ); |
|
129 AddParamL( _L("KSecQueryUiApplicationName"), aCaption ); |
|
130 |
|
131 _LIT(KTitle, "title"); |
|
132 // _LIT(KTitleValue1, "Enter PIN"); |
|
133 AddParamL( KTitle, aCaption ); |
|
134 |
|
135 _LIT( KCodeTop, "codeTop" ); _LIT( KCodeTopValue, "codeTop" ); |
|
136 AddParamL( KCodeTop, KCodeTopValue ); |
|
137 |
|
138 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
139 DisplayDeviceDialogL(); |
|
140 User::LeaveIfError( WaitUntilDeviceDialogClosed() ); |
|
141 aDataText.Copy(iPassword); |
133 aDataText.Copy(iPassword); |
142 return( iReturnValue == KErrNone ); |
134 RDEBUG( "iReturnValue", iReturnValue ); |
|
135 return iReturnValue; |
143 } |
136 } |
144 |
137 |
145 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
146 // CSecQueryUi::DisplayInformationNoteL() |
139 // CSecQueryUi::DisplayInformationNoteL() |
147 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
260 // CSecQueryUi::DoCancel() |
253 // CSecQueryUi::DoCancel() |
261 // --------------------------------------------------------------------------- |
254 // --------------------------------------------------------------------------- |
262 // |
255 // |
263 void CSecQueryUi::DoCancel() |
256 void CSecQueryUi::DoCancel() |
264 { |
257 { |
265 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
258 RDEBUG( "0", 0 ); |
266 if( iWait && iWait->IsStarted() && iWait->CanStopNow() ) |
259 if( iWait && iWait->IsStarted() && iWait->CanStopNow() ) |
267 { |
260 { |
268 iCompletionCode = KErrCancel; |
261 iCompletionCode = KErrCancel; |
269 iWait->AsyncStop(); |
262 iWait->AsyncStop(); |
270 } |
263 } |
|
264 RDEBUG( "0", 0 ); |
271 } |
265 } |
272 |
266 |
273 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |
274 // CSecQueryUi::RunL() |
268 // CSecQueryUi::RunL() |
275 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
276 // |
270 // |
277 void CSecQueryUi::RunL() |
271 void CSecQueryUi::RunL() |
278 { |
272 { |
279 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
273 RDEBUG( "0", 0 ); |
280 if( iWait ) |
274 if( iWait ) |
281 { |
275 { |
282 iWait->AsyncStop(); |
276 iWait->AsyncStop(); |
283 } |
277 } |
|
278 RDEBUG( "0", 0 ); |
284 } |
279 } |
285 |
280 |
286 // --------------------------------------------------------------------------- |
281 // --------------------------------------------------------------------------- |
287 // CSecQueryUi::DataReceived() |
282 // CSecQueryUi::DataReceived() |
288 // --------------------------------------------------------------------------- |
283 // --------------------------------------------------------------------------- |
289 // |
284 // |
290 void CSecQueryUi::DataReceived( CHbSymbianVariantMap& aData ) |
285 void CSecQueryUi::DataReceived( CHbSymbianVariantMap& aData ) |
291 { |
286 { |
292 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
287 RDEBUG( "0", 0 ); |
293 const CHbSymbianVariant* acceptedVariant = aData.Get( _L("accepted") ); // KSecQueryUiQueryAccepted |
288 const CHbSymbianVariant* acceptedVariant = aData.Get( _L("accepted") ); // KSecQueryUiQueryAccepted |
|
289 RDEBUG( "0", 0 ); |
294 if( acceptedVariant ) |
290 if( acceptedVariant ) |
295 { |
291 { |
296 TBool* acceptedValue = acceptedVariant->Value<TBool>(); |
292 RDEBUG( "0", 0 ); |
297 if( acceptedValue && *acceptedValue ) |
293 TInt* acceptedValue = acceptedVariant->Value<TInt>(); |
|
294 RDEBUG( "acceptedValue", acceptedValue ); |
|
295 RDEBUG( "*acceptedValue", *acceptedValue ); |
|
296 if( acceptedValue ) |
298 { |
297 { |
299 iReturnValue = KErrNone; |
298 iReturnValue = *acceptedValue; |
300 } |
299 } |
301 else |
|
302 { |
|
303 iReturnValue = KErrCancel; |
|
304 } |
|
305 } |
300 } |
306 const CHbSymbianVariant* acceptedVariantTop = aData.Get( _L("codeTop") ); // KSecQueryUiQueryAccepted |
301 const CHbSymbianVariant* acceptedVariantTop = aData.Get( _L("codeTop") ); // KSecQueryUiQueryAccepted |
|
302 RDEBUG( "0", 0 ); |
307 if( acceptedVariantTop ) |
303 if( acceptedVariantTop ) |
308 { |
304 { |
309 TPtrC acceptedValueTop = *acceptedVariantTop->Value<TDesC>(); |
305 TPtrC acceptedValueTop = *acceptedVariantTop->Value<TDesC>(); |
310 RDebug::Printf( "%s %s (%u) acceptedValueTop=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
306 RDEBUG( "acceptedValueTop", 0 ); |
311 RDebug::Print( acceptedValueTop ); |
307 RDebug::Print( acceptedValueTop ); |
312 iPassword.Copy(acceptedValueTop); |
308 iPassword.Copy(acceptedValueTop); |
313 } |
309 |
|
310 if(iReturnValue == KErrCompletion ) // the user didn't OK. It was send automatically because validating new lock code |
|
311 { |
|
312 _LIT( KInvalidNewLockCode, "invalidNewLockCode" ); |
|
313 _LIT( KInvalidNewLockCode0, "invalidNewLockCode#0" ); |
|
314 _LIT( KInvalidNewLockCode1, "invalidNewLockCode#1" ); |
|
315 _LIT( KInvalidNewLockCode2, "invalidNewLockCode#2" ); |
|
316 AddParamL( KInvalidNewLockCode, KInvalidNewLockCode0 ); // for starter |
|
317 RSCPClient scpClient; |
|
318 TSCPSecCode newCode; |
|
319 newCode.Copy( acceptedValueTop ); |
|
320 RDEBUG( "scpClient.Connect", 0 ); |
|
321 if ( scpClient.Connect() == KErrNone ) |
|
322 { |
|
323 /* |
|
324 RArray<TDevicelockPolicies> aFailedPolicies; |
|
325 TDevicelockPolicies failedPolicy; |
|
326 TInt retLockcode = KErrNone; |
|
327 RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 ); |
|
328 retLockcode = scpClient.VerifyNewLockcodeAgainstPolicies( newCode, aFailedPolicies ); |
|
329 RDEBUG( "retLockcode", retLockcode ); |
|
330 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
|
331 for(TInt i=0; i<aFailedPolicies.Count(); i++) |
|
332 { |
|
333 failedPolicy = aFailedPolicies[i]; |
|
334 RDEBUG( "failedPolicy", failedPolicy ); |
|
335 TBuf<0x100> KInvalidNewLockCodeX; KInvalidNewLockCodeX.Zero(); KInvalidNewLockCodeX.Append(_L("invalidNewLockCode")); KInvalidNewLockCodeX.Append(_L("#")); |
|
336 KInvalidNewLockCodeX.AppendNum(failedPolicy); |
|
337 AddParamL( KInvalidNewLockCode, KInvalidNewLockCodeX ); |
|
338 } |
|
339 */ |
|
340 scpClient.Close(); |
|
341 } |
|
342 RDEBUG( "iDeviceDialog->Update", 0 ); |
|
343 iDeviceDialog->Update( *iVariantMap ); |
|
344 } // KErrCompletion |
|
345 |
|
346 if(acceptedValueTop.Length()<=4) // TODO store aMinLenght and check it here, instead of "4" |
|
347 { |
|
348 RDEBUG( "CPhCltEmergencyCall", 0 ); |
|
349 CPhCltEmergencyCall* emergencyCall = CPhCltEmergencyCall::NewL( NULL ); |
|
350 RDEBUG( "PushL", 0 ); |
|
351 CleanupStack::PushL( emergencyCall ); |
|
352 TPhCltEmergencyNumber emNumber; |
|
353 |
|
354 // this relies on the fact that emergency has 3 digits, and password needs at least 4 |
|
355 TBool isEmergency( EFalse ); |
|
356 RDEBUG( "calling IsEmergencyPhoneNumber", 0 ); |
|
357 TInt error = emergencyCall->IsEmergencyPhoneNumber( acceptedValueTop, isEmergency ); |
|
358 RDEBUG( "error", error ); |
|
359 RDEBUG( "emNumber", 0 ); |
|
360 |
|
361 RDEBUG( "isEmergency", isEmergency ); |
|
362 #ifdef __WINS__ |
|
363 RDEBUG( "__WINS__ checking", 0 ); |
|
364 if(!acceptedValueTop.CompareF(_L("112")) || !acceptedValueTop.CompareF(_L("911")) || !acceptedValueTop.CompareF(_L("555")) ) |
|
365 { |
|
366 isEmergency = ETrue; |
|
367 error = KErrNone; |
|
368 RDEBUG( "__WINS__ isEmergency", isEmergency ); |
|
369 } |
|
370 #endif |
|
371 |
|
372 if ( !error ) // oddly enough, missing capabilities also gives KErrNone |
|
373 { |
|
374 if(iReturnValue == KErrAbort ) // the user didn't OK. It was send automatically because short code |
|
375 { |
|
376 _LIT( KEmergency, "emergency" ); _LIT( KEmergencyValueYes, "emergencyYes" ); _LIT( KEmergencyValueNo, "emergencyNo" ); |
|
377 if(isEmergency) |
|
378 { |
|
379 RDEBUG( "KEmergencyValueYes", 1 ); |
|
380 AddParamL( KEmergency, KEmergencyValueYes ); |
|
381 } |
|
382 else |
|
383 { |
|
384 RDEBUG( "KEmergencyValueNo", 0 ); |
|
385 AddParamL( KEmergency, KEmergencyValueNo ); |
|
386 } |
|
387 iDeviceDialog->Update( *iVariantMap ); |
|
388 } |
|
389 else if(iReturnValue == KErrNone ) |
|
390 { // user pressed Call and number is valid |
|
391 if(isEmergency) |
|
392 { |
|
393 RDEBUG( "DialEmergencyCallL", isEmergency ); |
|
394 emergencyCall->DialEmergencyCallL( emNumber ); |
|
395 iReturnValue = KErrAbort; // this means emergency call |
|
396 } |
|
397 } |
|
398 } // if !error |
|
399 RDEBUG( "0", 0 ); |
|
400 CleanupStack::PopAndDestroy( emergencyCall ); |
|
401 } // lenght<3 |
|
402 } // acceptedVariantTop |
|
403 RDEBUG( "iReturnValue", iReturnValue ); |
314 } |
404 } |
315 |
405 |
316 // --------------------------------------------------------------------------- |
406 // --------------------------------------------------------------------------- |
317 // CSecQueryUi::DeviceDialogClosed() |
407 // CSecQueryUi::DeviceDialogClosed() |
318 // --------------------------------------------------------------------------- |
408 // --------------------------------------------------------------------------- |
319 // |
409 // |
320 void CSecQueryUi::DeviceDialogClosed( TInt aCompletionCode ) |
410 void CSecQueryUi::DeviceDialogClosed( TInt aCompletionCode ) |
321 { |
411 { |
322 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
412 RDEBUG( "aCompletionCode", aCompletionCode ); |
323 iCompletionCode = aCompletionCode; |
413 iCompletionCode = aCompletionCode; |
324 iIsDisplayingDialog = EFalse; |
414 iIsDisplayingDialog = EFalse; |
325 |
415 |
326 TRequestStatus* status( &iStatus ); |
416 TRequestStatus* status( &iStatus ); |
|
417 RDEBUG( "0", 0 ); |
327 User::RequestComplete( status, KErrNone ); |
418 User::RequestComplete( status, KErrNone ); |
|
419 RDEBUG( "0", 0 ); |
328 } |
420 } |
329 |
421 |
330 // --------------------------------------------------------------------------- |
422 // --------------------------------------------------------------------------- |
331 // CSecQueryUi::CSecQueryUi() |
423 // CSecQueryUi::CSecQueryUi() |
332 // --------------------------------------------------------------------------- |
424 // --------------------------------------------------------------------------- |
333 // |
425 // |
334 CSecQueryUi::CSecQueryUi() : CActive( CActive::EPriorityStandard ) |
426 CSecQueryUi::CSecQueryUi() : CActive( CActive::EPriorityStandard ) |
335 { |
427 { |
336 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
428 RDEBUG( "0", 0 ); |
337 CActiveScheduler::Add( this ); |
429 CActiveScheduler::Add( this ); |
338 } |
430 } |
339 |
431 |
340 // --------------------------------------------------------------------------- |
432 // --------------------------------------------------------------------------- |
341 // CSecQueryUi::ConstructL() |
433 // CSecQueryUi::ConstructL() |
342 // --------------------------------------------------------------------------- |
434 // --------------------------------------------------------------------------- |
343 // |
435 // |
344 void CSecQueryUi::ConstructL() |
436 void CSecQueryUi::ConstructL() |
345 { |
437 { |
346 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
438 RDEBUG( "0", 0 ); |
347 iWait = new( ELeave ) CActiveSchedulerWait; |
439 iWait = new( ELeave ) CActiveSchedulerWait; |
348 // iDeviceDialog is allocated later, first call of DisplayDeviceDialogL() |
440 // iDeviceDialog is allocated later, first call of DisplayDeviceDialogL() |
349 } |
441 } |
350 |
442 |
351 // --------------------------------------------------------------------------- |
443 // --------------------------------------------------------------------------- |
352 // CSecQueryUi::ClearParamsL() |
444 // CSecQueryUi::ClearParamsL() |
353 // --------------------------------------------------------------------------- |
445 // --------------------------------------------------------------------------- |
354 // |
446 // |
355 void CSecQueryUi::ClearParamsL() |
447 void CSecQueryUi::ClearParamsL() |
356 { |
448 { |
|
449 RDEBUG( "0", 0 ); |
357 if( iVariantMap ) |
450 if( iVariantMap ) |
358 { |
451 { |
359 delete iVariantMap; |
452 delete iVariantMap; |
360 iVariantMap = NULL; |
453 iVariantMap = NULL; |
361 } |
454 } |
421 if( !iDeviceDialog ) |
514 if( !iDeviceDialog ) |
422 { |
515 { |
423 iDeviceDialog = CHbDeviceDialog::NewL(); |
516 iDeviceDialog = CHbDeviceDialog::NewL(); |
424 } |
517 } |
425 _LIT( KSecQueryUiDeviceDialog, "com.nokia.secuinotificationdialog/1.0" ); |
518 _LIT( KSecQueryUiDeviceDialog, "com.nokia.secuinotificationdialog/1.0" ); |
426 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
519 RDEBUG( "Show", 0 ); |
427 iDeviceDialog->Show( KSecQueryUiDeviceDialog, *iVariantMap, this ); |
520 iDeviceDialog->Show( KSecQueryUiDeviceDialog, *iVariantMap, this ); |
428 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
521 RDEBUG( "iIsDisplayingDialog", iIsDisplayingDialog ); |
429 iIsDisplayingDialog = ETrue; |
522 iIsDisplayingDialog = ETrue; |
430 } |
523 RDEBUG( "iIsDisplayingDialog", iIsDisplayingDialog ); |
|
524 } |
|
525 RDEBUG( "0", 0 ); |
431 } |
526 } |
432 |
527 |
433 // --------------------------------------------------------------------------- |
528 // --------------------------------------------------------------------------- |
434 // CSecQueryUi::WaitUntilDeviceDialogClosed() |
529 // CSecQueryUi::WaitUntilDeviceDialogClosed() |
435 // --------------------------------------------------------------------------- |
530 // --------------------------------------------------------------------------- |
436 // |
531 // |
437 TInt CSecQueryUi::WaitUntilDeviceDialogClosed() |
532 TInt CSecQueryUi::WaitUntilDeviceDialogClosed() |
438 { |
533 { |
439 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
534 RDEBUG( "0", 0 ); |
440 iCompletionCode = KErrInUse; |
535 iCompletionCode = KErrInUse; |
441 iReturnValue = KErrUnknown; |
536 iReturnValue = KErrUnknown; |
442 if( !IsActive() && iWait && !iWait->IsStarted() ) |
537 if( !IsActive() && iWait && !iWait->IsStarted() ) |
443 { |
538 { |
444 iStatus = KRequestPending; |
539 iStatus = KRequestPending; |
445 SetActive(); |
540 SetActive(); |
|
541 RDEBUG( "Start", 0 ); |
446 iWait->Start(); |
542 iWait->Start(); |
447 } |
543 RDEBUG( "Started", 1 ); |
|
544 } |
|
545 RDEBUG( "iCompletionCode", iCompletionCode ); |
448 return iCompletionCode; |
546 return iCompletionCode; |
449 } |
547 } |
450 |
548 |