terminalsecurity/SCP/SCPClient/src/SCPQueryDialog.cpp
branchRCL_3
changeset 16 915074efc433
parent 15 007508d6e57b
child 19 696f5dd11939
equal deleted inserted replaced
15:007508d6e57b 16:915074efc433
   309    iEikonEnv->BringForwards(ETrue, ECoeWinPriorityAlwaysAtFront+1);
   309    iEikonEnv->BringForwards(ETrue, ECoeWinPriorityAlwaysAtFront+1);
   310 
   310 
   311 	/// -- Change Window Priority for dialog and CBA 
   311 	/// -- Change Window Priority for dialog and CBA 
   312 	if (iECSSupport)
   312 	if (iECSSupport)
   313 		{
   313 		{
   314 		Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Changing Window Priority") ));			
   314 		Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Changing Window Priority") ));
   315 		DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   315 		DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   316 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); 	
   316 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   317 		}
   317 		}
   318 	else
   318 	else
   319 		{
   319 		{
   320 		DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1); //
   320 		DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1); //
   321 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1); 	  	
   321 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1);
   322 		}	
   322 		}	
   323 
   323 
   324 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Key sounds") ));
   324 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Key sounds") ));
   325 	// Key sounds
   325 	// Key sounds
   326 
   326 
   533         // Character removed, make sure we're back on track,
   533         // Character removed, make sure we're back on track,
   534         // though likely only backspace was pressed
   534         // though likely only backspace was pressed
   535         iValidTextLen = QueryControl()->GetTextLength();
   535         iValidTextLen = QueryControl()->GetTextLength();
   536         }   
   536         }   
   537         
   537         
   538 //Additional modifier set by query dialog, while simulating event
   538     //Additional modifier set by query dialog, while simulating event
   539 // As raw key events are used to simulate, modifiers and scan codes cannot be set at a time
   539     // As raw key events are used to simulate, modifiers and scan codes cannot be set at a time
   540 // In the 1st event, modifiers are set and in subsequent event, scan codes will be set.
   540     // In the 1st event, modifiers are set and in subsequent event, scan codes will be set.
   541 if(aKeyEvent.iModifiers & EModifierNumLock &&
   541     if( aKeyEvent.iModifiers & EModifierNumLock &&
   542         aKeyEvent.iModifiers & EModifierKeypad && aKeyEvent.iModifiers & EModifierSpecial
   542         aKeyEvent.iModifiers & EModifierKeypad && 
   543 )
   543         aKeyEvent.iModifiers & EModifierSpecial) {
   544     {
   544     
   545    
   545         return EKeyWasConsumed;
   546     return EKeyWasConsumed;
       
   547     }
   546     }
       
   547     
   548     if ( iECSSupport )
   548     if ( iECSSupport )
   549         {
   549         {
   550         // Save the text
   550         // Save the text
   551         if ( aType == EEventKey ) 
   551         if ( aType == EEventKey ) 
   552             {
   552             {
   601             {
   601             {
   602             // The input doesn't match a Em-number
   602             // The input doesn't match a Em-number
   603             if ( queryControl != NULL )
   603             if ( queryControl != NULL )
   604                 {
   604                 {
   605                 queryControl->RevealSecretText( EFalse );
   605                 queryControl->RevealSecretText( EFalse );
   606 			if(aType == EEventKey)
   606 				
   607 			{
   607                 if(aType == EEventKey)
   608                 HBufC* cbaLabel = NULL;
   608                 {
   609 				Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): R_SCPDIALOG_OK_TEXT") ));
   609                     HBufC* cbaLabel = NULL;
   610                 TRAPD ( err , cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   610                     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): R_SCPDIALOG_OK_TEXT") ));
   611                 if ( err == KErrNone )
   611                     TRAPD ( err , cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   612                 {
   612                     if ( err == KErrNone )
   613 					if (isCallSoftkeyAdded)
   613                     {
   614 					{
   614                         if (isCallSoftkeyAdded)
   615 						isCallSoftkeyAdded = EFalse;
   615                         {
   616 						ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyEmergencyCall);
   616                             isCallSoftkeyAdded = EFalse;
   617 					}
   617                             ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyEmergencyCall);
   618 					else
   618                         }
   619 					{
   619                         else
   620 					ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   620                         {
   621 					}
   621                         ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   622                 TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0,EAknSoftkeyOk,*cbaLabel) );
   622                         }
   623                 ButtonGroupContainer().DrawDeferred();
   623                     TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0,EAknSoftkeyOk,*cbaLabel) );
   624                 delete cbaLabel;
   624                     ButtonGroupContainer().DrawDeferred();
   625 				}
   625                     delete cbaLabel;
   626             	  }
   626                     }
   627                 }
   627                 }
   628             }
   628             }
   629         }                  
   629         }
       
   630     }
   630      
   631      
   631     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL() exiting") ));
   632     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL() exiting") ));
   632               
   633               
   633     if ( ret == EKeyWasConsumed ) // The editor control used up this keyevent
   634     if ( ret == EKeyWasConsumed ) // The editor control used up this keyevent
   634         {
   635         {
   659 	{
   660 	{
   660 	
   661 	
   661 	     Dprint( (_L("CSCPQueryDialog::OkToExitL ( aButtonId :%d, "), aButtonId ));
   662 	     Dprint( (_L("CSCPQueryDialog::OkToExitL ( aButtonId :%d, "), aButtonId ));
   662 	TInt ret = EFalse;
   663 	TInt ret = EFalse;
   663 	
   664 	
   664     if ( aButtonId == EAknSoftkeyOk )
   665 	switch(aButtonId) {
   665 		{	        		
   666 	    case EAknSoftkeyOk:
   666 		Dprint( (_L("CSCPQueryDialog::OkToExitL - EAknSoftkeyOk") ));		
   667 	    case EAknSoftkeyCancel:
   667 		TInt textLength = QueryControl()->GetTextLength();
   668 	        ret = CAknTextQueryDialog::OkToExitL(aButtonId);
   668 		if ( textLength < iMinLength )
   669 	        break;
   669 			{	
   670 	    case ESecUiEmergencyCall:
   670 			// The code was too short -> play error tone & clear editor
   671 	    case EAknSoftkeyEmergencyCall: {
   671 			if ( textLength != 0 )
   672             Dprint( (_L("CSCPQueryDialog::OkToExitL(): adding EKeyPhoneSend to detector") ));
   672 				{
   673             
   673 				CAknKeySoundSystem* soundSystem;
   674             switch(iButtons) {
   674 	            if ( iEikonEnv->AppUi() )
   675                 case RSCPClient::SCP_OK:
   675 		            {		            
   676                 case RSCPClient::SCP_OK_ETEL:
   676 		            soundSystem = static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds();
   677                     //Required only during device startup
   677 		            soundSystem->PlaySound( EAvkonSIDErrorTone );
   678                     iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityLow);
   678 		            } 
   679                     break;
   679 				QueryControl()->SetTextL( KNullDesC );
   680                 default:
   680 				iTextBuffer.Zero();
   681                     break;
   681 				iValidTextLen = 0;
   682             }
   682 
   683             
   683                 // Hide the OK key
   684             iEMCallActivated = ETrue;
   684                 //ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, EFalse );
   685             iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) );   
   685                // ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
   686 	    }
   686 
   687         break;
   687                 if (AknLayoutUtils::PenEnabled())
   688 	    default:
   688                     {
   689 	        break;	        
   689                     ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
   690 	}
   690                     }
   691 	
   691                 else
       
   692                     {
       
   693                     ButtonGroupContainer().MakeCommandVisible(EAknSoftkeyOk, EFalse);
       
   694                     }
       
   695                 }
       
   696             ret = EFalse;
       
   697             }	
       
   698 		else
       
   699 			{		
       
   700 			ret = CAknTextQueryDialog::OkToExitL(aButtonId);
       
   701 			}			    
       
   702 		}
       
   703 				
       
   704 	// Cancel is allowed, if the key is active
       
   705 	if ( aButtonId == EAknSoftkeyCancel )
       
   706 		{
       
   707     	Dprint( (_L("CSCPQueryDialog::OkToExitL EAknSoftkeyCancel ")) );	
       
   708 	    ret = CAknTextQueryDialog::OkToExitL(aButtonId);
       
   709 		}
       
   710 		
       
   711     // Emergency call, exit
       
   712     if (aButtonId == ESecUiEmergencyCall || aButtonId == EAknSoftkeyEmergencyCall)
       
   713     {
       
   714         //add EKeyPhonesend to ecs detector. 
       
   715 //        ret = ETrue;
       
   716 //        CAknTextQueryDialog::OkToExitL(aButtonId);
       
   717         Dprint( (_L("CSCPQueryDialog::OkToExitL(): adding EKeyPhoneSend to detector") ));
       
   718         
       
   719         switch(iButtons) {
       
   720             case RSCPClient::SCP_OK:
       
   721             case RSCPClient::SCP_OK_ETEL:
       
   722                 //Required only during device startup
       
   723                 iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityLow);
       
   724                 break;
       
   725             default:
       
   726                 break;
       
   727         }
       
   728         
       
   729         iEMCallActivated = ETrue;
       
   730         iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) );
       
   731     }
       
   732    
       
   733 	Dprint( (_L("CSCPQueryDialog::OkToExitL() done") ));   
   692 	Dprint( (_L("CSCPQueryDialog::OkToExitL() done") ));   
   734 	return ret;
   693 	return ret;
   735 	}
   694 	}
   736 
   695 
   737 
   696 
   754         serviceCallEnabled = FeatureManager::FeatureSupported( 
   713         serviceCallEnabled = FeatureManager::FeatureSupported( 
   755             KFeatureIdFfServiceCallWhilePhoneLocked );
   714             KFeatureIdFfServiceCallWhilePhoneLocked );
   756         FeatureManager::UnInitializeLib();
   715         FeatureManager::UnInitializeLib();
   757         }
   716         }
   758 
   717 
   759     /*if ( ( aUpdatedState == CAknEcsDetector::ECompleteMatchThenSendKey ) || 
   718     if ( aUpdatedState == CAknEcsDetector::ECompleteMatch ||
   760          ( aUpdatedState == CAknEcsDetector::ECallAttempted ) )
       
   761         {
       
   762         // Call attempted, cancel the query
       
   763         iEMCallActivated = ETrue; // OfferKeyEventL will close the dialog         
       
   764         }
       
   765     else*/ if ( aUpdatedState == CAknEcsDetector::ECompleteMatch ||
       
   766               ( serviceCallEnabled && aUpdatedState == CAknEcsDetector::EServiceNumMatch ) )
   719               ( serviceCallEnabled && aUpdatedState == CAknEcsDetector::EServiceNumMatch ) )
   767         {
   720         {
   768         iShowingEMNumber = ETrue;
   721         iShowingEMNumber = ETrue;
   769         }
   722         }
   770     else if ( iShowingEMNumber )
   723     else if ( iShowingEMNumber )
   785                    );            
   738                    );            
   786             if ( queryControl != NULL )
   739             if ( queryControl != NULL )
   787                 {
   740                 {
   788                 queryControl->RevealSecretText( EFalse );
   741                 queryControl->RevealSecretText( EFalse );
   789                 }
   742                 }
   790            // }        
   743 
   791                 HBufC* cbaLabel = NULL;
   744                 HBufC* cbaLabel = NULL;
   792 				Dprint( (_L("CSCPQueryDialog::HandleEcsEvent(): R_SCPDIALOG_OK_TEXT") ));
   745 				Dprint( (_L("CSCPQueryDialog::HandleEcsEvent(): R_SCPDIALOG_OK_TEXT") ));
   793                 TRAP ( err, cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   746                 TRAP ( err, cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   794                 if ( err == KErrNone )
   747                 if ( err == KErrNone )
   795                 {
   748                 {
   805                 	TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0, EAknSoftkeyOk, *cbaLabel) );
   758                 	TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0, EAknSoftkeyOk, *cbaLabel) );
   806                 	ButtonGroupContainer().DrawDeferred();
   759                 	ButtonGroupContainer().DrawDeferred();
   807                 	delete cbaLabel;
   760                 	delete cbaLabel;
   808                 }
   761                 }
   809             }
   762             }
   810         }    
   763         }
   811     }
   764     }    
   812  
   765  
   813 void CSCPQueryDialog::ShowWarningNoteL()
   766 void CSCPQueryDialog::ShowWarningNoteL()
   814     {
   767     {
   815     
   768     
   816     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog();
   769     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog();
   827     
   780     
   828 // -----------------------------------------------------------------------------
   781 // -----------------------------------------------------------------------------
   829 // CSCPQueryDialog::SetIncallBubbleAllowedInUsualL()
   782 // CSCPQueryDialog::SetIncallBubbleAllowedInUsualL()
   830 // -----------------------------------------------------------------------------
   783 // -----------------------------------------------------------------------------
   831 //
   784 //
   832 void CSCPQueryDialog::SetIncallBubbleAllowedInUsualL(TBool aAllowed)
   785 void CSCPQueryDialog :: SetIncallBubbleAllowedInUsualL(TBool aAllowed) {
   833     {
       
   834     CAknIncallBubble *incallBubble =  CAknIncallBubble::NewL();
   786     CAknIncallBubble *incallBubble =  CAknIncallBubble::NewL();
   835     CleanupStack::PushL(incallBubble);
   787     CleanupStack :: PushL(incallBubble);
   836     incallBubble->SetIncallBubbleAllowedInUsualL( aAllowed );
   788     incallBubble->SetIncallBubbleAllowedInUsualL(aAllowed);
   837     CleanupStack::PopAndDestroy();
   789     CleanupStack :: PopAndDestroy();
   838     }
   790 }
   839 	
       
   840 // Call from the SCPObserver
       
   841 	
   791 	
   842 void CSCPQueryDialog::TryCancelQueryL(TInt aReason) {
   792 void CSCPQueryDialog::TryCancelQueryL(TInt aReason) {
   843     Dprint( (_L("CSCPQueryDialog::TryCancelQueryL()")) );
   793     Dprint( (_L("CSCPQueryDialog::TryCancelQueryL()")) );
   844     
   794     
   845     switch(aReason) {
   795     switch(aReason) {
   846         case CSCPLockObserver :: EEnded:
   796         case CSCPLockObserver :: EEnded:
   847             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): Call ended, raising priority...")));
   797             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): Call ended, raising priority...")));
   848             
   798             
   849             switch(iButtons) {
   799             switch(iButtons) {
   850                 case RSCPClient::SCP_OK:
   800                 case RSCPClient :: SCP_OK:
   851                 case RSCPClient::SCP_OK_ETEL:
   801                 case RSCPClient :: SCP_OK_ETEL:
   852                     if(iEMCallActivated) {
   802                     if(iEMCallActivated) {
   853                         TryExitL(EAknSoftkeyCancel);
   803                         TryExitL(EAknSoftkeyCancel);
   854                     }
   804                     }
   855                     else {
   805                     else {
   856                         iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1);
   806                         iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1);
   861                     break;
   811                     break;
   862             }
   812             }
   863             break;
   813             break;
   864         case CSCPLockObserver :: EInProgress:
   814         case CSCPLockObserver :: EInProgress:
   865             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): received call in progress event...")));
   815             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): received call in progress event...")));
   866             
   816             TryExitL(EAknSoftkeyCancel);
   867 //            if(iEMCallActivated) {
       
   868                 Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): EM active, exiting...")));
       
   869                 TryExitL(EAknSoftkeyCancel);
       
   870 //            }
       
   871             break;
   817             break;
   872         case ESecUiDeviceLocked:
   818         case ESecUiDeviceLocked:
   873             Dprint(_L("[CSCPQueryDialog]-> TryExitL 4"));
   819             Dprint(_L("[CSCPQueryDialog]-> TryExitL 4"));
   874             TryExitL(EAknSoftkeyCancel);
   820             TryExitL(EAknSoftkeyCancel);
   875             break;
   821             break;
   876         default:
   822         default:
   877             break;
   823             break;
   878     }
   824     }
   879 }
   825 }
   880 
       
   881     
       
   882 // End of file
   826 // End of file
   883