uifw/AvKon/src/AknQueryControl.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
--- a/uifw/AvKon/src/AknQueryControl.cpp	Tue Aug 31 15:28:30 2010 +0300
+++ b/uifw/AvKon/src/AknQueryControl.cpp	Wed Sep 01 12:16:19 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -77,8 +77,9 @@
 #include <AknTasHook.h> // for testability hooks
 #include <tacticon.h>
 
+#include "akntrace.h"
 const TInt KPinCodeTacticonInterval = 30000000; // 30s
-const TInt KPinCodeMaxTacticons = 10;
+const TInt KPinCodeMaxTacticons = 5;
 /*******
  * CAknQueryControlExtension
  */
@@ -110,12 +111,14 @@
 
 CAknQueryControlExtension::~CAknQueryControlExtension()
     {
+    _AKNTRACE_FUNC_ENTER;
     delete iOriginalPrompt;
     delete iBackspaceButton;
     delete iKeypad;
 
     delete iPinTacticonTimer;
     iPinTacticonTimer = NULL;
+    _AKNTRACE_FUNC_EXIT;
     }
     
 CAknLocationEditor *CAknQueryControl::LocationEd() const
@@ -137,10 +140,12 @@
 
 void CAknQueryExtension::CreateEditorContextL()
     {
+    _AKNTRACE_FUNC_ENTER;
     delete iEditorContext;
     iEditorContext = NULL;
     iEditorContext = CAknsFrameBackgroundControlContext::NewL(
         KAknsIIDQsnFrInput, TRect(0,0,1,1), TRect(0,0,1,1), EFalse );
+    _AKNTRACE_FUNC_EXIT;
     }
 
 CAknsFrameBackgroundControlContext* CAknQueryExtension::EditorContext()
@@ -159,19 +164,23 @@
 void CAknQueryExtension::CreateExtensionL(
     const CAknQueryControl* aQueryControl )
     {
+    _AKNTRACE_FUNC_ENTER;
     CAknQueryExtension* extension = CAknQueryExtension::NewL();
     CleanupStack::PushL( extension );
     AknsPointerStore::StorePointerL( 
         static_cast<const CBase*>(aQueryControl), extension );
     CleanupStack::Pop(); // extension
+    _AKNTRACE_FUNC_EXIT;
     }
 
 void CAknQueryExtension::DestroyExtension(
     const CAknQueryControl* aQueryControl )
     {
+    _AKNTRACE_FUNC_ENTER;
     delete Instance( aQueryControl );
     AknsPointerStore::RemovePointer( 
         static_cast<const CBase*>(aQueryControl) );
+    _AKNTRACE_FUNC_EXIT;
     }
 
 CAknQueryExtension* CAknQueryExtension::NewL()
@@ -182,6 +191,7 @@
 CAknQueryExtension::~CAknQueryExtension()
     {
     delete iEditorContext;
+    _AKNTRACE( "[%s][%s]exit", "CAknQueryExtension", "~CAknQueryExtension" );
     }
 
 /*****************************
@@ -214,17 +224,24 @@
 EXPORT_C void TAknQueryEcsObserver::HandleEcsEvent( CAknEcsDetector* /*aDetector*/,
                                                     CAknEcsDetector::TState aUpdatedState )
     {
-    TRAP_IGNORE( iParent->SetEcsCbaVisibleL( aUpdatedState == CAknEcsDetector::ECompleteMatch ) );
+	_AKNTRACE( "[%s][%s] aUpdatedState: %d", "TAknQueryEcsObserver", __FUNCTION__,aUpdatedState);
+    TRAP_IGNORE( iParent->SetEcsCbaVisibleL( aUpdatedState == CAknEcsDetector::ECompleteMatch || 
+                                             aUpdatedState == CAknEcsDetector::EServiceNumMatch ) );
     
     // Hide the emergency call number again.
     // Number should be visible only in Partial or Complete match state
     if ( aUpdatedState != CAknEcsDetector::EPartialMatch &&
-         aUpdatedState != CAknEcsDetector::ECompleteMatch  )
+         aUpdatedState != CAknEcsDetector::ECompleteMatch && 
+         aUpdatedState != CAknEcsDetector::EServiceNumMatch )
         {
         if ( iParent->QueryType() == EPinLayout )
             {
-            static_cast<CAknNumericSecretEditor*>
-                ( iParent->ControlByLayoutOrNull( EPinLayout ) )->RevealSecretText( EFalse );
+            _AKNTRACE( "[%s][%s] ", "RevealSecretText( EFalse )", __FUNCTION__);
+            if( iParent->ControlByLayoutOrNull( EPinLayout ) )
+            	{
+				static_cast<CAknNumericSecretEditor*>
+					( iParent->ControlByLayoutOrNull( EPinLayout ) )->RevealSecretText( EFalse );
+            	}
             }
         }
     
@@ -232,8 +249,10 @@
     // If the query is cancelled, the iParent is deleted!
     if ( aUpdatedState == CAknEcsDetector::ECallAttempted )
         {
+        _AKNTRACE( "[%s][%s] ", "cancel query", __FUNCTION__);
         TRAP_IGNORE( iParent->CancelQueryL() );
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -294,6 +313,7 @@
  */
 EXPORT_C CAknQueryControl::~CAknQueryControl()
     {
+	_AKNTRACE( "[%s][%s] enter", "CAknQueryControl", "~CAknQueryControl");
     AKNTASHOOK_REMOVE();
 	if (iEdwin)
         AknsUtils::DeregisterControlPosition(iEdwin);
@@ -350,6 +370,7 @@
     delete iIncreaseValueButton;
     delete iDecreaseValueButton;
 #endif //defined( RD_SCALABLE_UI_V2)
+    _AKNTRACE( "[%s][%s] exit", "CAknQueryControl", "~CAknQueryControl");
     }
 
 /**
@@ -357,9 +378,10 @@
  */
 EXPORT_C void CAknQueryControl::ConstructFromResourceL(TResourceReader &aRes)
     {
+    _AKNTRACE_FUNC_ENTER;
     // Construct extension
     CAknQueryExtension::CreateExtensionL( this );
-	iExtension = new (ELeave)CAknQueryControlExtension;
+    iExtension = new (ELeave)CAknQueryControlExtension;
     
     iEcsObserver   = new (ELeave) TAknQueryEcsObserver(this);
     iEditIndicator = CAknQueryEditIndicator::NewL(this);
@@ -403,10 +425,12 @@
             iExtension->iKeypad = CAknKeypad::NewL( *this, iQueryType );
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 void CAknQueryControl::ConstructQueryL(TResourceReader& aRes)
     {
+    _AKNTRACE( "[%s][%s] iQueryType : %d", "CAknQueryControl", "ConstructQueryL", iQueryType );
     switch(iQueryType)
         {
         case EConfirmationQueryLayout:
@@ -720,18 +744,21 @@
         {
         extension->CreateEditorContextL();
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 TInt CAknQueryControl::PinCodeTimeoutCallback( TAny* aThis )
     {
+    _AKNTRACE_FUNC_ENTER;
     // play tacticon
     static_cast<CAknQueryControl*>( aThis )->PlayPinCodeTacticon();
-    
+    _AKNTRACE_FUNC_EXIT;
     return KErrNone;
     }
 
 void CAknQueryControl::PlayPinCodeTacticon()
     {
+    _AKNTRACE_FUNC_ENTER;
     // play tacticon
     RTacticon client;
     if ( KErrNone == client.Connect() )
@@ -756,10 +783,12 @@
             StopPinCodeTacticonTimer();
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 void CAknQueryControl::ResetPinCodeTacticonTimer()
     {
+    _AKNTRACE_FUNC_ENTER;
     // stop old timer
     StopPinCodeTacticonTimer();
 
@@ -777,10 +806,12 @@
                         TCallBack( PinCodeTimeoutCallback, this ) );
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 void CAknQueryControl::StopPinCodeTacticonTimer()
     {
+    _AKNTRACE_FUNC_ENTER;
     if ( iExtension )
         {
         // delete timer
@@ -789,6 +820,7 @@
         // set the timer null, so that it will not be used again
         iExtension->iPinTacticonTimer = NULL;
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 ///
@@ -925,6 +957,7 @@
  */
 EXPORT_C TKeyResponse CAknQueryControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType) 
     {
+    _AKNTRACE( "[%s][%s] aKeyEvent.iCode :%d, aType:%d ", "CAknQueryControl", __FUNCTION__, aKeyEvent.iCode, aType);
     TKeyResponse response( EKeyWasNotConsumed );
 
     // Send key handling for emergency call support
@@ -950,6 +983,7 @@
             ResetPinCodeTacticonTimer();
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     return response;
     }
 
@@ -1109,6 +1143,7 @@
                     TBool reveal = EFalse;
                     TInt ecsState( iEcsDetector->State() );
                     if ( ( ecsState == CAknEcsDetector::ECompleteMatch ) ||
+                         ( ecsState == CAknEcsDetector::EServiceNumMatch ) ||
                          ( ecsState == CAknEcsDetector::ECompleteMatchThenSendKey ) )
                         {
                         // Further check to ensure that the matched number is the entire buffer
@@ -1117,12 +1152,14 @@
                             {
                             reveal = ETrue;
                             
-                            if ( ecsState == CAknEcsDetector::ECompleteMatch )
+                            if ( ecsState == CAknEcsDetector::ECompleteMatch || 
+                                 ecsState == CAknEcsDetector::EServiceNumMatch )
                                 {
-                                SetEcsCbaVisibleL( ETrue );                                            
+                                SetEcsCbaVisibleL( ETrue );
                                 }
                             }
                         }
+                    _AKNTRACE( "[%s][%s] iPinEdwin->RevealSecretText( %d )", "CAknQueryControl", __FUNCTION__, reveal);
                     iPinEdwin->RevealSecretText( reveal );
                     }
                 }
@@ -2531,6 +2568,7 @@
 */
 void CAknQueryControl::CancelQueryL()
     {
+    _AKNTRACE_FUNC_ENTER;
     if (iQueryControlObserver)
         {
         iQueryControlObserver->HandleQueryEditorStateEventL(this, MAknQueryControlObserver::EEmergencyCallAttempted, MAknQueryControlObserver::EEditorValueValid);
@@ -2543,6 +2581,7 @@
         key.iScanCode = EStdKeyNull;
         iEikonEnv->SimulateKeyEventL(key, EEventKey);
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 /**
@@ -2600,7 +2639,7 @@
 
 EXPORT_C void CAknQueryControl::SetImageL(CEikImage* aImage)
     { // Gets ownership of the aImage
-    
+    _AKNTRACE_FUNC_ENTER;
 	if ( iImage && iImage->IsPictureOwnedExternally() )
         {
         delete ((CApaMaskedBitmap*) iImage->Bitmap());
@@ -2618,11 +2657,13 @@
     iAnimation = NULL;
 
     Layout();
+    _AKNTRACE_FUNC_EXIT;
     }
 
 EXPORT_C void CAknQueryControl::SetImageL(const TDesC& aImageFile,
                                           TInt aBmpId, TInt aBmpMaskId)
     {
+    _AKNTRACE_FUNC_ENTER;
     CEikImage* image = new(ELeave) CEikImage;
     CleanupStack::PushL( image );
                
@@ -2653,10 +2694,12 @@
 
     CleanupStack::Pop(); //image
     SetImageL(image); // gets ownership
+    _AKNTRACE_FUNC_EXIT;
     }
 
 EXPORT_C void CAknQueryControl::SetAnimationL(TInt aResource)
     {
+    _AKNTRACE_FUNC_ENTER;
     delete iAnimation;
     iAnimation = NULL;
     iAnimation = CAknBitmapAnimation::NewL();
@@ -2677,10 +2720,12 @@
     iExtension->iAnimationId = aResource;
     
     Layout();
+    _AKNTRACE_FUNC_EXIT;
     }
 
 EXPORT_C void CAknQueryControl::StartAnimationL()
     {
+    _AKNTRACE_FUNC_ENTER;
     if (iAnimation)
         {
         CBitmapAnimClientData *animClientData = iAnimation->BitmapAnimData();
@@ -2725,15 +2770,19 @@
 
         iAnimation->StartAnimationL();
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 EXPORT_C TInt CAknQueryControl::CancelAnimation()
     {
-    if ( iAnimation )
+	_AKNTRACE_FUNC_ENTER;
+	TInt result(KErrGeneral);
+	if ( iAnimation )
         {
-        return iAnimation->CancelAnimation();
+		result = iAnimation->CancelAnimation();
         }
-    return KErrGeneral;
+	_AKNTRACE( "[%s][%s] return %d", "CAknQueryControl", "CancelAnimation", result);
+    return result;
     }
 
 
@@ -2980,13 +3029,16 @@
 // Callback for doing a redraw when animating pictographs
 TInt CAknQueryControl::StaticPictographCallBack( TAny* aPtr )
     {
+    _AKNTRACE_FUNC_ENTER;
     CAknQueryControl* me = static_cast<CAknQueryControl*>( aPtr );
     me->PictographCallBack();
+    _AKNTRACE_FUNC_EXIT;
     return KErrNone;
     }
 
 void CAknQueryControl::PictographCallBack()
     {
+    _AKNTRACE_FUNC_ENTER;
     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
 
@@ -3020,11 +3072,15 @@
             DeactivateGc();
 
             // Draw the label after the background.
-            iPrompt->Line( i )->ActivateL(); // Never leaves
-            iPrompt->Line( i )->DrawNow();
+            TRAPD(err, iPrompt->Line( i )->ActivateL()); // Never leaves
+            if (err == KErrNone)
+                {
+                iPrompt->Line( i )->DrawNow();
+                }
             iPrompt->SetLineModified( i, EFalse );
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 TBool CAknQueryControl::EmbeddedVirtualInput() const
@@ -3060,10 +3116,12 @@
     
 CEikDialog* CAknQueryControl::Dialog() const
     {
+	_AKNTRACE_FUNC_ENTER;
     CAknQueryControl* control = const_cast<CAknQueryControl*>( this );
     
     CEikDialog* dialog = NULL;
     control->MopGetObject( dialog );
+    _AKNTRACE_FUNC_EXIT;
     return dialog;
     }
    
@@ -3330,32 +3388,34 @@
 
 EXPORT_C void CAknQueryControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
     { 
-    CEikMfne* edwin = NULL;
-    if ( iTimeEdwin )
-        {
-        edwin = iTimeEdwin;
-        }        
-    else if ( iDateEdwin )
-        {
-        edwin = iDateEdwin;
-        }
-    else if ( LocationEd() )
-        {
-        edwin = LocationEd();
-        }
-    else if ( iDurationEdwin )
-        {
-        edwin = iDurationEdwin;
-        }
-        
-    if ( edwin && iEditorFrame.Rect().Contains(aPointerEvent.iPosition) )
-        {
-        edwin->HandlePointerEventL(aPointerEvent);
-        }
+    if ( iHasEditor && iEditorFrame.Valid() 
+        && iEditorFrame.Rect().Contains( aPointerEvent.iPosition ) )
+    	{
+		/*For the events happening inside editor frame's rect, query control will forward
+		the events to editors to handle.This is added to fix bug ESLM-85YFCH:Text editor is hard 
+		to open in input dialog (usability). The valid area is enlarged to editor frame rect,
+		instead of text's rect, because text rect is too small for user to tap*/
+		CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
+		if( ctrl )
+			{
+			TPointerEvent pointerEvent( aPointerEvent );
+			if( !ctrl->Rect().Contains( aPointerEvent.iPosition ) && ( NbrOfEditorLines() == 1 ) )
+				{
+				// for the pointerevents happening in editor frame rect, 
+				// query control forward events to editors after justification
+				pointerEvent.iPosition.iY = ctrl->Rect().iTl.iY + ctrl->Rect().Height()/2;
+				}
+			ctrl->HandlePointerEventL( pointerEvent ); 
+			}
+		else
+			{
+			CAknControl::HandlePointerEventL( aPointerEvent ); 
+			}
+		}
     else
-        {
-        CAknControl::HandlePointerEventL(aPointerEvent); 
-        }
+    	{
+		CAknControl::HandlePointerEventL( aPointerEvent ); 
+		}
     }
 
 EXPORT_C void* CAknQueryControl::ExtensionInterface( TUid /*aInterface*/ ) 
@@ -3365,6 +3425,7 @@
     
 EXPORT_C void CAknQueryControl::HandleResourceChange(TInt aType)
     {
+    _AKNTRACE_FUNC_ENTER;
     CCoeControl::HandleResourceChange(aType);
     
     if( aType == KAknsMessageSkinChange && iExtension->iAnimationId )
@@ -3377,6 +3438,7 @@
         SizeChanged();
         TRAP_IGNORE(DoSetPromptL());
         }
+    _AKNTRACE_FUNC_EXIT;
     }    
 
 // ---------------------------------------------------------------------------
@@ -3410,6 +3472,7 @@
 //
 void CAknQueryControl::SetEcsCbaVisibleL( TBool aVisible )
     {
+    _AKNTRACE( "[%s][%s] aVisible:%d ", "CAknQueryControl", __FUNCTION__,aVisible);
     if ( iExtension &&
          !COMPARE_BOOLS( aVisible, iExtension->iEcsCbaShown ) &&
          iFlags.IsSet( EEmergencyCallsCBASupport ) )
@@ -3444,6 +3507,7 @@
                 }
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -3453,9 +3517,11 @@
 //
 void CAknQueryControl::AttemptEmergencyCallL()
     {
+    _AKNTRACE_FUNC_ENTER;
     if ( iEcsDetector )
         {
-        if ( iEcsDetector->State() == CAknEcsDetector::ECompleteMatch )
+        if ( iEcsDetector->State() == CAknEcsDetector::ECompleteMatch || 
+             iEcsDetector->State() == CAknEcsDetector::EServiceNumMatch )
             {
             // Further check to ensure that the matched number is the
             // entire buffer. Get the matched text and see if is the same
@@ -3470,6 +3536,7 @@
                 }
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -3507,6 +3574,7 @@
 
 void CAknExtQueryControl::ConstructQueryL(TResourceReader& aRes)
     {   
+    _AKNTRACE_FUNC_ENTER;
     if ( iQueryType == EIpLayout)   
         {
         iIpEditor = new(ELeave)CAknIpFieldEditor;
@@ -3536,6 +3604,7 @@
         {
         extension->CreateEditorContextL();
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -3613,7 +3682,7 @@
 EXPORT_C void CAknExtQueryControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
     {
     //CAknQueryControl::HandleControlEventL(NULL, aEventType);
-    
+	_AKNTRACE( "[%s][%s] aEventType:%d ", "CAknExtQueryControl", "HandleControlEventL",aEventType);
     if(iQueryControlObserver && aEventType == EEventStateChanged)
         {                
         if(GetTextLength())
@@ -3625,6 +3694,7 @@
             iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorEmpty);
             }
         }
+    _AKNTRACE( "[%s][%s] EXIT ", "CAknExtQueryControl", "HandleControlEventL");
     }
 
 
@@ -3722,14 +3792,34 @@
 
 EXPORT_C void CAknExtQueryControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
     { 
-    if ( iIpEditor && iEditorFrame.Rect().Contains(aPointerEvent.iPosition) )
-        {
-        iIpEditor->HandlePointerEventL(aPointerEvent); 
-        }
-    else
-        {
-        CAknQueryControl::HandlePointerEventL(aPointerEvent);
-        }
+	if ( iHasEditor && iEditorFrame.Valid() 
+	    && iEditorFrame.Rect().Contains( aPointerEvent.iPosition ) )
+		{
+		/*For the events happening inside editor frame's rect, query control will forward
+		the events to editors to handle.This is added to fix bug ESLM-85YFCH:Text editor is hard 
+		to open in input dialog (usability). The valid area is enlarged to editor frame rect,
+		instead of text's rect, because text rect is too small for user to tap*/
+		CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
+		if( ctrl )
+			{
+			TPointerEvent pointerEvent( aPointerEvent );
+			if( !ctrl->Rect().Contains( aPointerEvent.iPosition ) && ( NbrOfEditorLines() == 1 ) )
+				{
+				// for the pointerevents happening in editor frame rect, 
+				// query control forward events to editors after justification
+				pointerEvent.iPosition.iY = ctrl->Rect().iTl.iY + ctrl->Rect().Height()/2;
+				}
+			ctrl->HandlePointerEventL( pointerEvent ); 
+			}
+		else
+			{
+			CAknControl::HandlePointerEventL( aPointerEvent ); 
+			}
+		}
+	else
+		{
+		CAknControl::HandlePointerEventL( aPointerEvent ); 
+		}
     }
 
 EXPORT_C void* CAknExtQueryControl::ExtensionInterface( TUid /*aInterface*/ ) 
@@ -3946,13 +4036,16 @@
 // Callback for doing a redraw when animating pictographs
 TInt CAknExtQueryControl::StaticPictographCallBack( TAny* aPtr )
     {
+    _AKNTRACE_FUNC_ENTER;
     CAknExtQueryControl* me = static_cast<CAknExtQueryControl*>( aPtr );
     me->PictographCallBack();
+    _AKNTRACE_FUNC_EXIT;
     return KErrNone;
     }
 
 void CAknExtQueryControl::PictographCallBack()
     {
+    _AKNTRACE_FUNC_ENTER;
     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
 
@@ -3986,11 +4079,15 @@
             DeactivateGc();
 
             // Draw the label after the background.
-            iPrompt->Line( i )->ActivateL(); // Never leaves
-            iPrompt->Line( i )->DrawNow();
+            TRAPD(err, iPrompt->Line( i )->ActivateL()); // Never leaves
+            if (err == KErrNone)
+                {
+                iPrompt->Line( i )->DrawNow();
+                }
             iPrompt->SetLineModified( i, EFalse );
             }
         }
+    _AKNTRACE_FUNC_EXIT;
     }
 
 // End of File