Revision: 201025 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 18:38:16 +0300
branchRCL_3
changeset 57 94dc1107e8b2
parent 44 3c221667e687
child 58 40a3f856b14d
Revision: 201025 Kit: 2010127
phone_plat/phone_application_commands_api/inc/phoneappcommands.hrh
phoneapp/phoneuicontrol/inc/cphonekeyeventforwarder.h
phoneapp/phoneuicontrol/inc/cphonestateidle.h
phoneapp/phoneuicontrol/src/cphonekeyeventforwarder.cpp
phoneapp/phoneuicontrol/src/cphonenumberentrymanager.cpp
phoneapp/phoneuicontrol/src/cphonestateidle.cpp
phoneapp/phoneuistates/src/cphoneemergency.cpp
phoneapp/phoneuiutils/inc/phoneloggerviewcommands.h
phoneapp/phoneuiutils/src/phoneloggerviewcommands.cpp
phoneapp/phoneuiutils/src/phoneloggerviewcommands.st
phoneapp/phoneuiview/inc/cphonemenucontroller.h
phoneapp/phoneuiview/inc/cphoneviewcontroller.h
phoneapp/phoneuiview/inc/mphoneringingtonesrv.h
phoneapp/phoneuiview/inc/phoneringingtonesrv.h
phoneapp/phoneuiview/inc/phoneringingtonesrvsession.h
phoneapp/phoneuiview/inc/phoneviewcommanddefinitions.h
phoneapp/phoneuiview/src/cphonebubblewrapper.cpp
phoneapp/phoneuiview/src/cphonedialercontroller.cpp
phoneapp/phoneuiview/src/cphonemenucontroller.cpp
phoneapp/phoneuiview/src/cphoneviewcontroller.cpp
phoneapp/phoneuiview/src/phoneringingtonesrv.cpp
phoneapp/phoneuiview/src/phoneringingtonesrvsession.cpp
phoneengine/PhoneCntFinder/ContactService/inc/CPhCntMatcherImpl.h
phoneengine/PhoneCntFinder/ContactService/inc/cphcntmatchervoipimpl.h
phoneengine/PhoneCntFinder/ContactService/src/CPhCntMatcherImpl.cpp
phoneengine/PhoneCntFinder/ContactService/src/cphcntmatchervoipimpl.cpp
phoneengine/PhoneCntFinder/ContactService/src/cphcntspeeddialimpl.cpp
phoneengine/PhoneCntFinder/ContactService/src/tphcntservicerequestparams.cpp
phoneengine/PhoneCntFinder/inc/CPhCntMatcher.h
phoneengine/PhoneCntFinder/inc/Misc/CPhCntSpeedDialMonitor.h
phoneengine/contacthandling/src/cpecontactmatch.cpp
phoneuis/BubbleManager/Group/Bubblemanager.mmp
phoneuis/BubbleManager/Inc/BMMainPaneControl.h
phoneuis/BubbleManager/Inc/telbubbleimagescaler.h
phoneuis/BubbleManager/Src/BMCallObjectManager.cpp
phoneuis/BubbleManager/Src/BMMainPaneControl.cpp
phoneuis/BubbleManager/Src/telbubbleimagescaler.cpp
phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp
phoneuis/BubbleManager/eabi/bubblemanageru.def
phoneuis/dialer/src/cdialertoolbarcontainer.cpp
phoneuis/easydialing/src/easydialingutils.cpp
--- a/phone_plat/phone_application_commands_api/inc/phoneappcommands.hrh	Mon Jun 21 15:39:45 2010 +0300
+++ b/phone_plat/phone_application_commands_api/inc/phoneappcommands.hrh	Thu Jul 15 18:38:16 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2010 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"
@@ -11,10 +11,10 @@
 *
 * Contributors:
 *
-* Description: 
+* Description:
 *     This file contains declarations for commands of PhoneAppS60.
 *     The file can be included in C++ or resource file.
-*     
+*
 *
 */
 
@@ -28,7 +28,7 @@
 //  CONSTANTS
 
 #define KPhoneCmdBase 6000
-enum 
+enum
     {
     // commands for all
     EPhoneCmdDoNothing = KPhoneCmdBase,
@@ -132,13 +132,13 @@
     EPhoneInCallCmdCancelSendingDtmfString,
     EPhoneInCallCmdContinueSendingDtmfString,
     EPhoneInCallCmdVoiceMode,
-    EPhoneInCallCmdSendToCallerMenu,    
+    EPhoneInCallCmdSendToCallerMenu,
     EPhoneInCallCmdSendNew,
     EPhoneInCallCmdSendFile,
     EPhoneInCallCmdProcessSend, // NOT IN MENU!
     EPhoneInCallCmdDrop,
     EPhoneInCallCmdPrivate,
-    EPhoneInCallCmdCbaJoin,	// NOT IN MENU!
+    EPhoneInCallCmdCbaJoin,    // NOT IN MENU!
     EPhoneInCallCmdDialer,
 
     // Enable video
@@ -160,7 +160,7 @@
     EPhoneInCallCmdNewCallCall,
     EPhoneInCallCmdGoToIdle,
     EPhoneInCallCmdParticipants,
-    
+
     // CDMA specific
     EPhoneInCallCmdMulticall3WayCall,
     EPhoneInCallCmdMulticallIgnore,
@@ -181,12 +181,12 @@
     EPhoneCmdSettingsUiExit,
     // Settings GUI - Data Parameters GUI (commands specific to DataParameters)
     EPhoneCmdDataParametersRestoreSettings,
-    EPhoneCmdRelease,	
+    EPhoneCmdRelease,
     // DTMF specific
     EPhoneCmdDtmfSearch,
     EPhoneCmdDtmfOk,
     EPhoneCmdDtmfSpeedDialOk,
-    EPhoneInCallCmdDtmfListViewSearch,    
+    EPhoneInCallCmdDtmfListViewSearch,
     // other commands
     EPhoneCmdWaitNoteOk,
     EPhoneCmdVideoCallMemoryLowNoteDismissed,
@@ -196,7 +196,7 @@
     EPhoneCmdYesSwitchToVideo,
     EPhoneCmdNoSwitchToVideo,
     EPhoneCmdYesSwitchToVoice,
-    EPhoneCmdNoSwitchToVoice,    
+    EPhoneCmdNoSwitchToVoice,
     EPhoneMediatorSetPhoneNumber,
     EPhoneCmdCoverUiShowMultimediaRingingTone,
     EPhoneInCallCmdLockKeypad,
@@ -204,17 +204,17 @@
     EPhoneCmdYesVideoFailedNoMemorySwitchToVoice,
     EPhoneCmdNoVideoFailedNoMemorySwitchToVoice,
     EPhoneInCallCmdSetVolumeLevel,
-    
+
     //Dialer commands
     EPhoneDialerCmdLog,
     EPhoneDialerCmdContacts,
-    EPhoneDialerCmdClear,  
+    EPhoneDialerCmdClear,
     EPhoneDialerCallHandling,
     EPhoneDialerCmdTouchInput,
     EPhoneDialerCmdSpeedDial,
     EPhoneDialerCmdEditText,
-    EPhoneDialerCallSettings,	
-    EPhoneDtmfDialerCancel,	
+    EPhoneDialerCallSettings,
+    EPhoneDtmfDialerCancel,
     EPhoneDtmfDialerExit,
     EPhoneIsDTMFDialerVisible,
     EPhoneDialerCmdHelp,
@@ -232,10 +232,13 @@
     EPhoneCmdBlockingDialogLaunched,
     EPhoneCmdBlockingDialogClosed,
 
+    // Update cba in case of emergency call
+    EPhoneCmdUpdateEmergencyCba,
+
     EPhoneCmdLast
     };
-    
-    
+
+
 // Command range for custom menu commands.
 // Custom commands can be used for menu extensions.
 #define KPhoneCustomCmdBase 8000
--- a/phoneapp/phoneuicontrol/inc/cphonekeyeventforwarder.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuicontrol/inc/cphonekeyeventforwarder.h	Thu Jul 15 18:38:16 2010 +0300
@@ -186,7 +186,7 @@
         /**
         * Convert key code
         */   
-        void ConvertKeyCode( TUint& aCode, const TKeyEvent& aKeyEvent ); 
+        void ConvertKeyCodeL( TUint& aCode, const TKeyEvent& aKeyEvent ); 
 
         /**
         * Handle key long press
@@ -197,7 +197,7 @@
          * Checks from the statemachine is the given keyevent 
          * one which produces a legal character in the current mode.
          */
-        TBool IsKeyAllowed( const TKeyEvent& aKeyEvent );
+        TBool IsKeyAllowedL( const TKeyEvent& aKeyEvent );
                 
         /**
          * Checks is the given key special character (*, 0, # ) from half-qwerty
@@ -297,6 +297,13 @@
          */     
         TBool iVirtualKeyBoardOpen;
         
+        
+        /**
+         * Indicates if menu or dialog was displayed
+         * when the key was pressed down.
+         */
+        TBool iDisplayingMenuOrDialogOnEventKeyDown;
+        
         /**
          * Application menu.
          * Not owned.
--- a/phoneapp/phoneuicontrol/inc/cphonestateidle.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuicontrol/inc/cphonestateidle.h	Thu Jul 15 18:38:16 2010 +0300
@@ -230,6 +230,12 @@
         */
         TBool IsBubbleInitialized();
         
+        /**
+        * Removes NE and sets idle to background, for more detailed
+        * information check comments from implementation.
+        */
+        void RemoveNumberEntryAndSetIdleToBackgroundIfNeededL();
+        
     private: // New functions
         
         /**
@@ -317,6 +323,12 @@
          TInt GetNumberAcqMenuIdL();
          
          /**
+          * Sets UI elements to correct state and launches
+          * call header to screen by calling DisplayCallSetupL.
+          */
+         void ShowCallHandlingViewL( TInt aCallId );
+         
+         /**
           * Launches initializing call bubble.
           */
          void DisplayInitializingCallL( TInt aCallId );
@@ -338,8 +350,6 @@
          void ChangeTo( TInt aState );
          
     private:
-         // indicates that incomming call is arrived.
-         TBool iIncommingCall;
         
          // Indicates call bubble is already initiliazed.
          TBool iBubbleInitialized;
--- a/phoneapp/phoneuicontrol/src/cphonekeyeventforwarder.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuicontrol/src/cphonekeyeventforwarder.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -174,7 +174,7 @@
         
         // Open number entry view if any allowed character key
         // is pressed on homescreen or in-call ui
-        if ( aType != EEventKeyUp && IsKeyAllowed( keyEvent ) )
+        if ( aType != EEventKeyUp && IsKeyAllowedL( keyEvent ) )
             {
             // Do not open number entry with up key
             iStateMachine->State()->HandleCreateNumberEntryL( keyEvent, aType );
@@ -252,13 +252,13 @@
     }
 
 // -----------------------------------------------------------------------------
-// CPhoneKeyEventForwarder::IsAlphaNumericKey
+// CPhoneKeyEventForwarder::IsKeyAllowedL
 // -----------------------------------------------------------------------------
 //
-TBool CPhoneKeyEventForwarder::IsKeyAllowed( const TKeyEvent& aKeyEvent )
+TBool CPhoneKeyEventForwarder::IsKeyAllowedL( const TKeyEvent& aKeyEvent )
     {
     __LOGMETHODSTARTEND( EPhoneControl,
-        "CPhoneKeyEventForwarder::IsAlphaNumericKey");
+        "CPhoneKeyEventForwarder::IsKeyAllowedL");
 
     TKeyEvent keyEvent( aKeyEvent );
     
@@ -428,14 +428,20 @@
     
     if ( EEventKeyUp == aType && EKeyNull != iKeyPressedDown )
         {
-        // Handle short key press
-        iStateMachine->State()->HandleKeyMessageL( 
-            MPhoneKeyEvents::EPhoneKeyShortPress, 
-            TKeyCode( iKeyPressedDown ) );
-
+		// EKeyEnter is always offered to Telephony so donīt offer it 
+		// to state if there is menu or a dialog open.
+        if ( !( EKeyEnter == iKeyPressedDown 
+                && iDisplayingMenuOrDialogOnEventKeyDown ) )
+            {
+            // Handle short key press
+            iStateMachine->State()->HandleKeyMessageL( 
+                    MPhoneKeyEvents::EPhoneKeyShortPress, 
+                    TKeyCode( iKeyPressedDown ) );
+            }
         // Reset key code
         iScanCode = EStdKeyNull;
         iKeyPressedDown = EKeyNull;
+        iDisplayingMenuOrDialogOnEventKeyDown = EFalse;
         }
 
     return EKeyWasNotConsumed;
@@ -478,7 +484,7 @@
         "CPhoneKeyEventForwarder::HandleEventKeyDownBeforeControlStackL");
 
     // Convert key code
-    ConvertKeyCode( iKeyPressedDown, aKeyEvent );
+    ConvertKeyCodeL( iKeyPressedDown, aKeyEvent );
     // Save key scan code
     iScanCode = aKeyEvent.iScanCode;
     
@@ -520,7 +526,15 @@
             this ) );
         }
 
-    return ( EKeyWasNotConsumed );
+    // Check if dialog or menu is open
+    // EikAppUi()->IsDisplayingMenuOrDialog doesnīt always return correct 
+    // value for menubar, so ask visibility also from CEikMenuBar
+    iDisplayingMenuOrDialogOnEventKeyDown = ( iViewCommandHandle->HandleCommandL(
+            EPhoneViewIsDisplayingMenuOrDialog ) == 
+            EPhoneViewResponseSuccess ) || ( iMenu && iMenu->IsDisplayed() );
+
+    // Consume dialer simulated key events, pass others on
+    return ( IsKeySimulatedByTouchDialer( aKeyEvent ) ? EKeyWasConsumed : EKeyWasNotConsumed );
     }
 
 // -----------------------------------------------------------
@@ -631,7 +645,8 @@
     // Store the previous scan code
     iPreviousScanCode = iScanCode;
 
-    return EKeyWasNotConsumed;
+    // Consume dialer simulated key events, pass others on
+    return ( IsKeySimulatedByTouchDialer( aKeyEvent ) ? EKeyWasConsumed : EKeyWasNotConsumed );
     }
 
 // ---------------------------------------------------------
@@ -699,19 +714,19 @@
     }
 
 // -----------------------------------------------------------
-// CPhoneKeyEventForwarder::ConvertKeyCode
+// CPhoneKeyEventForwarder::ConvertKeyCodeL
 // -----------------------------------------------------------
 //
-void CPhoneKeyEventForwarder::ConvertKeyCode( TUint& aCode,
+void CPhoneKeyEventForwarder::ConvertKeyCodeL( TUint& aCode,
         const TKeyEvent& aKeyEvent )
     {
     __LOGMETHODSTARTEND( EPhoneControl,
-        "CPhoneKeyEventForwarder::ConvertKeyCode");
+        "CPhoneKeyEventForwarder::ConvertKeyCodeL");
 
     // Handler for special device key mapping in case iScanCode
     // to iCode conversion hasn't been handled by CAknAppUi::GetAliasKeyCodeL
     __PHONELOG1( EBasic, EPhoneControl,
-        "CPhoneKeyEventHandler::ConvertKeyCode scan code (%d)",
+        "CPhoneKeyEventHandler::ConvertKeyCodeL scan code (%d)",
         aKeyEvent.iScanCode );
 
     if ( !ConvertHalfQwertySpecialChar( aCode, aKeyEvent ) )
@@ -743,6 +758,7 @@
                 case EStdKeyYes:
                     aCode = EKeyYes;
                     break;
+                case EStdKeyEnd: // End key is emulated if the device has combined power and end key
                 case EStdKeyNo:
                     aCode = EKeyNo;
                     break;
@@ -766,7 +782,7 @@
         }
 
     __PHONELOG1( EBasic, EPhoneControl,
-        "CPhoneKeyEventHandler::ConvertKeyCode aCode (%d)", aCode );
+        "CPhoneKeyEventHandler::ConvertKeyCodeL aCode (%d)", aCode );
     }
 
 //  End of File
--- a/phoneapp/phoneuicontrol/src/cphonenumberentrymanager.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuicontrol/src/cphonenumberentrymanager.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -67,7 +67,7 @@
      iStateMachine ( aStateMachine ),
      iCustomization ( aCustomization ),
      iCbaManager ( aCbaManager ),
-     iEnv( *CEikonEnv::Static() )
+     iEnv( *CEikonEnv::Static() ) // codescanner::eikonenvstatic
     {
     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::CPhoneNumberEntryManager() ");
     }
@@ -478,9 +478,12 @@
         const TKeyEvent& aKeyEvent ) const
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsAlphanumericSupportedAndCharInput( ) ");
-    TBool ret = ( iViewCommandHandle.HandleCommandL( EPhoneViewIsNumberEntryNumericMode ) 
-                    != EPhoneViewResponseSuccess )
-                        &&
+    
+    TBool numericMode = EFalse;
+    TRAP_IGNORE( numericMode = ( iViewCommandHandle.HandleCommandL( EPhoneViewIsNumberEntryNumericMode ) 
+            == EPhoneViewResponseSuccess ) );
+    
+    TBool ret = !numericMode &&
                 ( ( aKeyEvent.iScanCode >= KPhoneKeyStart &&
                     aKeyEvent.iScanCode <= KPhoneKeyEnd ) ||
                   aKeyEvent.iModifiers & EModifierSpecial );
--- a/phoneapp/phoneuicontrol/src/cphonestateidle.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuicontrol/src/cphonestateidle.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -76,7 +76,8 @@
     MPhoneStateMachine* aStateMachine, 
     MPhoneViewCommandHandle* aViewCommandHandle,
     MPhoneCustomization* aCustomization ) : 
-    CPhoneState( aStateMachine, aViewCommandHandle, aCustomization )
+    CPhoneState( aStateMachine, aViewCommandHandle, aCustomization ),
+    iBubbleInitialized( EFalse )
     {
     }
 
@@ -480,32 +481,45 @@
 EXPORT_C void CPhoneStateIdle::HandleDialingL( TInt aCallId )
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleDialingL( ) ");
+    if( IsBubbleInitialized() )
+        {
+        UpdateCallBubbleL( aCallId );
+        }
+    else
+        {
+        ShowCallHandlingViewL( aCallId );
+        }
+    ChangeTo( EPhoneStateCallSetup );
+    }
 
+// -----------------------------------------------------------
+// CPhoneStateIdle::ShowCallHandlingViewL
+// -----------------------------------------------------------
+//
+void CPhoneStateIdle::ShowCallHandlingViewL( TInt aCallId )
+    {
+    __LOGMETHODSTARTEND(EPhoneControl, 
+            "CPhoneStateIdle::ShowCallHandlingViewL( ) ");
     BeginUiUpdateLC();
-    
     SetNumberEntryVisibilityL(EFalse);
 
     // Show call setup buttons
     SetTouchPaneButtons( EPhoneCallSetupButtons );
-    SetTouchPaneButtonDisabled( EPhoneInCallCmdHold );    
-
+    SetTouchPaneButtonDisabled( EPhoneInCallCmdHold );
+    
     // Display call setup 
-    DisplayCallSetupL( aCallId );            
-    
+    DisplayCallSetupL( aCallId );
     EndUiUpdate();
     
     // Remove any phone dialogs if they are displayed
     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
-            
+    
     // Go to call setup state
     iCbaManager->UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
 
     SetToolbarDimming( ETrue );
-
     SetToolbarButtonLoudspeakerEnabled();
     SetToolbarButtonHandsetEnabled();
-    
-    ChangeTo( EPhoneStateCallSetup );
     }
 
 // -----------------------------------------------------------
@@ -831,12 +845,19 @@
     // Set Phone as the top application
     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
         &uidParam ); 
-    
-    if ( !UpdateCallBubbleL( aCallId ) )
+
+    if( !IsBubbleInitialized() )
         {
         // Create and Display call setup header if update was not done.
         DisplayHeaderForOutgoingCallL( aCallId );
         }
+    else 
+        {
+        /* Create and Display initializing call header, difference
+        to DisplayHeaderForOutgoingCallL is that this doesnt load 
+        CLI information to header.*/
+        DisplayHeaderForInitializingCallL( aCallId );
+        }
     }
 
 // -----------------------------------------------------------
@@ -884,40 +905,7 @@
     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageCheckEmergencyNumber );
     if ( IsBubbleInitialized() )
         {
-        BeginUiUpdateLC();
-        
-        SetNumberEntryVisibilityL(EFalse);
-        
-        // Show call setup buttons
-        SetTouchPaneButtons( EPhoneCallSetupButtons );
-        
-        // Close menu bar, if it is displayed
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
-
-        // Capture keys when the phone is dialling
-        CaptureKeysDuringCallNotificationL( ETrue );
-        
-        // Bring Phone app in the foreground
-        TPhoneCmdParamInteger uidParam;
-        uidParam.SetInteger( KUidPhoneApplication.iUid );
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
-            &uidParam );
-
-        // Set Phone as the top application
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
-            &uidParam ); 
-        
-        DisplayHeaderForInitializingCallL( aCallId );
-            
-        EndUiUpdate();
-        
-        // Remove any phone dialogs if they are displayed
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
-                
-        // Go to call setup state
-        iCbaManager->UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
-
-        SetToolbarDimming( ETrue );
+        ShowCallHandlingViewL( aCallId );
         }
     }
 
@@ -1032,12 +1020,11 @@
 // -----------------------------------------------------------
 // CPhoneStateIdle::SpeedDialL
 // -----------------------------------------------------------
-//   
+//
 EXPORT_C void CPhoneStateIdle::SpeedDialL( const TUint& aDigit, 
         TDialInitiationMethod aDialMethod )
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::SpeedDialL( ) ");
-    
     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
     
     TPhoneCmdParamSpeedDial speedDialParam;
@@ -1050,29 +1037,43 @@
     if ( NULL != phoneNumber && KNullDesC() != *phoneNumber )
         {
         DialL( *phoneNumber, speedDialParam.NumberType(), aDialMethod );
-        
-        if ( IsNumberEntryUsedL()  ) 
-            {         
-            iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
-            
-            // Set Idle background, if still idle
-            if ( iStateMachine->State() == this )
-                {
-                SetupIdleScreenInBackgroundL();
-                }
-            }
+        RemoveNumberEntryAndSetIdleToBackgroundIfNeededL();
         }
     else
         {
         // User cancelled dialog or didn't give a valid number
         SpeedDialCanceledL( aDigit );
         }
-    
     CleanupStack::PopAndDestroy( phoneNumber );
     }
 
 // -----------------------------------------------------------
-// CPhoneStateIdle:SpeedDialCanceledL
+// CPhoneStateIdle::RemoveNumberEntryAndSetIdleToBackgroundIfNeededL
+// -----------------------------------------------------------
+//
+void CPhoneStateIdle::RemoveNumberEntryAndSetIdleToBackgroundIfNeededL()
+    {
+    __LOGMETHODSTARTEND(EPhoneControl, 
+    "CPhoneStateIdle::RemoveNumberEntryAndSetIdleToBackgroundIfNeededL( ) ");
+    if ( IsNumberEntryUsedL() )
+        {
+        /*NE should be removed because if speeddial dial is interupted during
+        call setup phone should not return to NE/Dialler view.*/
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
+        
+        /*It might be possible that some async operation was ongoing and 
+        state has already in that case do not set idle to background. If 
+        there is initialized call then do not set idle to background.*/
+        if ( ( iStateMachine->State() == this ) && 
+            ( !IsBubbleInitialized() ) )
+            {
+            SetupIdleScreenInBackgroundL();
+            }
+        }
+    }
+
+// -----------------------------------------------------------
+// CPhoneStateIdle::SpeedDialCanceledL
 // -----------------------------------------------------------
 //
 EXPORT_C void CPhoneStateIdle::SpeedDialCanceledL( const TUint& aDigit )
@@ -1609,8 +1610,9 @@
     __PHONELOG1( EBasic, EPhoneControl,
             "PhoneUIControl: CPhoneStateIdle::HandleErrorL - aErrorInfo.iCallId =%d ",
             aErrorInfo.iCallId );
-    if( ( ECCPErrorNone != aErrorInfo.iErrorCode ) &&
-            IsBubbleInitialized() )
+    if( ( KErrNotFound < aErrorInfo.iCallId ) && 
+        ( ECCPErrorNone != aErrorInfo.iErrorCode ) &&
+          IsBubbleInitialized() )
         {
         HandleInitializingCallErrorL( aErrorInfo.iCallId );
         SetBubbleInitialized( EFalse );
--- a/phoneapp/phoneuistates/src/cphoneemergency.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuistates/src/cphoneemergency.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -45,8 +45,10 @@
 
 // ================= MEMBER FUNCTIONS =======================
 
+// -----------------------------------------------------------
 // C++ default constructor can NOT contain any code, that
 // might leave.
+// -----------------------------------------------------------
 //
 CPhoneEmergency::CPhoneEmergency(
     MPhoneStateMachine* aStateMachine,
@@ -62,7 +64,7 @@
 // Destructor
 // (other items were commented in a header).
 // -----------------------------------------------------------
-
+//
 CPhoneEmergency::~CPhoneEmergency()
     {
     }
@@ -183,10 +185,10 @@
                     }
                  }
             break;
-            
+
         case MEngineMonitor::EPEMessageColpNumberAvailable:
             //Don't show COLP note during emergency call.
-            break; 
+            break;
 
         default:
             CPhoneGsmInCall::HandlePhoneEngineMessageL(
@@ -551,11 +553,11 @@
             }
         }
     else if ( iStateMachine->SecurityMode()->IsAutolockEnabled()
-    	|| SimState() != EPESimUsable
-    	|| iStartupInterrupted )
+        || SimState() != EPESimUsable
+        || iStartupInterrupted )
         {
         if ( TouchCallHandlingSupported() )
-        	{
+            {
             resourceId = EPhoneCallHandlingEmergencyInCallNoOptions;
             }
         else if ( audioOutput == EPEWiredAudioAccessory || IsSwivelClosed())
@@ -581,8 +583,8 @@
             {
             resourceId = EPhoneCallHandlingEmergencyHandsetCBA;
             }
-        else if ( ( audioOutput == EPEHandset ) 
-        		&& ( btAvailable ) )
+        else if ( ( audioOutput == EPEHandset )
+                && ( btAvailable ) )
             {
             resourceId = EPhoneCallHandlingInCallBtaaCBA;
             }
@@ -643,10 +645,10 @@
             {
             if ( TouchCallHandlingSupported() )
                 {
-                CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode ); 
+                CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode );
                 }
             else if ( !iStateMachine->SecurityMode()->IsAutolockEnabled()
-            	&& SimState() == EPESimUsable )   
+                && SimState() == EPESimUsable )
                 {
                 // do base operation
                 CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode );
@@ -696,6 +698,10 @@
             DisconnectEmergencyCallL();
             break;
 
+        case EPhoneCmdUpdateEmergencyCba:
+            UpdateInCallCbaL();
+            break;
+
         default:
             commandStatus = CPhoneGsmInCall::HandleCommandL( aCommand );
             break;
@@ -768,24 +774,24 @@
     TEventCode aEventCode )
     {
     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleKeyEventL( ) ");
-    
+
     if ( TouchCallHandlingSupported() )
         {
         CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
         }
     else
         {
-		 if ( iStateMachine->SecurityMode()->IsAutolockEnabled()
-			&& CPhoneKeys::IsNumericKey( aKeyEvent, aEventCode ) )
-			{
-			// Send the key event to the phone engine
-			SendKeyEventL( aKeyEvent, aEventCode );
-			}
-		else
-			{
-			// Handle numeric keys when key events are received in idle state
-			CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
-			}
+         if ( iStateMachine->SecurityMode()->IsAutolockEnabled()
+            && CPhoneKeys::IsNumericKey( aKeyEvent, aEventCode ) )
+            {
+            // Send the key event to the phone engine
+            SendKeyEventL( aKeyEvent, aEventCode );
+            }
+        else
+            {
+            // Handle numeric keys when key events are received in idle state
+            CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
+            }
         }
     }
 
@@ -880,8 +886,8 @@
     const TPEAudioOutput audioOutput =
         iStateMachine->PhoneEngineInfo()->AudioOutput();
 
-    if ( !( TouchCallHandlingSupported() ) 
-    		&& iCallSetup && audioOutput != EPENotActive )
+    if ( !( TouchCallHandlingSupported() )
+            && iCallSetup && audioOutput != EPENotActive )
         {
         if ( audioOutput == EPELoudspeaker )
             {
@@ -951,33 +957,33 @@
 // --------------------------------------------------------------
 //
 TBool CPhoneEmergency::TouchCallHandlingSupported () const
-	{
-	if ( FeatureManager::FeatureSupported ( KFeatureIdTouchCallHandling ) )
-		{
-		return ETrue;
-		}
-	else 
-		{
-		return EFalse;
-		}
-	}
+    {
+    if ( FeatureManager::FeatureSupported ( KFeatureIdTouchCallHandling ) )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
 
 // --------------------------------------------------------------
 // CPhoneEmergency::UseEmergencyNoIhfCBA
 // --------------------------------------------------------------
 //
 TBool CPhoneEmergency::UseEmergencyNoIhfCBA( const TPEAudioOutput& aAudioOutput ) const
-	{
-	if ( !( TouchCallHandlingSupported() ) 
-		&& ( ( aAudioOutput == EPEWiredAudioAccessory ) || ( IsSwivelClosed() ) ) )
-		{
-		return ETrue;
-		}
-	else 
-		{
-		return EFalse;
-		}
-	}
+    {
+    if ( !( TouchCallHandlingSupported() )
+        && ( ( aAudioOutput == EPEWiredAudioAccessory ) || ( IsSwivelClosed() ) ) )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
 
 // --------------------------------------------------------------
 // CPhoneEmergency::UseHandsetEmergencyCBA
@@ -985,15 +991,15 @@
 //
 TBool CPhoneEmergency::UseHandsetEmergencyCBA( const TPEAudioOutput& aAudioOutput ) const
     {
-	if ( !( TouchCallHandlingSupported() ) 
-		&& ( ( aAudioOutput == EPELoudspeaker ) || ( aAudioOutput == EPEBTAudioAccessory ) ) )
-		{
-		return ETrue;
-		}
-	else 
-		{
-		return EFalse;
-		}
+    if ( !( TouchCallHandlingSupported() )
+        && ( ( aAudioOutput == EPELoudspeaker ) || ( aAudioOutput == EPEBTAudioAccessory ) ) )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
     }
 
 // --------------------------------------------------------------
--- a/phoneapp/phoneuiutils/inc/phoneloggerviewcommands.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiutils/inc/phoneloggerviewcommands.h	Thu Jul 15 18:38:16 2010 +0300
@@ -194,10 +194,10 @@
 		EPhoneViewPrivateFromConference,
 		/** EPhoneViewSelectedConfMember */
 		EPhoneViewSelectedConfMember,
+		/** EPhoneViewGetConferenceListVisibleFlag */
+		EPhoneViewGetConferenceListVisibleFlag,
 		/** EPhoneViewOpenConferenceList */
 		EPhoneViewOpenConferenceList,
-		/** EPhoneViewGetConferenceListVisibleFlag */
-		EPhoneViewGetConferenceListVisibleFlag,
 		/** EPhoneViewGetCallState */
 		EPhoneViewGetCallState,
 		/** EPhoneViewGetCallIdByState */
@@ -246,10 +246,6 @@
 		EPhoneViewSetBlockingDialogStatus,
 		/** EPhoneViewSetPhoneNumberAvailableInPhoneEngine */
 		EPhoneViewSetPhoneNumberAvailableInPhoneEngine,
-		/** EPhoneViewSetSecurityMode */
-		EPhoneViewSetSecurityMode,
-		/** EPhoneViewGetSecurityModeStatus */
-		EPhoneViewGetSecurityModeStatus,
 		/** EPhoneViewSetStatusPaneVisible */
 		EPhoneViewSetStatusPaneVisible,
 		/** EPhoneViewEnableKeyLock */
@@ -366,12 +362,12 @@
 		EPhoneViewSetVideoCallDTMFVisibilityFlag,
 		/** EPhoneViewLoadPlugins */
 		EPhoneViewLoadPlugins,
-		/** PhoneViewServiceSelection */
-		PhoneViewServiceSelection,
 		/** EPhoneViewOpenVirtualKeyBoard */
 		EPhoneViewOpenVirtualKeyBoard,
 		/** EPhoneViewUpdateNoteSoftkeys */
 		EPhoneViewUpdateNoteSoftkeys,
+		/** EPhoneViewSendAiwCommand */
+		EPhoneViewSendAiwCommand,
 		/** EPhoneViewShowCustomizedDialer */
 		EPhoneViewShowCustomizedDialer,
 		/** EPhoneViewHideCustomizedDialer */
@@ -380,6 +376,8 @@
 		EPhoneViewGetCustomizedDialerMenuResourceId,
 		/** EPhoneViewGetCustomizedDialerCbaResourceId */
 		EPhoneViewGetCustomizedDialerCbaResourceId,
+		/** EPhoneViewCipheringInfoChangePlayTone */
+		EPhoneViewCipheringInfoChangePlayTone,
 		/** EPhoneViewCreatePhoneBookServices */
 		EPhoneViewCreatePhoneBookServices,
 		/** EPhoneViewDisableKeyLockWithoutNote */
@@ -404,6 +402,8 @@
 		EPhoneViewAddContactByString,
 		/** EPhoneViewIsActiveNoteDissmissableByKeyEvent */
 		EPhoneViewIsActiveNoteDissmissableByKeyEvent,
+		/** EPhoneViewUpdateContextMenu */
+		EPhoneViewUpdateContextMenu,
 		/** EPhoneViewSetNoConnectedCalls */
 		EPhoneViewSetNoConnectedCalls,
 		/** EPhoneViewIsDTMFEditorVisible */
@@ -430,12 +430,18 @@
 		EPhoneViewGetNeedToReturnToForegroundAppStatus,
 		/** EPhoneViewSetNeedToReturnToForegroundAppStatus */
 		EPhoneViewSetNeedToReturnToForegroundAppStatus,
+		/** EPhoneViewSetConferenceAndWaitingVideo */
+		EPhoneViewSetConferenceAndWaitingVideo,
+		/** EPhoneViewLaunchMultimediaSharing */
+		EPhoneViewLaunchMultimediaSharing,
 		/** EPhoneViewGetQwertyModeObserver */
 		EPhoneViewGetQwertyModeObserver,
 		/** EPhoneViewSetIncallBubbleTrue */
 		EPhoneViewSetIncallBubbleTrue,
 		/** EPhoneViewSetIncallBubbleFalse */
 		EPhoneViewSetIncallBubbleFalse,
+		/** EPhoneViewIsDisplayingMenuOrDialog */
+		EPhoneViewIsDisplayingMenuOrDialog,
 		/** , // Don't remove this, this should always be the last in list. */
 		EPhoneAmountOfCommands
 		};
--- a/phoneapp/phoneuiutils/src/phoneloggerviewcommands.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiutils/src/phoneloggerviewcommands.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -106,8 +106,8 @@
 _STLIT8(K80, "EPhoneViewRemoveFromConference");
 _STLIT8(K81, "EPhoneViewPrivateFromConference");
 _STLIT8(K82, "EPhoneViewSelectedConfMember");
-_STLIT8(K83, "EPhoneViewOpenConferenceList");
-_STLIT8(K84, "EPhoneViewGetConferenceListVisibleFlag");
+_STLIT8(K83, "EPhoneViewGetConferenceListVisibleFlag");
+_STLIT8(K84, "EPhoneViewOpenConferenceList");
 _STLIT8(K85, "EPhoneViewGetCallState");
 _STLIT8(K86, "EPhoneViewGetCallIdByState");
 _STLIT8(K87, "EPhoneViewMoveHighLightInList");
@@ -132,85 +132,85 @@
 _STLIT8(K106, "EPhoneViewSendMessage");
 _STLIT8(K107, "EPhoneViewSetBlockingDialogStatus");
 _STLIT8(K108, "EPhoneViewSetPhoneNumberAvailableInPhoneEngine");
-_STLIT8(K109, "EPhoneViewSetSecurityMode");
-_STLIT8(K110, "EPhoneViewGetSecurityModeStatus");
-_STLIT8(K111, "EPhoneViewSetStatusPaneVisible");
-_STLIT8(K112, "EPhoneViewEnableKeyLock");
-_STLIT8(K113, "EPhoneViewLaunchFaxModem");
-_STLIT8(K114, "EPhoneViewUpdateFSW");
-_STLIT8(K115, "EPhoneViewIsQuery");
-_STLIT8(K116, "EPhoneViewBringIdleToForeground");
-_STLIT8(K117, "EPhoneViewSetIdleTopApplication");
-_STLIT8(K118, "EPhoneViewBeginUpdate");
-_STLIT8(K119, "EPhoneViewEndUpdate");
-_STLIT8(K120, "EPhoneViewSetConfrenceOptionsFlag");
-_STLIT8(K121, "EPhoneViewRemoveConferenceBubble");
-_STLIT8(K122, "EPhoneViewGetSoftRejectWindowGroupId");
-_STLIT8(K123, "EPhoneViewSetTouchPaneButtons");
-_STLIT8(K124, "EPhoneViewSetTouchPaneVisible");
-_STLIT8(K125, "EPhoneViewEnableTouchButton");
-_STLIT8(K126, "EPhoneViewDisableTouchButton");
-_STLIT8(K127, "EPhoneResetTouchButtons");
-_STLIT8(K128, "EPhoneViewGetIsConferenceInSelectionMode");
-_STLIT8(K129, "EPhoneViewIsStraightCallToVideoMailBox");
-_STLIT8(K130, "EPhoneViewSetDtmfDialerViewVisible");
-_STLIT8(K131, "EPhoneViewSetRestrictedDialer");
-_STLIT8(K132, "EPhoneViewIsConferenceInExpandedMode");
-_STLIT8(K133, "EPhoneViewIsMenuBarVisible");
-_STLIT8(K134, "EPhoneViewGetBlockingDialogStatus");
-_STLIT8(K135, "EPhoneViewYesSingleItemFetch");
-_STLIT8(K136, "EPhoneViewNoSingleItemFetch");
-_STLIT8(K137, "EPhoneViewGetLocalizedNumberFromEntry");
-_STLIT8(K138, "EPhoneViewIsNoteActive");
-_STLIT8(K139, "EPhoneViewOpenNumberEntry");
-_STLIT8(K140, "EPhoneViewOpenCallHandling");
-_STLIT8(K141, "EPhoneViewGetConferenceAndSingleFlag");
-_STLIT8(K142, "EPhoneViewSetConferenceAndSingleFlag");
-_STLIT8(K143, "EPhoneViewSetVideoCallFlag");
-_STLIT8(K144, "EPhoneViewSetDtmfOptionsFlag");
-_STLIT8(K145, "EPhoneViewShowVTSetupFailedCreateCallToSameContactQuery");
-_STLIT8(K146, "EPhoneViewGetAudioVolumeLevel");
-_STLIT8(K147, "EPhoneViewIsIdleTopApp");
-_STLIT8(K148, "EPhoneViewUpdateToolbar");
-_STLIT8(K149, "EPhoneViewSetControlAndVisibility");
-_STLIT8(K150, "EPhoneViewAllowWaitingCallHeader");
-_STLIT8(K151, "EPhoneViewBeginTransEffect");
-_STLIT8(K152, "EPhoneViewEndTransEffect");
-_STLIT8(K153, "EPhoneViewSetDialerControlVisible");
-_STLIT8(K154, "EPhoneViewCloseSingleItemFetchDialog");
-_STLIT8(K155, "EPhoneViewGetActivatePreviousApp");
-_STLIT8(K156, "EPhoneViewActivatePreviousApp");
-_STLIT8(K157, "EPhoneViewSetPointerCapture");
-_STLIT8(K158, "EPhoneViewSetSendKeyDialerActivationFlag");
-_STLIT8(K159, "EPhoneViewPrepareIcons");
-_STLIT8(K160, "EPhoneViewKeypadAudioEnabled");
-_STLIT8(K161, "EPhoneViewKeypadAudioDisabled");
-_STLIT8(K162, "EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel");
-_STLIT8(K163, "EPhoneViewRemoveDtmfNote");
-_STLIT8(K164, "EPhoneViewUpdatePhoneIconToFSW");
-_STLIT8(K165, "EPhoneViewSetEikonNotifiersDisabled");
-_STLIT8(K166, "EPhoneViewCancelAllNotications");
-_STLIT8(K167, "EPhoneViewSetVideoCallDTMFVisibilityFlag");
-_STLIT8(K168, "EPhoneViewLoadPlugins");
-_STLIT8(K169, "PhoneViewServiceSelection");
-_STLIT8(K170, "EPhoneViewOpenVirtualKeyBoard");
-_STLIT8(K171, "EPhoneViewUpdateNoteSoftkeys");
-_STLIT8(K172, "EPhoneViewShowCustomizedDialer");
-_STLIT8(K173, "EPhoneViewHideCustomizedDialer");
-_STLIT8(K174, "EPhoneViewGetCustomizedDialerMenuResourceId");
-_STLIT8(K175, "EPhoneViewGetCustomizedDialerCbaResourceId");
-_STLIT8(K176, "EPhoneViewCreatePhoneBookServices");
-_STLIT8(K177, "EPhoneViewDisableKeyLockWithoutNote");
-_STLIT8(K178, "EPhoneViewGetKeyLockStatus");
-_STLIT8(K179, "EPhoneViewSetNumberEntryObserver");
-_STLIT8(K180, "EPhoneViewGetSingleItemFetchType");
-_STLIT8(K181, "EPhoneViewRemoveGlobalWaitNote");
-_STLIT8(K182, "EPhoneViewSetPhoneCustomization");
-_STLIT8(K183, "EPhoneViewSetViewCustomization");
-_STLIT8(K184, "EPhoneViewSetButtonCustomization");
-_STLIT8(K185, "EPhoneViewUpdateContactByString");
-_STLIT8(K186, "EPhoneViewAddContactByString");
-_STLIT8(K187, "EPhoneViewIsActiveNoteDissmissableByKeyEvent");
+_STLIT8(K109, "EPhoneViewSetStatusPaneVisible");
+_STLIT8(K110, "EPhoneViewEnableKeyLock");
+_STLIT8(K111, "EPhoneViewLaunchFaxModem");
+_STLIT8(K112, "EPhoneViewUpdateFSW");
+_STLIT8(K113, "EPhoneViewIsQuery");
+_STLIT8(K114, "EPhoneViewBringIdleToForeground");
+_STLIT8(K115, "EPhoneViewSetIdleTopApplication");
+_STLIT8(K116, "EPhoneViewBeginUpdate");
+_STLIT8(K117, "EPhoneViewEndUpdate");
+_STLIT8(K118, "EPhoneViewSetConfrenceOptionsFlag");
+_STLIT8(K119, "EPhoneViewRemoveConferenceBubble");
+_STLIT8(K120, "EPhoneViewGetSoftRejectWindowGroupId");
+_STLIT8(K121, "EPhoneViewSetTouchPaneButtons");
+_STLIT8(K122, "EPhoneViewSetTouchPaneVisible");
+_STLIT8(K123, "EPhoneViewEnableTouchButton");
+_STLIT8(K124, "EPhoneViewDisableTouchButton");
+_STLIT8(K125, "EPhoneResetTouchButtons");
+_STLIT8(K126, "EPhoneViewGetIsConferenceInSelectionMode");
+_STLIT8(K127, "EPhoneViewIsStraightCallToVideoMailBox");
+_STLIT8(K128, "EPhoneViewSetDtmfDialerViewVisible");
+_STLIT8(K129, "EPhoneViewSetRestrictedDialer");
+_STLIT8(K130, "EPhoneViewIsConferenceInExpandedMode");
+_STLIT8(K131, "EPhoneViewIsMenuBarVisible");
+_STLIT8(K132, "EPhoneViewGetBlockingDialogStatus");
+_STLIT8(K133, "EPhoneViewYesSingleItemFetch");
+_STLIT8(K134, "EPhoneViewNoSingleItemFetch");
+_STLIT8(K135, "EPhoneViewGetLocalizedNumberFromEntry");
+_STLIT8(K136, "EPhoneViewIsNoteActive");
+_STLIT8(K137, "EPhoneViewOpenNumberEntry");
+_STLIT8(K138, "EPhoneViewOpenCallHandling");
+_STLIT8(K139, "EPhoneViewGetConferenceAndSingleFlag");
+_STLIT8(K140, "EPhoneViewSetConferenceAndSingleFlag");
+_STLIT8(K141, "EPhoneViewSetVideoCallFlag");
+_STLIT8(K142, "EPhoneViewSetDtmfOptionsFlag");
+_STLIT8(K143, "EPhoneViewShowVTSetupFailedCreateCallToSameContactQuery");
+_STLIT8(K144, "EPhoneViewGetAudioVolumeLevel");
+_STLIT8(K145, "EPhoneViewIsIdleTopApp");
+_STLIT8(K146, "EPhoneViewUpdateToolbar");
+_STLIT8(K147, "EPhoneViewSetControlAndVisibility");
+_STLIT8(K148, "EPhoneViewAllowWaitingCallHeader");
+_STLIT8(K149, "EPhoneViewBeginTransEffect");
+_STLIT8(K150, "EPhoneViewEndTransEffect");
+_STLIT8(K151, "EPhoneViewSetDialerControlVisible");
+_STLIT8(K152, "EPhoneViewCloseSingleItemFetchDialog");
+_STLIT8(K153, "EPhoneViewGetActivatePreviousApp");
+_STLIT8(K154, "EPhoneViewActivatePreviousApp");
+_STLIT8(K155, "EPhoneViewSetPointerCapture");
+_STLIT8(K156, "EPhoneViewSetSendKeyDialerActivationFlag");
+_STLIT8(K157, "EPhoneViewPrepareIcons");
+_STLIT8(K158, "EPhoneViewKeypadAudioEnabled");
+_STLIT8(K159, "EPhoneViewKeypadAudioDisabled");
+_STLIT8(K160, "EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel");
+_STLIT8(K161, "EPhoneViewRemoveDtmfNote");
+_STLIT8(K162, "EPhoneViewUpdatePhoneIconToFSW");
+_STLIT8(K163, "EPhoneViewSetEikonNotifiersDisabled");
+_STLIT8(K164, "EPhoneViewCancelAllNotications");
+_STLIT8(K165, "EPhoneViewSetVideoCallDTMFVisibilityFlag");
+_STLIT8(K166, "EPhoneViewLoadPlugins");
+_STLIT8(K167, "EPhoneViewOpenVirtualKeyBoard");
+_STLIT8(K168, "EPhoneViewUpdateNoteSoftkeys");
+_STLIT8(K169, "EPhoneViewSendAiwCommand");
+_STLIT8(K170, "EPhoneViewShowCustomizedDialer");
+_STLIT8(K171, "EPhoneViewHideCustomizedDialer");
+_STLIT8(K172, "EPhoneViewGetCustomizedDialerMenuResourceId");
+_STLIT8(K173, "EPhoneViewGetCustomizedDialerCbaResourceId");
+_STLIT8(K174, "EPhoneViewCipheringInfoChangePlayTone");
+_STLIT8(K175, "EPhoneViewCreatePhoneBookServices");
+_STLIT8(K176, "EPhoneViewDisableKeyLockWithoutNote");
+_STLIT8(K177, "EPhoneViewGetKeyLockStatus");
+_STLIT8(K178, "EPhoneViewSetNumberEntryObserver");
+_STLIT8(K179, "EPhoneViewGetSingleItemFetchType");
+_STLIT8(K180, "EPhoneViewRemoveGlobalWaitNote");
+_STLIT8(K181, "EPhoneViewSetPhoneCustomization");
+_STLIT8(K182, "EPhoneViewSetViewCustomization");
+_STLIT8(K183, "EPhoneViewSetButtonCustomization");
+_STLIT8(K184, "EPhoneViewUpdateContactByString");
+_STLIT8(K185, "EPhoneViewAddContactByString");
+_STLIT8(K186, "EPhoneViewIsActiveNoteDissmissableByKeyEvent");
+_STLIT8(K187, "EPhoneViewUpdateContextMenu");
 _STLIT8(K188, "EPhoneViewSetNoConnectedCalls");
 _STLIT8(K189, "EPhoneViewIsDTMFEditorVisible");
 _STLIT8(K190, "EPhoneViewSetToolbarDimming");
@@ -224,10 +224,13 @@
 _STLIT8(K198, "EPhoneViewGetEasyDialingCbaId");
 _STLIT8(K199, "EPhoneViewGetNeedToReturnToForegroundAppStatus");
 _STLIT8(K200, "EPhoneViewSetNeedToReturnToForegroundAppStatus");
-_STLIT8(K201, "EPhoneViewGetQwertyModeObserver");
-_STLIT8(K202, "EPhoneViewSetIncallBubbleTrue");
-_STLIT8(K203, "EPhoneViewSetIncallBubbleFalse");
-_STLIT8(K204, ", // Don't remove this, this should always be the last in list.");
+_STLIT8(K201, "EPhoneViewSetConferenceAndWaitingVideo");
+_STLIT8(K202, "EPhoneViewLaunchMultimediaSharing");
+_STLIT8(K203, "EPhoneViewGetQwertyModeObserver");
+_STLIT8(K204, "EPhoneViewSetIncallBubbleTrue");
+_STLIT8(K205, "EPhoneViewSetIncallBubbleFalse");
+_STLIT8(K206, "EPhoneViewIsDisplayingMenuOrDialog");
+_STLIT8(K207, ", // Don't remove this, this should always be the last in list.");
 
 // Intermediate
 const void * const KStringPointers[] =
@@ -435,8 +438,11 @@
 	(const void*)&K201,
 	(const void*)&K202,
 	(const void*)&K203,
-	(const void*)&K204
+	(const void*)&K204,
+	(const void*)&K205,
+	(const void*)&K206,
+	(const void*)&K207
 	};
 
-const TStringTable PhoneLoggerviewCommands::Table = {204, KStringPointers, EFalse};
+const TStringTable PhoneLoggerviewCommands::Table = {207, KStringPointers, EFalse};
 
--- a/phoneapp/phoneuiutils/src/phoneloggerviewcommands.st	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiutils/src/phoneloggerviewcommands.st	Thu Jul 15 18:38:16 2010 +0300
@@ -82,8 +82,8 @@
 EPhoneViewRemoveFromConference EPhoneViewRemoveFromConference
 EPhoneViewPrivateFromConference EPhoneViewPrivateFromConference
 EPhoneViewSelectedConfMember EPhoneViewSelectedConfMember
+EPhoneViewGetConferenceListVisibleFlag EPhoneViewGetConferenceListVisibleFlag
 EPhoneViewOpenConferenceList EPhoneViewOpenConferenceList
-EPhoneViewGetConferenceListVisibleFlag EPhoneViewGetConferenceListVisibleFlag
 EPhoneViewGetCallState EPhoneViewGetCallState
 EPhoneViewGetCallIdByState EPhoneViewGetCallIdByState
 EPhoneViewMoveHighLightInList EPhoneViewMoveHighLightInList
@@ -108,8 +108,6 @@
 EPhoneViewSendMessage EPhoneViewSendMessage
 EPhoneViewSetBlockingDialogStatus EPhoneViewSetBlockingDialogStatus
 EPhoneViewSetPhoneNumberAvailableInPhoneEngine EPhoneViewSetPhoneNumberAvailableInPhoneEngine
-EPhoneViewSetSecurityMode EPhoneViewSetSecurityMode
-EPhoneViewGetSecurityModeStatus EPhoneViewGetSecurityModeStatus
 EPhoneViewSetStatusPaneVisible EPhoneViewSetStatusPaneVisible
 EPhoneViewEnableKeyLock EPhoneViewEnableKeyLock
 EPhoneViewLaunchFaxModem EPhoneViewLaunchFaxModem
@@ -168,13 +166,14 @@
 EPhoneViewCancelAllNotications EPhoneViewCancelAllNotications
 EPhoneViewSetVideoCallDTMFVisibilityFlag EPhoneViewSetVideoCallDTMFVisibilityFlag
 EPhoneViewLoadPlugins EPhoneViewLoadPlugins
-PhoneViewServiceSelection PhoneViewServiceSelection
 EPhoneViewOpenVirtualKeyBoard EPhoneViewOpenVirtualKeyBoard
 EPhoneViewUpdateNoteSoftkeys EPhoneViewUpdateNoteSoftkeys
+EPhoneViewSendAiwCommand EPhoneViewSendAiwCommand
 EPhoneViewShowCustomizedDialer EPhoneViewShowCustomizedDialer
 EPhoneViewHideCustomizedDialer EPhoneViewHideCustomizedDialer
 EPhoneViewGetCustomizedDialerMenuResourceId EPhoneViewGetCustomizedDialerMenuResourceId
 EPhoneViewGetCustomizedDialerCbaResourceId EPhoneViewGetCustomizedDialerCbaResourceId
+EPhoneViewCipheringInfoChangePlayTone EPhoneViewCipheringInfoChangePlayTone
 EPhoneViewCreatePhoneBookServices EPhoneViewCreatePhoneBookServices
 EPhoneViewDisableKeyLockWithoutNote EPhoneViewDisableKeyLockWithoutNote
 EPhoneViewGetKeyLockStatus EPhoneViewGetKeyLockStatus
@@ -187,6 +186,7 @@
 EPhoneViewUpdateContactByString EPhoneViewUpdateContactByString
 EPhoneViewAddContactByString EPhoneViewAddContactByString
 EPhoneViewIsActiveNoteDissmissableByKeyEvent EPhoneViewIsActiveNoteDissmissableByKeyEvent
+EPhoneViewUpdateContextMenu EPhoneViewUpdateContextMenu
 EPhoneViewSetNoConnectedCalls EPhoneViewSetNoConnectedCalls
 EPhoneViewIsDTMFEditorVisible EPhoneViewIsDTMFEditorVisible
 EPhoneViewSetToolbarDimming EPhoneViewSetToolbarDimming
@@ -200,7 +200,10 @@
 EPhoneViewGetEasyDialingCbaId EPhoneViewGetEasyDialingCbaId
 EPhoneViewGetNeedToReturnToForegroundAppStatus EPhoneViewGetNeedToReturnToForegroundAppStatus
 EPhoneViewSetNeedToReturnToForegroundAppStatus EPhoneViewSetNeedToReturnToForegroundAppStatus
+EPhoneViewSetConferenceAndWaitingVideo EPhoneViewSetConferenceAndWaitingVideo
+EPhoneViewLaunchMultimediaSharing EPhoneViewLaunchMultimediaSharing
 EPhoneViewGetQwertyModeObserver EPhoneViewGetQwertyModeObserver
 EPhoneViewSetIncallBubbleTrue EPhoneViewSetIncallBubbleTrue
 EPhoneViewSetIncallBubbleFalse EPhoneViewSetIncallBubbleFalse
+EPhoneViewIsDisplayingMenuOrDialog EPhoneViewIsDisplayingMenuOrDialog
 EPhoneAmountOfCommands, // Don't remove this, this should always be the last in list.
--- a/phoneapp/phoneuiview/inc/cphonemenucontroller.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/cphonemenucontroller.h	Thu Jul 15 18:38:16 2010 +0300
@@ -159,6 +159,8 @@
         void ShowTaskSwapper( TInt aResourceId ) const;
         
         TBool IsSwivelClosed() const;
+        
+        TBool IsQwertyMode() const;
     
     private:
         CEikMenuBar* iMenu;
--- a/phoneapp/phoneuiview/inc/cphoneviewcontroller.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/cphoneviewcontroller.h	Thu Jul 15 18:38:16 2010 +0300
@@ -260,31 +260,31 @@
          * From base class MNumberEntryObserver
          * Indication that numberentry state changed
          */
-        void NumberEntryStateChanged( TBool aEntryHasText );    
+        void NumberEntryStateChanged( TBool aEntryHasText );
 
 // From MPhoneSecurityModeChangeObserver
 
-		IMPORT_C void HandleSecurityModeChanged( TBool aIsEnabled );
-		
-		/**
+        IMPORT_C void HandleSecurityModeChanged( TBool aIsEnabled );
+
+        /**
         * Sets incall small bubbleīs visibility in special cases.
-        */ 
-		void AllowInCallBubbleInSpecialCases();
-		
-		/**
+        */
+        void AllowInCallBubbleInSpecialCases();
+
+        /**
         * Sets value for incall bubble visibility.
-        */ 
-		void SetIncallBubbleVisibility( TBool aIncallBubbleVisible );
+        */
+        void SetIncallBubbleVisibility( TBool aIncallBubbleVisible );
 
     private:     // New functions
 
-		/**
-		 * Set security mode
-		 *
-		 * @param aMode ETrue if mode should be set enabled.
-		 */
-    	void SetSecurityMode( TBool aMode );
-    	
+        /**
+         * Set security mode
+         *
+         * @param aMode ETrue if mode should be set enabled.
+         */
+        void SetSecurityMode( TBool aMode );
+
         /**
         * read IdleApplicationUid from PubSub
         */
@@ -526,7 +526,7 @@
         * @return Phone number's type
         */
         TPhoneNumberType ConvertNumberTypeFromSpeedDialFieldInfo(
-            CPhCntSpeedDialMonitor::TSpdDialFieldInfo aFieldInfo );
+            const CPhCntSpeedDialMonitor::TSpdDialFieldInfo& aFieldInfo  );
 
         /**
         * Open the Unified message editor and get
@@ -586,7 +586,7 @@
         /**
         * Handles transition effect.
         */
-        void HandleTransitionEffect( TPhoneTransEffectType aType, 
+        void HandleTransitionEffect( TPhoneTransEffectType aType,
                 const TUid& aAppUidEffectParam = KUidPhoneApplication );
 
         /**
@@ -633,15 +633,15 @@
         TInt SingleItemFetchType() const;
 
         /**
-         * Checks if DTMF dialer mode is currently active        
+         * Checks if DTMF dialer mode is currently active
          */
         TBool IsDtmfDialerActive() const;
-        
+
         /**
-         * Checks if custom dialer mode is currently active        
+         * Checks if custom dialer mode is currently active
          */
         TBool IsCustomDialerActive() const;
-        
+
         /**
         * Checks if the effect could and should be triggered.
         */
@@ -659,14 +659,19 @@
         * Complete transition effect.
         */
         void EndTransEffect();
-        
+
         /**
          * TCleanupOperation to call EndTransEffect, if leave occurs
          * after BeginTransEffectForAppStartFromDialerLC.
          */
         static void EffectCleanup(TAny* aThis );
-        
-    private: 
+
+        /**
+         * Checks if emergency call is ongoing.
+         */
+        TBool IsEmergencyCallOngoing();
+
+    private:
         /**
          * Called by the skin server when skin content is changed and the
          * connected client wants to be informed.
@@ -692,12 +697,12 @@
          */
          void SkinPackageChanged(
              const TAknsSkinStatusPackageChangeReason aReason );
-        
+
     private:    // Data
 
         CPhoneView* iPhoneView;
 
-		CPhoneDialerView* iDialerView;
+        CPhoneDialerView* iDialerView;
 
         // iCba
         CEikButtonGroupContainer* iCba;
@@ -712,16 +717,16 @@
 
         // Controls the touch buttons
         CPhoneDialerController* iDialerController;
-        
+
         // Controls touch dialer in DTMF mode
         CPhoneDtmfDialerController* iDtmfDialerController;
-        
+
         // Controls the toolbar
         CPhoneToolbarController* iToolbarController;
 
         // Handles easydialing commands. Owned.
         CPhoneEasyDialingController* iEasyDialingController;
-        
+
         // For accessing incall indicator
         CPhoneIncallIndicator* iIncallIndicator;
 
@@ -736,7 +741,7 @@
         CPhoneApplicationExit* iApplicationExit;
 
         CPhoneAudioController* iAudioController;
-        
+
         CPhoneRingingTonePlayerAO* iRingingTonePlayerAO;
 
         // EikEnv for CPhoneKeyCaptureController, CPhoneNoteController,
@@ -830,18 +835,18 @@
         TInt iPrevious;
 
         TBool iPriotityChanged;
-		
-		/**
-		 * Internal flag to define if security mode is enabled.
-		 */
+
+        /**
+         * Internal flag to define if security mode is enabled.
+         */
         TBool iSecurityMode;
-        
+
         // Boolean flag. ETrue if the application needs to return
         // to the foreground after call ended
         TBool iNeedToReturnToForegroundAppAfterCall;
-        
+
         CAknIncallBubble* iIncallBubble;
-        
+
         // Server wich sends events about background image changes
         RAknsSrvSession iSkinServerSession;
     };
--- a/phoneapp/phoneuiview/inc/mphoneringingtonesrv.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/mphoneringingtonesrv.h	Thu Jul 15 18:38:16 2010 +0300
@@ -24,14 +24,14 @@
     {
 public:
     /**
-    * Increments sessions.
+    * Start session.
     */
-    virtual void IncrementSessions() = 0;
+    virtual TInt StartSession() = 0;
 
     /**
-    * Decrements sessions.
+    * Close session.
     */
-    virtual void DecrementSessions() = 0;
+    virtual void CloseSession() = 0;
 
     // Ringing tone settings
     
--- a/phoneapp/phoneuiview/inc/phoneringingtonesrv.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/phoneringingtonesrv.h	Thu Jul 15 18:38:16 2010 +0300
@@ -51,14 +51,14 @@
     ~CPhoneRingingToneServer();
 
     /**
-    * Increments sessions.
+    * Start session.
     */
-    void IncrementSessions();
+    TInt StartSession();
 
     /**
-    * Decrements sessions.
+    * Close session.
     */
-    void DecrementSessions();
+    void CloseSession();
 
     /**
     * Thread entry function.
@@ -180,8 +180,8 @@
     // File server connection
     RFs iFs;
 
-    // Number of active sessions
-    TInt iSessionCount;
+    // Indicates is session already in use
+    TBool iSessionInUse;
 
     // Player active object
     CPhoneRingingToneSrvPlayerAO* iPlayer;
--- a/phoneapp/phoneuiview/inc/phoneringingtonesrvsession.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/phoneringingtonesrvsession.h	Thu Jul 15 18:38:16 2010 +0300
@@ -58,6 +58,8 @@
 private:
     // Server.
     MPhoneRingingToneServer& iServer;
+
+    TInt iStartSession;
     };
 
 #endif
--- a/phoneapp/phoneuiview/inc/phoneviewcommanddefinitions.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/inc/phoneviewcommanddefinitions.h	Thu Jul 15 18:38:16 2010 +0300
@@ -235,6 +235,7 @@
     EPhoneViewGetQwertyModeObserver,
     EPhoneViewSetIncallBubbleTrue,
     EPhoneViewSetIncallBubbleFalse,
+    EPhoneViewIsDisplayingMenuOrDialog,
 
     EPhoneAmountOfCommands, // Don't remove this, this should always be the last in list.
 };
--- a/phoneapp/phoneuiview/src/cphonebubblewrapper.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/cphonebubblewrapper.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -336,7 +336,7 @@
             // 3. Thumbnail
             if ( callHeaderParam->Thumbnail() )
                 {
-                iBubbleManager->SetCallObjectImage( bubble, callHeaderParam->Thumbnail(), NULL );
+                iBubbleManager->SetThumbnail( bubble, callHeaderParam->Thumbnail(), NULL );
                 }
             }
         else if ( iCallTheme->CallImageThemeSettings() == 2 )
@@ -609,7 +609,7 @@
                 "CPhoneBubbleWrapper::SetCallHeaderParameters()-> Set 3.Thumbnail");
             if ( aCallHeaderParam->Thumbnail() )
                 {
-                iBubbleManager->SetCallObjectImage( aBubble, aCallHeaderParam->Thumbnail(), NULL );
+                iBubbleManager->SetThumbnail( aBubble, aCallHeaderParam->Thumbnail(), NULL );
                 }
             }
         else
--- a/phoneapp/phoneuiview/src/cphonedialercontroller.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/cphonedialercontroller.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -132,7 +132,7 @@
         EAknsMinorGenericQgnIndiDialerClear,
         EMbmPhoneuiQgn_indi_dialer_clear,
         EMbmPhoneuiQgn_indi_dialer_clear_mask,
-        R_PHONEUI_DIALER_TOOLTIP_CLEAR
+        0   //no tooltip for clear key
         }
     };
 static const TInt KClearButtonDataTableCount = 
@@ -491,7 +491,15 @@
         const TDesC& aMifFile ) const
     {
     // Create tooltip text
-    HBufC* tooltip = StringLoader::LoadLC( aSourceData.iTooltipResourceId );
+    HBufC* tooltip = NULL;
+    if ( aSourceData.iTooltipResourceId > 0 )
+        {
+        tooltip = StringLoader::LoadLC( aSourceData.iTooltipResourceId );
+        }
+    else
+        {
+        tooltip = HBufC::NewLC(0);
+        }
     
     // Create icon
     TAknsItemID skinId = { EAknsMajorGeneric, aSourceData.iSkinItemIdMinor };
--- a/phoneapp/phoneuiview/src/cphonemenucontroller.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/cphonemenucontroller.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -40,7 +40,7 @@
 #include <phoneappvoipcommands.hrh>
 #include <phoneui.rsg>
 #include <telephonyvariant.hrh>
-
+#include <AvkonInternalCRKeys.h>
 #include <hwrmdomainpskeys.h>
 
 #include <AiwServiceHandler.h>
@@ -175,6 +175,15 @@
 
     } 
 
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+TBool CPhoneMenuController::IsQwertyMode() const
+    {
+    return CPhonePubSubProxy::Instance()->Value(
+                    KCRUidAvkon, 
+                    KAknQwertyInputModeActive );
+    } 
 // ---------------------------------------------------------
 // CPhoneMenuController::DynInitMenuBar
 // ---------------------------------------------------------
@@ -522,7 +531,8 @@
                 break;
             case EPhoneDialerCmdTouchInput:
                 {
-                if ( !FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
+                if ( !FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ||
+                     IsQwertyMode() )
                     {
                     menuPane->DeleteMenuItem( menuItemArray[i] );      
                     }
--- a/phoneapp/phoneuiview/src/cphoneviewcontroller.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/cphoneviewcontroller.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -187,7 +187,7 @@
     iAppui = (CAknAppUi*)iEikEnv.EikAppUi();
     iCba = iEikEnv.AppUiFactory()->Cba();
 
-	iPhoneView = CPhoneView::NewL( aRect, *iCba, this );
+    iPhoneView = CPhoneView::NewL( aRect, *iCba, this );
 
     iBubbleWrapper = CPhoneBubbleWrapper::NewL( iPhoneView, aRect  );
 
@@ -224,7 +224,7 @@
         iEikEnv.WsSession().FindWindowGroupIdentifier( 0, KPhoneEikonServer ) );
 
     CCoeEnv* coeEnv = CCoeEnv::Static();
-    
+
     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
         {
         iButtonsController = CPhoneButtonsController::NewL( iBubbleWrapper->TouchPane() );
@@ -249,13 +249,13 @@
         // Finalise dialer view
         iDialerView->SetControl( iDialer );
         iDialerView->ActivateL();
-        
+
         // Create controller for Easy Dialing
         iEasyDialingController = CPhoneEasyDialingController::NewL( *iDialer );
         iDialerController->SetEasyDialingController( iEasyDialingController );
-        
+
         // Create controller for DTMF mode of the dialer
-        iDtmfDialerController = CPhoneDtmfDialerController::NewL( iBubbleWrapper, 
+        iDtmfDialerController = CPhoneDtmfDialerController::NewL( iBubbleWrapper,
                                                                   *coeEnv );
         }
 
@@ -264,9 +264,9 @@
     // if you are using sgc-client's session to capserver,
     //you are not allowed to close the session.
     iAknUiServerClient = CAknSgcClient::AknSrv();
-    
+
     iIncallBubble = CAknIncallBubble::NewL();
-    
+
     User::LeaveIfError( iSkinServerSession.Connect( this ) );
     }
 
@@ -294,7 +294,7 @@
     __LOGMETHODSTARTEND( EPhoneUIView,
                         "CPhoneViewController::~CPhoneViewController()" );
     iSkinServerSession.Close();
-    
+
     delete iButtonsController;
     delete iDialerController;
     delete iToolbarController;
@@ -326,10 +326,10 @@
             }
         delete iDialerView;
         }
-		
-	delete iEasyDialingController;
-	delete iDtmfDialerController;
-		
+
+    delete iEasyDialingController;
+    delete iDtmfDialerController;
+
     delete iDialer;
     if ( iSingleItemFetch )
         {
@@ -342,7 +342,7 @@
 //    delete iStatusPane; <-- CCoeStatic are destroyed outside application
 
     iApaLsSession.Close();
-    
+
     delete iIncallBubble;
     }
 
@@ -380,12 +380,12 @@
                 SetControltoCallHandlingL();
                 iBubbleWrapper->RemoveNumberEntry();
                 iPhoneView->SetActivatePreviousApp( EFalse );
-                
+
                 TPhoneCmdParamCallStateData callStateData;
                 callStateData.SetCallState( EPEStateConnected );
                 iBubbleWrapper->GetCallIdByState( &callStateData );
                 TInt connected = callStateData.CallId();
-                    
+
                 // If video call
                 if( connected == KVideoTelephonyCallId1 ||
                         connected == KVideoTelephonyCallId2 )
@@ -445,7 +445,7 @@
         case EPhoneViewRemovePhoneDialogs:
             RemovePhoneDialogsL();
             break;
-            
+
         case EPhoneViewRemoveAllCallHeaders:
             iBubbleWrapper->RemoveAllCallHeadersL();
             break;
@@ -457,7 +457,7 @@
         case EPhoneViewStopRingTone:
             iRingingTonePlayerAO->StopPlaying();
             break;
-            
+
         case EPhoneViewMuteRingTone:
             iRingingTonePlayerAO->MuteRingingTone();
             break;
@@ -642,7 +642,7 @@
             {
             iToolbarController->HideToolbar();
             }
-            break;  
+            break;
 
         case EPhoneViewLaunchMultimediaSharing:
             {
@@ -741,9 +741,10 @@
             break;
 
         case EPhoneViewUpdateContextMenu:
-            {     
-            iMenuController->SetContextMenu( aCommandParam );     
-            } break; 
+            {
+            iMenuController->SetContextMenu( aCommandParam );
+            }
+            break;
 
         case EPhoneViewGetLocalizedNumberFromEntry:
             iBubbleWrapper->GetLocalizedNumberEntryContent( aCommandParam );
@@ -906,7 +907,7 @@
             iMenuController->CloseMenuBar();
             iIncallIndicator->Update( aCommandParam );
             iMenuController->SetCallInProgressFlag( aCommandParam );
-            iToolbarController->SetCallInProgressFlag( aCommandParam );            
+            iToolbarController->SetCallInProgressFlag( aCommandParam );
             break;
 
         case EPhoneViewStartCapturingKey:
@@ -1186,11 +1187,11 @@
             iToolbarController->DimToolbar( booleanParam->Boolean());
             break;
             }
-            
+
         case EPhoneViewSetInvalidCsPhoneNumberFlag:
             iMenuController->SetInvalidCsPhoneNumberFlag( aCommandParam );
             break;
-                
+
         case EPhoneViewGetInvalidCsPhoneNumberFlag:
             iMenuController->GetInvalidCsPhoneNumberFlag( aCommandParam );
             break;
@@ -1206,7 +1207,7 @@
             TPhoneCmdParamBoolean*  booleanParam =
                             static_cast<TPhoneCmdParamBoolean*>( aCommandParam );
             iMenuController->SetConferenceAndWaitingVideoFlag( booleanParam->Boolean() );
-			}
+            }
             break;
         default:
             __PHONELOG( EBasic, EPhonePhoneapp,
@@ -1499,7 +1500,7 @@
                 }
             }
             break;
-			
+
         case EPhoneViewEnableToolbarButton:
             {
             TPhoneCmdParamInteger*  integerParam =
@@ -1507,7 +1508,7 @@
             iToolbarController->SetToolbarButtonDimmed( integerParam->Integer(), EFalse );
             }
             break;
-            
+
         case EPhoneViewGetQwertyModeObserver:
             {
             TPhoneCmdParamPointer* ptrParam = static_cast<TPhoneCmdParamPointer*>( aCommandParam );
@@ -1603,7 +1604,7 @@
                 EPhoneViewResponseSuccess :
                 EPhoneViewResponseFailed;
             break;
-            
+
         case EPhoneViewIsMenuBarVisible:
             viewResponse = iMenuController->IsMenuBarVisible() ?
                 EPhoneViewResponseSuccess :
@@ -1634,7 +1635,7 @@
             EndTransEffect();
             }
             break;
-            
+
         case EPhoneDialerCmdContacts:
             {
             // Launch Phonebook application
@@ -1644,7 +1645,7 @@
             ExecuteCommandL( EPhoneViewActivateApp, &appInfoParam );
             EndTransEffect();
             }
-            break;           
+            break;
 
         case EPhoneDialerCmdSpeedDial:
             {
@@ -1654,7 +1655,7 @@
             ExecuteCommandL( EPhoneViewActivateApp, &appInfoParam );
             break;
             }
-            
+
         case EPhoneDialerCallSettings:
             {
             CGSLauncher* launcher = CGSLauncher::NewLC();
@@ -1664,7 +1665,7 @@
             CleanupStack::PopAndDestroy( launcher );
             break;
             }
-            
+
         case EPhoneViewIsDTMFEditorVisible:
             if ( iDialer )
                 {
@@ -1679,7 +1680,7 @@
                     EPhoneViewResponseFailed;
                 }
             break;
-            
+
         case EPhoneViewIsConferenceInExpandedMode:
             viewResponse = iBubbleWrapper->IsConferenceInExpandedMode() ?
                 EPhoneViewResponseSuccess :
@@ -1705,18 +1706,18 @@
                 // Set Number Entry CBA
                 TPhoneCmdParamInteger integerParam;
                 if ( iSecurityMode )
-                	{
+                    {
                     iNoteController->DestroyNote();
                     integerParam.SetInteger(
-                    CPhoneMainResourceResolver::Instance()->
-                              		ResolveResourceID( EPhoneEmergencyModeNoteCBA ) );
-                              	}
-                              else
-                              	{
-                              	integerParam.SetInteger(
-                              		CPhoneMainResourceResolver::Instance()->
-                              		ResolveResourceID( EPhoneNumberAcqCBA ) );
-                              	}
+                            CPhoneMainResourceResolver::Instance()->
+                                ResolveResourceID( EPhoneEmergencyModeNoteCBA ) );
+                    }
+                else
+                    {
+                    integerParam.SetInteger(
+                            CPhoneMainResourceResolver::Instance()->
+                                ResolveResourceID( EPhoneNumberAcqCBA ) );
+                    }
                 ExecuteCommandL( EPhoneViewUpdateCba, &integerParam );
                 // Set flag to false because dialler is set to open status.
                 iPhoneView->SetPhoneAppViewToDialer( EFalse );
@@ -1736,10 +1737,10 @@
                     static_cast<MEikCommandObserver*>( CEikonEnv::Static()->EikAppUi() )
                     ->ProcessCommandL( EPhoneDtmfDialerExit );
                     }
-                else if ( iCustomization && 
+                else if ( iCustomization &&
                           IsCustomDialerActive() )
                     {
-                    iCustomization->HandleCommandL( 
+                    iCustomization->HandleCommandL(
                        *this, EPhoneViewOpenCallHandling, NULL );
                     }
                 else
@@ -1803,6 +1804,14 @@
             iToolbarController->ShowToolbar();
             }
             break;
+            
+        case EPhoneViewIsDisplayingMenuOrDialog:
+            {
+            viewResponse = iEikEnv.EikAppUi()->IsDisplayingMenuOrDialog() ?
+                EPhoneViewResponseSuccess :
+                EPhoneViewResponseFailed;
+            }
+            break;
         default:
             viewResponse = EPhoneViewResponseFailed;
             __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneViewController::HandleCommandL -> UnKnownMessage !!! ");
@@ -1823,7 +1832,7 @@
     __PHONELOGVIEWMSG( aCmdId, 0 );
     TPhoneViewResponseId viewResponse = EPhoneViewResponseSuccess;
     TInt err;
-    
+
     switch ( aCmdId )
         {
         case EPhoneViewSendKeyEventToNumberEntry:
@@ -1956,7 +1965,7 @@
             viewResponse = EPhoneViewResponseSuccess;
             }
             break;
-            
+
         default:
             if ( iCustomization )
                 {
@@ -2132,7 +2141,7 @@
                         "CPhoneViewController::HandleResourceChangeL()" )
     // Notify the bubble that there has been a resource change
     iBubbleWrapper->Control()->HandleResourceChange( aType );
-    
+
     // Notify dialer and switch statuspane layout.
     if ( iDialer )
         {
@@ -2178,25 +2187,54 @@
     }
 
 // ---------------------------------------------------------------------------
+// CPhoneViewController::IsEmergencyCallOngoing()
+// ---------------------------------------------------------------------------
+//
+TBool CPhoneViewController::IsEmergencyCallOngoing()
+    {
+    __LOGMETHODSTARTEND( EPhoneUIView,
+                         "CPhoneViewController::IsEmergencyCallOngoing()");
+
+    TPhoneCmdParamCallStateData callStateData;
+    callStateData.SetCallState( EPEStateConnected );
+    iBubbleWrapper->GetCallIdByState( &callStateData );
+    TInt connected = callStateData.CallId();
+
+    callStateData.SetCallState( EPEStateConnecting );
+    iBubbleWrapper->GetCallIdByState( &callStateData );
+    TInt connecting = callStateData.CallId();
+
+    return ( ( connected == KEmergencyCallId ) ||
+             ( connecting == KEmergencyCallId ) );
+    }
+
+// ---------------------------------------------------------------------------
 // CPhoneViewController::HandleSecurityModeChanged
 // ---------------------------------------------------------------------------
 //
 EXPORT_C void CPhoneViewController::HandleSecurityModeChanged( TBool aIsEnabled )
-	{
-	 __PHONELOG1( EBasic, EPhoneUIView,
-            "CPhoneViewController::SetSecurityMode Mode = (%d)", aIsEnabled );
-    iToolbarController->DimToolbar( aIsEnabled );			
-	iPhoneView->SetSecurityMode( aIsEnabled );
-	iMenuController->SetSecurityMode( aIsEnabled );
-	
-	TBool securityModeChanged = ( iSecurityMode != aIsEnabled );
-	
-	iSecurityMode = aIsEnabled;
-	
-	if ( iDialer )
-		{
+    {
+    __PHONELOG1( EBasic, EPhoneUIView,
+            "CPhoneViewController::HandleSecurityModeChanged Mode = (%d)", aIsEnabled );
+
+    TBool emergencyCallOngoing = IsEmergencyCallOngoing();
+
+    // Don't undim toolbar if emergency call is ongoing 
+    if ( !emergencyCallOngoing )
+        {
+        iToolbarController->DimToolbar( aIsEnabled );
+        }
+    iPhoneView->SetSecurityMode( aIsEnabled );
+    iMenuController->SetSecurityMode( aIsEnabled );
+
+    TBool securityModeChanged = ( iSecurityMode != aIsEnabled );
+
+    iSecurityMode = aIsEnabled;
+
+    if ( iDialer )
+        {
         iDialerController->SetRestrictedDialer( aIsEnabled );
-	
+
         if ( iDialerActive && securityModeChanged )
             {
             CDialingExtensionInterface* easyDialing = iDialer->GetEasyDialingInterface();
@@ -2222,30 +2260,40 @@
                     }
                 }
             iDialer->RelayoutAndDraw();
-            
-            // also update cba if security mode changes while dialer is open
-            TPhoneCmdParamInteger integerParam;
-            if ( aIsEnabled )
+
+            // Don't update cba here if emergency call is ongoing 
+            if ( !emergencyCallOngoing )
                 {
-                iNoteController->DestroyNote();
-                integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
-                        ResolveResourceID( EPhoneEmergencyModeNoteCBA ) );
+                // also update cba if security mode changes while dialer is open
+                TPhoneCmdParamInteger integerParam;
+                if ( aIsEnabled )
+                    {
+                    iNoteController->DestroyNote();
+                    integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
+                            ResolveResourceID( EPhoneEmergencyModeNoteCBA ) );
+                    }
+                else
+                    {
+                    integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
+                            ResolveResourceID( EPhoneNumberAcqCBA ) );
+                    }
+                TRAP_IGNORE( ExecuteCommandL( EPhoneViewUpdateCba, &integerParam ) );
                 }
-            else
-                {
-                integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
-                        ResolveResourceID( EPhoneNumberAcqCBA ) );
-                }
-            TRAP_IGNORE( ExecuteCommandL( EPhoneViewUpdateCba, &integerParam ) );
-            
             if ( !aIsEnabled )
                 {
                 TRAP_IGNORE( SwitchLayoutToFlatStatusPaneL( ETrue ) );
                 }
             }
-		}
+        }
     if ( securityModeChanged )
         {
+        // Update cba if security mode changes while emergency call is ongoing
+        if ( emergencyCallOngoing )
+            {
+            TRAP_IGNORE( static_cast<MEikCommandObserver*>( CEikonEnv::Static()->EikAppUi() )
+                                ->ProcessCommandL( EPhoneCmdUpdateEmergencyCba ) );
+            }
+
         // Update status pane dimming
         iStatusPane->StatusPane().SetDimmed( aIsEnabled );
 
@@ -2257,7 +2305,7 @@
 
         iKeyCaptureController->StopCapturingKey( &appKeyCaptureParam );
         }
-	}
+    }
 
 // ---------------------------------------------------------------------------
 // CPhoneViewController::IdleAppUid
@@ -2299,7 +2347,7 @@
     {
     iMenuController->SetNumberEntryEmptyFlag( !aEntryHasText );
     iBubbleWrapper->HandleNumberEntryChanged();
-    ExecuteCommandL( EPhoneViewUpdateToolbar );
+    TRAP_IGNORE( ExecuteCommandL( EPhoneViewUpdateToolbar ) );
     }
 
 // ---------------------------------------------------------------------------
@@ -2485,7 +2533,7 @@
         CAknSgcClient::MoveApp( phoneApp.WgId(), ESgcMoveAppToForeground );
         __PHONELOG1( EBasic, EPhoneUIView,
                       "CPhoneViewController::BringPhoneAppToForeground - Previous App WG ID: %d",
-                      iPrevForegroundAppWg );        
+                      iPrevForegroundAppWg );
         }
     }
 
@@ -2760,9 +2808,9 @@
     TInt resourceId = cbaResource->Integer();
 
     iCba->SetCommandSetL( resourceId );
-    
+
     iCba->DrawDeferred();
-    
+
     }
 
 // ---------------------------------------------------------------------------
@@ -2879,10 +2927,10 @@
 
     if ( phoneIsLocked || IsSecurityCodeQuery() )
         {
-        // Soft Reject is enabled if the phone is not locked. 
-		// Security Code query is checked because in the boot
-		// autolock status value is OFF even when it's actually
-		// ON so we need to do this double checking.
+        // Soft Reject is enabled if the phone is not locked.
+        // Security Code query is checked because in the boot
+        // autolock status value is OFF even when it's actually
+        // ON so we need to do this double checking.
         return EFalse;
         }
     return ETrue;
@@ -3029,8 +3077,8 @@
     CPhCntSpeedDialMonitor::TSpdDialFieldInfo fieldInfo;
 
     TBuf<KPhoneNumberEntryBufferSize> number;
-    TContactItemId itemId = iSpeedDialController->GetSpeedDialFieldL( 
-                                aSpeedDialLocation, 
+    TContactItemId itemId = iSpeedDialController->GetSpeedDialFieldL(
+                                aSpeedDialLocation,
                                 number,
                                 fieldInfo );
 
@@ -3045,7 +3093,7 @@
 // ---------------------------------------------------------------------------
 //
 TPhoneNumberType CPhoneViewController::ConvertNumberTypeFromSpeedDialFieldInfo(
-    CPhCntSpeedDialMonitor::TSpdDialFieldInfo aFieldInfo )
+    const CPhCntSpeedDialMonitor::TSpdDialFieldInfo& aFieldInfo )
     {
     __LOGMETHODSTARTEND(EPhoneUIView,
         "CPhoneViewController::ConvertNumberTypeFromSpeedDialFieldInfo() ");
@@ -3103,7 +3151,7 @@
 TBool CPhoneViewController::AssignSpeedDialLocationL(
     TInt aLocation )
     {
-  CreateSpeedDialControllerL();
+    CreateSpeedDialControllerL();
 
     // Assign speed dial location
     TBuf<KPhoneNumberEntryBufferSize> number;
@@ -3128,7 +3176,7 @@
     TUid mtmUid = { KSenduiMtmUniMessageUidValue };
 
     CSendUi* messageEditor = CSendUi::NewL();
-  CleanupStack::PushL( messageEditor );
+    CleanupStack::PushL( messageEditor );
 
     // Inform the SendUi to open the message editor. This is not a blocking
     // dialog so the flag does not need to be set.
@@ -3588,7 +3636,7 @@
   {
     __LOGMETHODSTARTEND( EPhoneUIView,
         "CPhoneViewController::CreateSpeedDialControllerL()" );
-  if( !iSpeedDialController )
+    if( !iSpeedDialController )
         {
         iSpeedDialController = iContactController->CreateSpeedDialMonitorL();
         }
@@ -3690,12 +3738,12 @@
 // -----------------------------------------------------------
 //
 TInt CPhoneViewController::SingleItemFetchType() const
-   {
-   __LOGMETHODSTARTEND(EPhoneUIView,
+    {
+    __LOGMETHODSTARTEND(EPhoneUIView,
        "CPhoneViewController::SingleItemFetchType()" );
 
-   return iSingleItemFetchType;
-   }
+    return iSingleItemFetchType;
+    }
 
 // ---------------------------------------------------------------------------
 // CPhoneViewController::SwitchLayoutToFlatStatusPaneL
@@ -3822,9 +3870,9 @@
         case EPhoneTransEffectAppStartFromDialer:
             {
             GfxTransEffect::BeginFullScreen(
-                AknTransEffect::EApplicationStart, 
-                TRect(), 
-                AknTransEffect::EParameterType, 
+                AknTransEffect::EApplicationStart,
+                TRect(),
+                AknTransEffect::EParameterType,
                 AknTransEffect::GfxTransParam( aAppUidEffectParam,
                     AknTransEffect::TParameter::EActivateExplicitCancel ) );
             iEffectOngoing = ETrue;
@@ -3859,18 +3907,18 @@
         {
         iDialerActive = ETrue;
 
-        // Ensure that toolbar and menu commands are up-to-date 
+        // Ensure that toolbar and menu commands are up-to-date
         TBuf<1> temp; // we are only interested if the text is empty or not
         iDialer->GetTextFromNumberEntry( temp );
         NumberEntryStateChanged( temp.Length() > 0 );
-        
+
         // Make dialer view top most
         iDialerView->DrawableWindow()->SetOrdinalPosition(
             iPhoneView->DrawableWindow()->OrdinalPosition() );
 
         // Hide in-call view toolbar
         iToolbarController->HideToolbar();
-        
+
         SwitchLayoutToFlatStatusPaneL( ETrue );
 
         // Don't make dialer view visible before status pane is updated.
@@ -3882,7 +3930,7 @@
         // dialer as soon as it becomes visible to prevent the flashing of
         // number entry (DrawDeferred() isn't fast enough here).
         iDialerView->DrawNow();
-      
+
         iPhoneView->DrawableWindow()->SetOrdinalPosition( -1 );
         iPhoneView->MakeVisible( EFalse );
 
@@ -3910,7 +3958,7 @@
         // resizing of dialer components. Hiding dialer view already before showing
         // phone view might cause screen flickering but tests have proven it doesn't happen.
         iDialerView->MakeVisible( EFalse );
-        
+
         SwitchLayoutToFlatStatusPaneL( EFalse );
 
         // Make call handling view top most
@@ -3924,7 +3972,7 @@
         // Update control stack
         iAppui->AddToStackL( iPhoneView );
         iAppui->RemoveFromStack( iDialerView );
-        
+
         iEasyDialingController->HandleCommandL( EEasyDialingCallHandlingActivated );
         }
     }
@@ -4038,8 +4086,8 @@
 //
 TBool CPhoneViewController::IsDtmfDialerActive() const
     {
-    TBool ret = 
-            ( iDialer && iDtmfDialerController && 
+    TBool ret =
+            ( iDialer && iDtmfDialerController &&
               iDialer->Controller() == iDtmfDialerController );
     return ret;
     }
@@ -4054,8 +4102,8 @@
     if ( iDialer )
         {
         MPhoneDialerController* curController = iDialer->Controller();
-        ret = ( curController && 
-                curController != iDialerController && 
+        ret = ( curController &&
+                curController != iDialerController &&
                 curController != iDtmfDialerController );
         }
     return ret;
@@ -4065,16 +4113,16 @@
 // CPhoneViewController::CanTransEffectBeUsed
 // -----------------------------------------------------------
 //
-TBool CPhoneViewController::CanTransEffectBeUsed( 
+TBool CPhoneViewController::CanTransEffectBeUsed(
     TPhoneTransEffectType aType )
     {
     TBool okToUseEffect( EFalse );
-    
+
     TBool isForeground = iAppui->IsForeground();
     // Check whether the idle is on foreground
     TBool idleInFore = ForegroundApplicationWindowGroupId() ==  IdleWindowGroupId() ?
             ETrue : EFalse;
-    
+
     if ( isForeground && // Newer run effect if not at front
          ( ( aType == EPhoneTransEffectDialerCreate && !iDialerActive ) ||
            ( aType == EPhoneTransEffectDialerOpen && !iDialerActive &&
@@ -4083,18 +4131,18 @@
         {
         okToUseEffect = ETrue;
         }
-    // In case transition is from idle to dialer show transition effects as well.                 
+    // In case transition is from idle to dialer show transition effects as well.
     else if ( idleInFore && !iDialerActive &&
               aType == EPhoneTransEffectDialerOpen )
         {
         okToUseEffect = ETrue;
         }
-    else if ( isForeground && iDialerActive && 
+    else if ( isForeground && iDialerActive &&
               aType == EPhoneTransEffectAppStartFromDialer )
         {
         okToUseEffect = ETrue;
         }
-    
+
     return okToUseEffect;
     }
 
@@ -4102,13 +4150,13 @@
 // CPhoneViewController::BeginTransEffectForAppStartFromDialerLC
 // -----------------------------------------------------------
 //
-void CPhoneViewController::BeginTransEffectForAppStartFromDialerLC( 
+void CPhoneViewController::BeginTransEffectForAppStartFromDialerLC(
     const TUid& aAppUid )
     {
     TPhoneCmdParamTransEffect effectParam;
     effectParam.SetType( EPhoneTransEffectAppStartFromDialer );
     effectParam.SetAppUid( aAppUid );
-    
+
     ExecuteCommand( EPhoneViewBeginTransEffect,  &effectParam );
 
     TCleanupItem operation( EffectCleanup, this );
@@ -4167,20 +4215,19 @@
 // ---------------------------------------------------------------------------
 //
 void CPhoneViewController::AllowInCallBubbleInSpecialCases()
-{
+    {
     // this method can be used for special cases like dialer
- 
+
     if( iDialerActive )
-    {
+        {
         SetIncallBubbleVisibility( ETrue );
+        }
+    else
+        {
+        SetIncallBubbleVisibility( EFalse );
+        }
     }
-    else
-    {
-        SetIncallBubbleVisibility( EFalse );
-    }
- 
-}
-                    
+
 // ---------------------------------------------------------------------------
 // CPhoneViewController::SetIncallBubbleVisibility
 // ---------------------------------------------------------------------------
@@ -4191,7 +4238,7 @@
         "CPhoneViewController::SetIncallBubbleVisibility(%d)",
         aVisible );
 
-    TRAP_IGNORE( iIncallBubble->SetIncallBubbleAllowedInUsualL( aVisible ) ); 
+    TRAP_IGNORE( iIncallBubble->SetIncallBubbleAllowedInUsualL( aVisible ) );
     }
 
 // ---------------------------------------------------------------------------
--- a/phoneapp/phoneuiview/src/phoneringingtonesrv.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/phoneringingtonesrv.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -88,24 +88,37 @@
     }
 
 // -----------------------------------------------------------------------------
-// CPhoneRingingToneServer::IncrementSessions
+// CPhoneRingingToneServer::StartSession
 // -----------------------------------------------------------------------------
 //
-void CPhoneRingingToneServer::IncrementSessions()
+TInt CPhoneRingingToneServer::StartSession()
     {
-    iSessionCount++;
+    PHONEUIVIEW_PRINTF( "CPhoneRingingToneServer::StartSession err %d", iSessionCount );
+
+    TInt err( KErrNone );
+
+    if( !iSessionInUse )
+        {
+        iSessionInUse = ETrue;
+        }
+    else
+        {
+        err = KErrAccessDenied;
+        }
+
+    return err;
     }
 
 // -----------------------------------------------------------------------------
-// CPhoneRingingToneServer::DecrementSessions
+// CPhoneRingingToneServer::CloseSession
 // -----------------------------------------------------------------------------
 //
-void CPhoneRingingToneServer::DecrementSessions()
+void CPhoneRingingToneServer::CloseSession()
     {
-    if ( --iSessionCount <= 0 )
-        {
-        CActiveScheduler::Stop();
-        }
+    PHONEUIVIEW_PRINT( "CPhoneRingingToneServer::CloseSession()" );
+
+    CActiveScheduler::Stop();
+    iSessionInUse = EFalse;
     }
 
 // -----------------------------------------------------------------------------
--- a/phoneapp/phoneuiview/src/phoneringingtonesrvsession.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneapp/phoneuiview/src/phoneringingtonesrvsession.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -43,7 +43,10 @@
 //
 CPhoneRingingToneServerSession::~CPhoneRingingToneServerSession()
     {
-    iServer.DecrementSessions();
+    if( iStartSession == KErrNone )
+        {
+        iServer.CloseSession();
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -68,7 +71,10 @@
 void CPhoneRingingToneServerSession::ConstructL()
     {
     PHONEUIVIEW_PRINT( "CPhoneRingingToneServerSession::ConstructL" );
-    iServer.IncrementSessions();
+
+    iStartSession = iServer.StartSession();
+
+    User::LeaveIfError( iStartSession );
     }
 
 // -----------------------------------------------------------------------------
--- a/phoneengine/PhoneCntFinder/ContactService/inc/CPhCntMatcherImpl.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/inc/CPhCntMatcherImpl.h	Thu Jul 15 18:38:16 2010 +0300
@@ -45,12 +45,12 @@
     {
 public:
 
-	/**
-	 * Static constructor.
-	 *
-	 * @since S60 v3.1
-	 * @param aOwner Phonebook owner.
-	 */
+    /**
+     * Static constructor.
+     *
+     * @since S60 v3.1
+     * @param aOwner Phonebook owner.
+     */
     static CPhCntMatcherImpl* NewL( const MPhoneCntPbkOwner& aOwner );
 
     /**
@@ -110,14 +110,14 @@
     /**
     * Match number to phonebook.
     * @param aMatch Found match, owership tranferred. NULL if not found any.
-    * @param aNumber Number to match against.
+    * @param aMatchString Number to match against.
     * @return Error code: KErrNone - one match found
     *                     KErrNotFound - no matches found
     *                     other - normal Symbian OS error
     */
-	TInt MatchVoipNumber(
+    TInt MatchVoipNumber(
         MPhCntMatch*& aMatch,
-        const TDesC& aNumber,
+        const TDesC& aMatchString,
         TBool aAllowUserNameMatch,
         MDesCArray* aContactStoreUris,
         TInt aCharsForMatching = 0 );
@@ -127,6 +127,7 @@
     * by contact id.
     * @since Series60 3.0
     * @param aMatch for found match, owership tranferred. Empty if not found.
+    * @param aMatchString Number to match against.
     * @param aContactId for current contact.
     * @return Error code: KErrNone - VoIP call contact found
     *                     KErrNotFound - no VoIP call contact found
@@ -134,6 +135,7 @@
     */
     TInt MatchVoipNumber(
         MPhCntMatch*& aMatch,
+        const TDesC& aMatchString,
         const CPhCntContactId& aContactId );
 
 
--- a/phoneengine/PhoneCntFinder/ContactService/inc/cphcntmatchervoipimpl.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/inc/cphcntmatchervoipimpl.h	Thu Jul 15 18:38:16 2010 +0300
@@ -44,7 +44,7 @@
      * Match number to phonebook.
      * @since S60 v3.2
      * @param aMatch Found match, owership tranferred. NULL if not found any.
-     * @param aNumber Number to match against.
+     * @param aMatchString Number to match against.
      * @param aAllowUserNameMatch If true user name match is allowed.
      * @param aCharsForMatching Characters for user name match. Match is started from
      *                          the rigth of the user name part. (see CS call match)
@@ -54,7 +54,7 @@
      */    
     TInt MatchVoipNumber(
         MPhCntMatch*& aMatch,
-        const TDesC& aNumber,
+        const TDesC& aMatchString,
         TBool aAllowUserNameMatch,
         MDesCArray* aContactStoreUris,
         TInt aCharsForMatching = 0 );
@@ -65,6 +65,7 @@
      * by contact id.
      * @since Series60 3.2
      * @param aMatch for found match, owership tranferred. Empty if not found.
+     * @param aMatchString Number to match against.
      * @param aContactId for current contact.
      * @return Error code: KErrNone - VoIP call contact found
      *                     KErrNotFound - no VoIP call contact found
@@ -72,6 +73,7 @@
      */
     TInt MatchVoipNumber(
         MPhCntMatch*& aMatch,
+        const TDesC& aMatchString,
         const CPhCntContactId& aContactId );
 
     
@@ -110,6 +112,16 @@
      */
     TInt CreateMatcher();
 
+    /**
+     * Sets matched VoIP number if it was found.
+     *
+     * @param aContact Contact, which is checked.
+     * @param aMatchString Number to match against.
+     */
+    void SetMatchedVoIPNumberIfExists( 
+        CPhCntContact& aContact,
+        const TDesC& aMatchString );
+    
 private: // data
 
       
--- a/phoneengine/PhoneCntFinder/ContactService/src/CPhCntMatcherImpl.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/src/CPhCntMatcherImpl.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -78,25 +78,25 @@
     TEFLOGSTRING( KTAOBJECT, "CNT CPhCntMatcherImpl::MatchNumber" );
     TInt err = CreateMatcher();
     if ( !err )
-    	{
-	    // Check if we already have the contact.
-	    CPhCntContact* contact = iFoundContacts->FindContact( aTelNumber );
+        {
+        // Check if we already have the contact.
+        CPhCntContact* contact = iFoundContacts->FindContact( aTelNumber );
 
-	    err = KErrNone;
-	    if( !contact )
-	        {
-	        // Get contact from contact stores
-	        TRAPD( traperr, err = GetContactL( aMatch, aTelNumber ));
-	        if ( traperr )
-	            {
-	            err = traperr;
-	            }
-	        }
-	    else
-	        {
-	        aMatch = contact;
-	        }
-    	}
+        err = KErrNone;
+        if( !contact )
+            {
+            // Get contact from contact stores
+            TRAPD( traperr, err = GetContactL( aMatch, aTelNumber ));
+            if ( traperr )
+                {
+                err = traperr;
+                }
+            }
+        else
+            {
+            aMatch = contact;
+            }
+        }
     TEFLOGSTRING2( KTAOBJECT, "CNT CPhCntMatcherImpl::MatchNumber %d " , err);
     return err;
     }
@@ -113,31 +113,31 @@
     {
     TInt err = CreateMatcher();
     if ( !err )
-	    {
-	    if( aContactId.IsValid() )
-	        {
-	        // Do we have existing contact for the link and number.
-	        const CPhCntVPbkContactId& contactId =
-	            static_cast<const CPhCntVPbkContactId&>( aContactId );
-	        const MVPbkContactLink& link = contactId.ContactLink();
-	        aMatch =
-	            iFoundContacts->FindContact( aTelNumber, link );
-	        if( !aMatch )
-	            {
-	            // Get the contact.
-	            CPhCntContact* match = NULL;
-	            err = FetchContact( match, link, aTelNumber );
-	            if( !err )
-	                {
-	                aMatch = match;
-	                }
-	            }
-	        }
-	    else
-	        {
-	        err = MatchNumber( aMatch, aTelNumber );
-	        }
-	    }
+        {
+        if( aContactId.IsValid() )
+            {
+            // Do we have existing contact for the link and number.
+            const CPhCntVPbkContactId& contactId =
+                static_cast<const CPhCntVPbkContactId&>( aContactId );
+            const MVPbkContactLink& link = contactId.ContactLink();
+            aMatch =
+                iFoundContacts->FindContact( aTelNumber, link );
+            if( !aMatch )
+                {
+                // Get the contact.
+                CPhCntContact* match = NULL;
+                err = FetchContact( match, link, aTelNumber );
+                if( !err )
+                    {
+                    aMatch = match;
+                    }
+                }
+            }
+        else
+            {
+            err = MatchNumber( aMatch, aTelNumber );
+            }
+        }
     return err;
     }
 
@@ -163,6 +163,7 @@
 //
 TInt CPhCntMatcherImpl::MatchVoipNumber(
     MPhCntMatch*& /*aMatch*/,
+    const TDesC& /*aMatchString*/,
     const CPhCntContactId& /*aContactId*/ )
     {
     return KErrNotFound;
@@ -266,26 +267,26 @@
 // ---------------------------------------------------------------------------
 //
 void CPhCntMatcherImpl::DoCreateMatcherL()
-	{
-	TEFLOGSTRING( KTAOBJECT, "CNT CPhCntMatcherImpl::DoCreateMatcherL" );
-	if ( !iContactStores )
-		{
-		iFoundContacts = CPhCntFoundContacts::NewL();
-	    iContactStores = CPhCntContactStores::NewL( iContactManager );
-	    iMatchContact = CPhCntMatchContact::NewL();
-	    iFetchContact = CPhCntFetchContact::NewL( *iContactStores );
-		}
-	}
+    {
+    TEFLOGSTRING( KTAOBJECT, "CNT CPhCntMatcherImpl::DoCreateMatcherL" );
+    if ( !iContactStores )
+        {
+        iFoundContacts = CPhCntFoundContacts::NewL();
+        iContactStores = CPhCntContactStores::NewL( iContactManager );
+        iMatchContact = CPhCntMatchContact::NewL();
+        iFetchContact = CPhCntFetchContact::NewL( *iContactStores );
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // Delayed on-demand based construction
 // ---------------------------------------------------------------------------
 //
 TInt CPhCntMatcherImpl::CreateMatcher()
-	{
-	TRAPD( err, DoCreateMatcherL() );
-	return err;
-	}
+    {
+    TRAPD( err, DoCreateMatcherL() );
+    return err;
+    }
 
 // ---------------------------------------------------------------------------
 // Second phase constructor
--- a/phoneengine/PhoneCntFinder/ContactService/src/cphcntmatchervoipimpl.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/src/cphcntmatchervoipimpl.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -78,117 +78,116 @@
     TInt err = CreateMatcher();    
 
     if ( err == KErrNone )
-    {
-    CPhCntContact* existingContact = 
-        iFoundContacts->FindContact( sipUri.SipURI() );
-    if( !existingContact )
         {
-        // Check for service specific contact stores and
-        // open stores if not open
-        if ( aContactStoreUris )
+        CPhCntContact* existingContact = 
+            iFoundContacts->FindContact( sipUri.SipURI() );
+        if( !existingContact )
             {
-            TInt storeCount = aContactStoreUris->MdcaCount();
-            for( TInt i = 0; i < storeCount ; i++ )
+            // Check for service specific contact stores and
+            // open stores if not open
+            if ( aContactStoreUris )
+                {
+                TInt storeCount = aContactStoreUris->MdcaCount();
+                for( TInt i = 0; i < storeCount ; i++ )
+                    {
+                    TPtrC storeUri = aContactStoreUris->MdcaPoint( i );
+                   
+                    err = iContactStoreLoader->LoadContactStoreWithUri( storeUri );              
+                    }  
+                }
+    
+            const MVPbkContactLinkArray* linkArray = NULL;
+            
+            // Find possible contacts.
+            if( aAllowUserNameMatch && !aCharsForMatching )
+                {
+                err = iMatchContact->MatchContact(
+                    linkArray, sipUri.UserNamePart(), *iVoipMatchStrategy );
+                }
+            else if ( aCharsForMatching )
+                {
+                err = iMatchContact->MatchContact(
+                    linkArray, sipUri.FixedUserNamePart(), *iVoipMatchStrategy );            
+                }
+            else
+                {
+                err = iMatchContact->MatchContact( 
+                    linkArray, sipUri.SipURI() , *iVoipMatchStrategy );    
+                }
+            
+            MPhCntMatch* match = NULL;
+            if( !err )
                 {
-                TPtrC storeUri = aContactStoreUris->MdcaPoint( i );
-               
-                err = iContactStoreLoader->LoadContactStoreWithUri( storeUri );              
-                }  
-            }
-
-        const MVPbkContactLinkArray* linkArray = NULL;
-        
-        // Find possible contacts.
-        if( aAllowUserNameMatch && !aCharsForMatching )
-            {
-            err = iMatchContact->MatchContact(
-                linkArray, sipUri.UserNamePart(), *iVoipMatchStrategy );
-            }
-        else if ( aCharsForMatching )
-            {
-            err = iMatchContact->MatchContact(
-                linkArray, sipUri.FixedUserNamePart(), *iVoipMatchStrategy );            
+                // Fetch all the matched contacts, because iVoipMatchStrategy
+                // could give us a match that is matched to wrong contact field.
+                const TInt matchedContacts( linkArray->Count() );
+    
+                // Find real matches.
+                TPhCntVoipMatchArray voipMatches;
+                for( TInt i = 0; i < matchedContacts; i++ )
+                    {
+                    // Get contacts from phone book.
+                    CPhCntContact* match = NULL;
+                    err = FetchContact( match, linkArray->At( i ), sipUri.SipURI() );
+                    if( !err )
+                        {
+                        TRAP_IGNORE( voipMatches.AppendL( match ) );
+                        }
+                    else
+                        {
+                        // Error in fetching contacts 
+                        break;
+                        }
+                    }
+                    
+                if( aAllowUserNameMatch || aCharsForMatching )   
+                    {
+                    match = voipMatches.FindFullOrUsernameMatch( sipUri, aCharsForMatching );
+                    }
+                else
+                    {
+                    // Take the first match, that is voip contact. Gives NULL if match not found.
+                    match = voipMatches.FindFullMatch( sipUri );
+                    }
+                
+                // Release extra matches
+                voipMatches.ReleaseMatches();
+                }
+            
+            // If no error and match still null pointer, then no contacts were found.
+            if( !err && !match )        
+                {
+                err = KErrNotFound;
+                }
+            else
+                {
+                aMatch = match;
+                }
             }
         else
             {
-            err = iMatchContact->MatchContact( 
-                linkArray, sipUri.SipURI() , *iVoipMatchStrategy );    
-            }
-        
-            
-        MPhCntMatch* match = NULL;
-        if( !err )
-            {
-            // Fetch all the matched contacts, because iVoipMatchStrategy
-            // could give us a match that is matched to wrong contact field.
-            const TInt matchedContacts( linkArray->Count() );
-
-            // Find real matches.
-            TPhCntVoipMatchArray voipMatches;
-            for( TInt i = 0; i < matchedContacts; i++ )
-                {
-                // Get contacts from phone book.
-                CPhCntContact* match = NULL;
-                err = FetchContact( match, linkArray->At( i ), sipUri.SipURI() );
-                if( !err )
-                    {
-                    TRAP_IGNORE( voipMatches.AppendL( match ) );
-                    }
-                else
-                    {
-                    // Error in fetching contacts 
-                    break;
-                    }
-                }
-                
-            if( aAllowUserNameMatch || aCharsForMatching )   
-                {
-                match = voipMatches.FindFullOrUsernameMatch( sipUri, aCharsForMatching );
-                }
-            else
-                {
-                // Take the first match, that is voip contact. Gives NULL if match not found.
-                match = voipMatches.FindFullMatch( sipUri );
-                }
-            
-            // Release extra matches
-            voipMatches.ReleaseMatches();
-            }
-        
-        // If no error and match still null pointer, then no contacts were found.
-        if( !err && !match )        
-            {
-            err = KErrNotFound;
-            }
-        else
-            {
-            aMatch = match;
+            aMatch = existingContact;
             }
         }
-    else
-        {
-        aMatch = existingContact;
-        }
-    }
 
     return err;
     }
-    
+
 // ---------------------------------------------------------------------------
 // From class CPhCntMatcher
 // Matches voip contacts
 // ---------------------------------------------------------------------------
 TInt CPhCntMatcherVoIPImpl::MatchVoipNumber(
-            MPhCntMatch*& aMatch,
-            const CPhCntContactId& aContactId )
+    MPhCntMatch*& aMatch,
+    const TDesC& aMatchString,
+    const CPhCntContactId& aContactId )
     {
     const CPhCntVPbkContactId& contactId = 
             static_cast<const CPhCntVPbkContactId&>( aContactId );
-            
+
     const MVPbkContactLink& contactLink = contactId.ContactLink();
     
-    
-    TInt err = CreateMatcher();    
+    TInt err = CreateMatcher();
 
     const TVPbkContactStoreUriPtr uri 
         = contactLink.ContactStore().StoreProperties().Uri(); 
@@ -197,61 +196,78 @@
     iContactStoreLoader->LoadContactStoreWithUri( uri.UriDes() );
     
     if ( err == KErrNone )
-    {
-    CPhCntContact* existingContact = 
-        iFoundContacts->FindContact( contactLink );
-     
-    
-    if( !existingContact )
         {
-        CPhCntContact* contact = NULL;
-        err = iFetchContact->FetchContact( contactLink,  contact );
-
-        if( !err )
+        CPhCntContact* existingContact = 
+            iFoundContacts->FindContact( contactLink );
+        
+        if ( !existingContact )
             {
-            const RArray<TPhCntNumber>& allNumbers = 
-                contact->AllNumbers();
-            const TInt count( allNumbers.Count() );
-            for( TInt i = 0; i < count; i++ )
+            CPhCntContact* contact = NULL;
+            err = iFetchContact->FetchContact( contactLink,  contact );
+    
+            if ( !err )
                 {
-                // Take first voip number and set it as contacts number.
-                TPhCntNumber number = allNumbers[i];
-                if( number.Type() == MPhCntMatch::EVoipNumber ||
-                    number.Type() == MPhCntMatch::EMobileNumber ||
-                    number.Type() == MPhCntMatch::EStandardNumber ||
-                    number.Type() == CPhCntContact::EPagerNumber ||
-                    number.Type() == CPhCntContact::EVideoNumber ||
-                    number.Type() == CPhCntContact::EAssistantNumber ||
-                    number.Type() == CPhCntContact::EFaxNumber ||
-                    number.Type() == CPhCntContact::ECarNumber ) 
+                SetMatchedVoIPNumberIfExists( *contact, aMatchString );
+
+                TPhCntSipURI sipUri( contact->Number() );
+                TRAP( err, iFoundContacts->AddL( contact, sipUri.SipURI() ) );
+                if ( err )
                     {
-                    contact->SetMatchedVoipNumber( TPhCntSipURI( number.Number() ) );
-                    break;
+                    delete contact;
+                    }
+                else
+                    {
+                    aMatch = contact;
                     }
                 }
-            TPhCntSipURI sipUri( contact->Number() );
-            TRAP( err, iFoundContacts->AddL( contact, sipUri.SipURI() ) );
-            if( err )
-                {
-                delete contact;
-                }
-            else
-                {
-                aMatch = contact;
-                }
-         
+            }
+        else
+            {
+            aMatch = existingContact;
             }
         }
-    else
-        {
-        aMatch = existingContact;
-        }
-    }
     return err;
     }
 
 
 // ---------------------------------------------------------------------------
+// Sets matched VoIP number if it was found.
+// ---------------------------------------------------------------------------
+//    
+void CPhCntMatcherVoIPImpl::SetMatchedVoIPNumberIfExists( 
+    CPhCntContact& aContact,
+    const TDesC& aMatchString )
+    {
+    const RArray<TPhCntNumber>& allNumbers = aContact.AllNumbers();
+    const TInt numberCount( allNumbers.Count() );
+    TPhCntSipURI sipUri( aMatchString );
+    
+    for ( TInt i = 0; i < numberCount; i++ ) 
+        {
+        TPhCntNumber number = allNumbers[i];
+        if ( number.Type() == CPhCntContact::EVoipNumber ||
+             number.Type() == CPhCntContact::EMobileNumber || 
+             number.Type() == CPhCntContact::EStandardNumber ||
+             number.Type() == CPhCntContact::EPagerNumber ||
+             number.Type() == CPhCntContact::EVideoNumber ||
+             number.Type() == CPhCntContact::EAssistantNumber ||
+             number.Type() == CPhCntContact::EFaxNumber ||
+             number.Type() == CPhCntContact::ECarNumber ) 
+            {
+            // If uris are the same then we have a full match.
+            // (usernamepart requires case sensitive match, domain is not sensitive)
+            TPhCntSipURI matchURI( number.Number() );
+            if ( matchURI.SipURI().CompareF( sipUri.SipURI() ) == KErrNone &&
+                 matchURI.UserNamePart().Compare( sipUri.UserNamePart() ) == KErrNone )
+                {
+                aContact.SetMatchedVoipNumber( matchURI );
+                break;
+                }
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // From class CPhCntMatcher
 // Determines if contact has CS numbers.
 // ---------------------------------------------------------------------------
@@ -265,28 +281,26 @@
     
     if ( CreateMatcher() == KErrNone )
         {
+        // Check if we have contact already.
+        CPhCntContact* contact = 
+            iFoundContacts->FindContact( contactId.ContactLink() );
             
-    // Check if we have contact already.
-    CPhCntContact* contact = 
-        iFoundContacts->FindContact( contactId.ContactLink() );
-        
-    if( contact ) 
-        {
-        hasCSNumbers = HasCSNumbers( contact );
-        contact->Release();
-        }
-    else
-        {
-        // Fetch the contact from Virtual phonebook.
-        const TInt err = 
-            iFetchContact->FetchContact( contactId.ContactLink(), contact );
-        hasCSNumbers = HasCSNumbers( contact );
-        
-        // We can delete the contact, because it is not added to 
-        // iFoundContacts.
-        delete contact;
-        }
-    
+        if ( contact ) 
+            {
+            hasCSNumbers = HasCSNumbers( contact );
+            contact->Release();
+            }
+        else
+            {
+            // Fetch the contact from Virtual phonebook.
+            const TInt err = 
+                iFetchContact->FetchContact( contactId.ContactLink(), contact );
+            hasCSNumbers = HasCSNumbers( contact );
+            
+            // We can delete the contact, because it is not added to 
+            // iFoundContacts.
+            delete contact;
+            }
         }
 
     return hasCSNumbers;
@@ -323,17 +337,17 @@
     {
     
     TBool hasCSNumbers = EFalse;
-    if( aContact )
+    if ( aContact )
         {
         const RArray<TPhCntNumber>& allNumbers = aContact->AllNumbers();
         const TInt count( allNumbers.Count() );
         for( TInt i = 0; i < count; i++ )
             {
             const MPhCntMatch::TNumberType type = allNumbers[i].Type();
-            if( type != MPhCntMatch::ENone &&
-                type != MPhCntMatch::EFaxNumber &&
-                type != MPhCntMatch::EPagerNumber &&
-                type != MPhCntMatch::EVoipNumber 
+            if ( type != MPhCntMatch::ENone &&
+                 type != MPhCntMatch::EFaxNumber &&
+                 type != MPhCntMatch::EPagerNumber &&
+                 type != MPhCntMatch::EVoipNumber 
                 )
                 {
                 hasCSNumbers = ETrue;
@@ -343,10 +357,14 @@
     return hasCSNumbers;
     }
 
+// ---------------------------------------------------------------------------
+// Creates the contact matcher.
+// ---------------------------------------------------------------------------
+//  
 TInt CPhCntMatcherVoIPImpl::CreateMatcher()
     {
     TInt err = CPhCntMatcherImpl::CreateMatcher();
-    if (!err && !iVoipMatchStrategy )
+    if ( !err && !iVoipMatchStrategy )
         {
         TRAP( err, iVoipMatchStrategy = 
             CPhCntVoipContactMatchStrategy::NewL( iContactManager, 
--- a/phoneengine/PhoneCntFinder/ContactService/src/cphcntspeeddialimpl.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/src/cphcntspeeddialimpl.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -106,14 +106,6 @@
         TInt aSpeedDialPosition, 
         TSpdDialFieldInfo& aFieldInfo )
     {
-    
-    MVPbkContactLink* contactLink = aContact.ContactLink()->CloneLC();
-    CPhCntVPbkContactId* contactId = 
-        CPhCntVPbkContactId::NewL( contactLink, iContactManager );
-    CleanupStack::Pop(); // contactLink
-    aFieldInfo.iContactId = contactId;
-        
-    aFieldInfo.iThumbIndex = KErrNotFound;
 	TPhCntNumber speedDial = aContact.SpeedDialNumber( aSpeedDialPosition );    
 	aFieldInfo.iNumberType = speedDial.Type();
     }
@@ -260,6 +252,9 @@
     TInt err = iSpdDial->ShowAssign( aSpeedDialPosition, link );
     delete iSpdDial;
     iSpdDial = NULL;
+    delete link;
+    link = NULL;
+    
     if ( err == KErrNone )
         {
         err = FetchNumberL( aSpeedDialPosition, aPhoneNumber );    
--- a/phoneengine/PhoneCntFinder/ContactService/src/tphcntservicerequestparams.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/ContactService/src/tphcntservicerequestparams.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -249,8 +249,6 @@
 
     aContactManager.AppendFilterToSelectorL( *iContactViewFilter,   
         EVPbkContactViewFilterPhoneNumber );
-    
-	iDefaultPriorities.Append( EVPbkDefaultTypePhoneNumber );    
 	
     TAiwSingleItemSelectionDataV3 data = TAiwSingleItemSelectionDataV3();
 	  
--- a/phoneengine/PhoneCntFinder/inc/CPhCntMatcher.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/inc/CPhCntMatcher.h	Thu Jul 15 18:38:16 2010 +0300
@@ -102,7 +102,7 @@
         /**
         * Match number to phonebook.
         * @param aMatch Found match, owership tranferred. NULL if not found any.
-        * @param aNumber Number to match against.
+        * @param aMatchString Number to match against.
         * @param aAllowUsernameMatch 
         *						is ETrue if username is sufficient for match.
         * @param aContactStoreUris
@@ -116,7 +116,7 @@
         */    
         virtual TInt MatchVoipNumber(
             MPhCntMatch*& aMatch,
-            const TDesC& aNumber,
+            const TDesC& aMatchString,
             const TBool aAllowUsernameMatch,
             MDesCArray* aContactStoreUris,
             TInt aCharsForMatching = 0 ) = 0;
@@ -126,6 +126,7 @@
         * by contact id.
         * @since Series60 3.0
         * @param aMatch for found match, owership tranferred. Empty if not found.
+        * @param aMatchString Number to match against.
         * @param aContactId for current contact.
         * @return Error code: KErrNone - VoIP call contact found
         *                     KErrNotFound - no VoIP call contact found
@@ -133,6 +134,7 @@
         */    
         virtual TInt MatchVoipNumber(
             MPhCntMatch*& aMatch,
+            const TDesC& aMatchString,
             const CPhCntContactId& aContactId ) = 0;
             
         /**
--- a/phoneengine/PhoneCntFinder/inc/Misc/CPhCntSpeedDialMonitor.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/PhoneCntFinder/inc/Misc/CPhCntSpeedDialMonitor.h	Thu Jul 15 18:38:16 2010 +0300
@@ -49,12 +49,7 @@
         */
         struct TSpdDialFieldInfo
             {
-            CPhCntContactId* iContactId;
-            
             MPhCntMatch::TNumberType iNumberType;
-            
-            // Thumbnail index of a grid array.
-            TInt iThumbIndex;
             };
         
         /**
--- a/phoneengine/contacthandling/src/cpecontactmatch.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneengine/contacthandling/src/cpecontactmatch.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -81,7 +81,7 @@
     delete iSpeedDialCommand;
     if ( iContactThumbnailLoader && iThumbnailId )
         {
-      	iContactThumbnailLoader->Cancel( iThumbnailId );
+        iContactThumbnailLoader->Cancel( iThumbnailId );
         }
     delete iThumbnailImage;
     delete iContactThumbnailLoader;
@@ -194,11 +194,10 @@
 void CPEContactMatch::MatchWithContactIdL(
         const TInt aCallId
         )
-
     {
     TEFLOGSTRING( KTAINT, "CNT CPEContactMatch::MatchWithContactIdL" );
     MPhCntMatch* match( NULL );
-    CPhCntContactId* contactId = NULL;
+    CPhCntContactId* contactId( NULL );
     contactId = CreateContactIdL( iDataStore.CallClientInformation( aCallId ).ContactLink() );
     CleanupStack::PushL( contactId );
     if ( iDataStore.CallType( aCallId ) == EPECallTypeVoIP )
@@ -208,6 +207,7 @@
             TEFLOGSTRING( KTAINT, "CNT CPEContactMatch::MatchWithContactIdL > CPhCntMatcher::MatchVoipNumber" );
             // Get contact based on contact id.
             iContactMatcher->MatchVoipNumber( match, 
+                                              iDataStore.RemotePhoneNumber( aCallId ),
                                               *contactId );
             }
         else
@@ -220,9 +220,9 @@
         if ( contactId && contactId->IsValid() )
             {
             TEFLOGSTRING( KTAINT, "CNT CPEContactMatch::MatchWithContactIdL > CPhCntMatcher::MatchNumber" );
-	        iContactMatcher->MatchNumber( match, 
-	                                      iDataStore.RemotePhoneNumber( aCallId ),
-	                                      *contactId );
+            iContactMatcher->MatchNumber( match, 
+                                          iDataStore.RemotePhoneNumber( aCallId ),
+                                          *contactId );
             }
         else
             {
@@ -230,7 +230,7 @@
             }
         }
 
-    if ( match != NULL )
+    if ( match )
         {
         TEFLOGSTRING( KTAINT, "CNT CPEContactMatch::MatchWithContactIdL, Contact match found" );
         CopyContactFieldsDataL( *match, aCallId );
@@ -277,7 +277,7 @@
         iContactMatcher->MatchNumber( match, remoteNumber );
         }
 
-    if ( match != NULL )
+    if ( match )
         {
         TEFLOGSTRING( KTAINT, "CNT CPEContactMatch::MatchWithNumberL, Contact match found" );
         CopyContactFieldsDataL( *match, aCallId );
@@ -645,7 +645,7 @@
 // -----------------------------------------------------------
 //
 CDesCArray* CPEContactMatch::StoreUrisForServiceL( TUint aServiceId )
-    {	
+    {
     CDesCArray* storeUris = new ( ELeave ) CDesC16ArrayFlat( 1 );
     CleanupStack::PushL( storeUris );
     
--- a/phoneuis/BubbleManager/Group/Bubblemanager.mmp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/Group/Bubblemanager.mmp	Thu Jul 15 18:38:16 2010 +0300
@@ -89,6 +89,7 @@
 source  BMNumberTypeIcon.cpp
 source  BMMainPaneControl.cpp
 source  BMTouchPaneButton.cpp
+SOURCE  telbubbleimagescaler.cpp
 
 sourcepath ../laf
 source  BMLayout.cpp
@@ -122,5 +123,5 @@
 LIBRARY akntransitionutils.lib
 #endif
 LIBRARY bmcustomization.lib
-
+LIBRARY bitmaptransforms.lib
 // End of File
--- a/phoneuis/BubbleManager/Inc/BMMainPaneControl.h	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/Inc/BMMainPaneControl.h	Thu Jul 15 18:38:16 2010 +0300
@@ -19,8 +19,9 @@
 #ifndef C_BUBBLEMAINPANECONTROL_H
 #define C_BUBBLEMAINPANECONTROL_H
 
+#include <coecntrl.h>
 #include "BMBubbleManager.h"
-#include <coecntrl.h>
+#include "telbubbleimagescaler.h"
 
 class CBubbleCallObjectManager;
 class CTelBubbleCustomElement;
@@ -34,7 +35,8 @@
  *  @lib BubbleManager.lib
  *  @since S60 v5.0
  */
-NONSHARABLE_CLASS( CBubbleMainPaneControl ) : public CCoeControl
+NONSHARABLE_CLASS( CBubbleMainPaneControl ) : public CCoeControl,
+    public MTelBubbleImageScalerObserver
     {
 public:
     /**
@@ -77,7 +79,18 @@
      * Returns ETrue when image is being displayed.
      */
     TBool IsUsed() const;
-        
+    
+    // from MTelBubbleImageScalerObserver    
+    /**
+     * Callback function from CTelBubbleImageScaler
+     * 
+     * @param aError Error happened during scaling
+     * @param aBitmap Scaled bitmap
+     * @return None 
+     */ 
+    void ImageScalingComplete
+                    (TInt aError, CFbsBitmap* aBitmap);
+            
 private:    
     CBubbleMainPaneControl( CBubbleManager& aCustomManager, 
                             CBubbleCallObjectManager& aCallObjectManager );
@@ -87,8 +100,10 @@
                           TBool& aBitmapOwnership, 
                           CFbsBitmap*& aMask,
                           TBool& aMaskOwnership,
-                          TBool aIsScalable ); 
+                          TBool aIsScalable,
+                          TBool aThumbnail = EFalse );
 
+    void StartScaling( CFbsBitmap *aSourceBitmap );
 private: // data
     CBubbleManager& iBubbleManager;
     CBubbleCallObjectManager& iCallObjectManager;
@@ -98,6 +113,11 @@
     TBool iIsUsed;
     CFbsBitmap* iBitmap; // not owned
     CFbsBitmap* iMask; // not owned
+    CTelBubbleImageScaler *iScaler;
+    CFbsBitmap *iScaledImage;
+    
+    // to prevent loading & scaling the same image again.
+    CFbsBitmap* iOldBitmap;	
     };
 
 #endif // C_BUBBLEMAINPANECONTROL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phoneuis/BubbleManager/Inc/telbubbleimagescaler.h	Thu Jul 15 18:38:16 2010 +0300
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Ctelbubbleimagescaler declaration
+*
+*/
+
+#ifndef TELBUBBLEIMAGESCALER_H
+#define TELBUBBLEIMAGESCALER_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CFbsBitmap;
+class CBitmapScaler;
+
+/**
+ *  Interface to observe scaling status
+ */
+class MTelBubbleImageScalerObserver
+{
+public:
+    /**
+     * Callback to indicate scaling completion
+     * 
+     * @param aError Error occured during scaling
+     * @param aBitmap Scaled bitmap
+     */
+    virtual void ImageScalingComplete
+                (TInt aError, CFbsBitmap* aBitmap) = 0;
+    };
+
+/**
+ *  Asynchronous bitmap scaler.
+ *  Uses CBitmapScaler to do scaling
+ */
+class CTelBubbleImageScaler : public CActive
+{
+public:
+    // Cancel and destroy
+    ~CTelBubbleImageScaler();
+
+    /** Two phase constructor */
+    static CTelBubbleImageScaler* NewL(MTelBubbleImageScalerObserver& aObserver);
+
+    /** Two phase constructor */
+    static CTelBubbleImageScaler* NewLC(MTelBubbleImageScalerObserver& aObserver);
+    
+    /**
+     *  Scaling status
+     */
+    enum TState
+        {
+        EScalingIdle = 0, EScalingStarted, EScalingDone
+        };
+
+public:
+    /**
+     * Starts bitmap scaling Asynchronously 
+     * @param aSrc Bitmap that needs to be scaled
+     * @param aTarget Scaled bitmap
+     * @return None.
+     */
+    void StartScaleL(CFbsBitmap* aSrc, CFbsBitmap* aTarget);
+    
+    /**
+     * Sets the state of Scaler 
+     * @param aState State to be set
+     * @return None.
+     */
+    void SetState(TState aState);
+    
+    /**
+     * Returns the current state of Scaler 
+     * @param None
+     * @return TInt State of the scaler
+     */   
+    TInt GetState();
+
+private:
+    /* constructor */
+    CTelBubbleImageScaler(MTelBubbleImageScalerObserver& aObserver);
+
+    /* Second-phase constructor */
+    void ConstructL();
+
+private: // From CActive
+    /*
+     * Handle completion
+     */
+    void RunL();
+
+    /*
+     * Cancels active request
+     */
+    void DoCancel();
+
+    /*
+     * Override to handle leaves from RunL(). Default implementation causes
+     * the active scheduler to panic.
+     */
+    TInt RunError(TInt aError);
+
+private:
+    /* 
+     * Scaler observer instance 
+     */
+    MTelBubbleImageScalerObserver& iObserver;
+    
+    /*
+     * Own: Bitmap scaler
+     */
+    CBitmapScaler* iScaler;
+    
+    /* 
+     * Own: The bitmap that is scaled.
+     */
+    CFbsBitmap* iScaledBitmap;
+
+    /*
+     * Scaler state
+     */
+    TInt iState;
+    };
+
+#endif // TELBUBBLEIMAGESCALER_H
+
+// End of File
+
--- a/phoneuis/BubbleManager/Src/BMCallObjectManager.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/Src/BMCallObjectManager.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -167,36 +167,52 @@
     
     TSize sourceSize( iMediaReader->SourceSize() );
     
-    TReal scaleFactor;
-    TRect clipRect;
-    TSize targetSize;
-    if ( BubbleCallObjectUtils::GetScaleFactorAndClipRect(
+    TReal scaleFactor( 0 );
+    TRect clipRect( 0, 0, 0, 0 );
+    TSize targetSize( 0, 0 );
+    
+    // if the caller image (source size) is bigger than aPreferredImageSize (the whole caller-image area)
+    // then some down scaling is required.
+    if ( sourceSize.iHeight > aPreferredImageSize.iHeight && sourceSize.iWidth > aPreferredImageSize.iWidth )
+        {
+        targetSize = aPreferredImageSize;
+        
+        BubbleCallObjectUtils::GetScaleFactorAndClipRect(
              sourceSize,
              aPreferredImageSize,
              BubbleCallObjectUtils::EFillTarget,
              scaleFactor,
-             clipRect ) &&
-         aTinyImageSize != TSize(0,0) )
+             clipRect ); 
+        }
+    else // no scaling. wide or tall images gets cropped from center if required.
         {
-        // Tiny image
-        BubbleCallObjectUtils::GetScaleFactorAndClipRect(
-             sourceSize,
-             aTinyImageSize,
-             BubbleCallObjectUtils::EMaximumFit,
-             scaleFactor,
-             clipRect );
-        
-        targetSize = aTinyImageSize;           
+        targetSize = aPreferredImageSize;
+        scaleFactor = 1;
+        TInt x_offset = 0;
+        TInt y_offset = 0;
+
+        if ( sourceSize.iWidth > aPreferredImageSize.iWidth )
+            {
+            x_offset = ( sourceSize.iWidth - aPreferredImageSize.iWidth ) / 2;
+            }
+        if ( sourceSize.iHeight > aPreferredImageSize.iHeight )
+            {
+            y_offset = ( sourceSize.iHeight - aPreferredImageSize.iHeight ) / 2; 
+            }
+
+        clipRect = sourceSize;
+                
+        if ( x_offset > 0 || y_offset > 0 )
+            {
+            // clip from center of the source image
+            clipRect.Shrink( x_offset, y_offset );
+            }
         }
-    else
-        {
-        targetSize = aPreferredImageSize;    
-        }        
-    
+
     iMediaReader->StartReadingL( targetSize, 
                                  scaleFactor, 
                                  clipRect, 
-                                 this );    
+                                 this );   
     }
 
 // ---------------------------------------------------------------------------
--- a/phoneuis/BubbleManager/Src/BMMainPaneControl.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/Src/BMMainPaneControl.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -28,6 +28,8 @@
 #include <AknIconUtils.h>
 #include <layoutmetadata.cdl.h>
 
+#define SCALE_FACTOR 1.5
+
 // ---------------------------------------------------------------------------
 // C++ constructor
 // ---------------------------------------------------------------------------
@@ -36,7 +38,9 @@
     CBubbleManager& aBubbleManager,  
     CBubbleCallObjectManager& aCallObjectManager ) : 
     iBubbleManager( aBubbleManager ), 
-    iCallObjectManager ( aCallObjectManager )
+    iCallObjectManager ( aCallObjectManager ),
+    iScaler( NULL ),
+    iScaledImage( NULL )
     {
     }
 
@@ -46,6 +50,7 @@
 //
 void CBubbleMainPaneControl::ConstructL()
     {
+    iScaler = CTelBubbleImageScaler::NewL( *this );
     }
 
 // ---------------------------------------------------------------------------
@@ -72,6 +77,11 @@
 //
 CBubbleMainPaneControl::~CBubbleMainPaneControl()
     {
+    delete iScaler;
+    iScaler = NULL;
+    
+    delete iScaledImage;
+    iScaledImage = NULL;	
     }
 
 // ---------------------------------------------------------------------------
@@ -82,23 +92,49 @@
     const CBubbleHeader& aHeader )
     {
     iBubble = aHeader.BubbleId();
-    iBitmap = aHeader.CallObjectImage();
-    iMask = aHeader.CallObjectImageMask();
+    TBool thumbnail( EFalse );
+    TBool noScaling( EFalse );
+    
+    if ( aHeader.CallObjectImage() )
+        {
+        iBitmap = aHeader.CallObjectImage();
+        iMask = aHeader.CallObjectImageMask();
+        }
+    else if ( aHeader.TnBitmap() )
+        {
+        iBitmap = aHeader.TnBitmap();
+        iMask = aHeader.TnBitmapMask();
+        thumbnail = ETrue;
+        }
+    else
+        {
+        iBitmap = NULL;
+        }
+    
     iThreeLinedBubble = ( aHeader.CNAP().Length() > 0 );
     
+    // PrepareBitmapsL() needs to know if a brand new thumbnail is about to get prepared.
+    if ( thumbnail && (iOldBitmap != NULL) && (iOldBitmap == iBitmap) && (iScaler->GetState() != CTelBubbleImageScaler::EScalingStarted) )
+        {
+        noScaling = ETrue;
+        }
+    
     if ( iBitmap )
         {
-        CFbsBitmap* bitmap;
-        CFbsBitmap* mask;
-        TBool bitmapOwnership;
-        TBool maskOwnership;
+        iOldBitmap = iBitmap;
+        
+        CFbsBitmap* bitmap( NULL );
+        CFbsBitmap* mask( NULL );
+        TBool bitmapOwnership( EFalse );
+        TBool maskOwnership( EFalse );
         
         TRAPD(err, PrepareBitmapsL( bitmap, 
                                     bitmapOwnership, 
                                     mask, 
                                     maskOwnership,
                                     aHeader.CallObjectImageType() == 
-                                    CBubbleHeader::EThemeImage ) );
+                                    CBubbleHeader::EThemeImage,
+                                    noScaling ));
         
         if ( err )
             {
@@ -119,6 +155,12 @@
         
         iIsUsed = ETrue;
         MakeVisible( ETrue );
+        
+        // upscale thumbnails if loading it for the first time.
+        if ( thumbnail && !noScaling && ( iScaler->GetState() != CTelBubbleImageScaler::EScalingStarted ) )
+            {
+            StartScaling( iBitmap );
+            }
         }
     }
 
@@ -131,9 +173,18 @@
     TBool& aBitmapOwnership, 
     CFbsBitmap*& aMask,
     TBool& aMaskOwnership,
-    TBool aIsScalable )
+    TBool aIsScalable,
+    TBool aThumbnail )
     {
-    aBitmap = iBitmap;
+    if ( aThumbnail )
+        {
+        aBitmap = iScaledImage;
+        }
+    else
+        {
+        aBitmap = iBitmap;
+        }
+
     aMask = iMask;
     aBitmapOwnership = EFalse;
     aMaskOwnership = EFalse;
@@ -278,5 +329,117 @@
         }
     }
 
+// ---------------------------------------------------------------------------
+// CTelBubbleCallImage::ImageScalingComplete
+//
+// ---------------------------------------------------------------------------
+//
+void CBubbleMainPaneControl::ImageScalingComplete( TInt aError,
+        CFbsBitmap* aBitmap )
+    {
+    if ( aError == KErrNone )
+        {
+        // Draw the scaled image
+        iScaledImage = aBitmap;
+        iScaler->SetState( CTelBubbleImageScaler::EScalingDone );
+        
+        CFbsBitmap* bitmap( NULL );
+        CFbsBitmap* mask( NULL );
+        TBool bitmapOwnership( EFalse );
+        TBool maskOwnership( EFalse );
+      
+        TRAPD(err, PrepareBitmapsL( bitmap, 
+                                    bitmapOwnership, 
+                                    mask, 
+                                    maskOwnership,
+                                    EFalse,
+                                    ETrue ) );
+        
+        if ( err )
+            {
+            return;
+            }
+                
+        if ( iCallImage->ControlType() == 
+             CTelBubbleCustomElement::EBubbleCallImage )
+            {
+            CTelBubbleCallImage* image = 
+                static_cast<CTelBubbleCallImage*> ( iCallImage->Control() );
+            image->SetImage( bitmap, EFalse, mask, maskOwnership );
+            } 
+
+        SizeChanged();
+        
+        iIsUsed = ETrue;
+        MakeVisible( ETrue );
+        
+        Parent()->DrawNow(); // refreshing view with scaled image
+        }
+    else if ( aError == KErrCancel )
+        {
+        // error is ignored
+        // This error is returned when a previous scaling is cancelled
+        // while new scaling request is given to active object
+        }
+    else
+        {
+        // draw the unscaled image in error cases
+    
+        delete iScaledImage;
+        iScaledImage = NULL;
+        }
+    
+    iScaler->SetState( CTelBubbleImageScaler::EScalingDone );
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleCallImage::StartScaling
+//
+// ---------------------------------------------------------------------------
+//
+void CBubbleMainPaneControl::StartScaling( CFbsBitmap *aSourceBitmap )
+    {
+    if ( !iScaler )
+        {
+        return;
+        }
+    
+    iScaler->Cancel(); // cancels any outstanding scaling requests
+    
+    delete iScaledImage;
+    iScaledImage = NULL;
+
+    // create a bitmap for scaled size
+    TRAPD( err, iScaledImage = new (ELeave) CFbsBitmap );
+    if ( err != KErrNone )
+        {
+        // no scaling in error cases
+        iScaler->SetState( CTelBubbleImageScaler::EScalingIdle );
+        return;
+        }
+
+    TSize size = aSourceBitmap->SizeInPixels();
+    TRect scaledRect( 0, 0, size.iWidth * SCALE_FACTOR, size.iHeight * SCALE_FACTOR );
+    
+    TRAP( err, iScaledImage->Create( scaledRect.Size(), aSourceBitmap->DisplayMode() ) );
+    if ( err != KErrNone )
+        {
+        delete iScaledImage;
+        iScaledImage = NULL;
+        iScaler->SetState( CTelBubbleImageScaler::EScalingIdle );
+        }
+    else
+        {
+        //start scaling
+        TRAPD( err, iScaler->StartScaleL( aSourceBitmap, iScaledImage ) );
+        if (err != KErrNone)
+            {
+            iScaler->SetState( CTelBubbleImageScaler::EScalingIdle );
+            delete iScaledImage;
+            iScaledImage = NULL;
+            }
+        }
+    }
+	
 // END OF FILE
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phoneuis/BubbleManager/Src/telbubbleimagescaler.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Ctelbubbleimagescaler implementation
+*
+*/
+
+#include "telbubbleimagescaler.h"
+#include "BMBubbleDebug.h"
+#include <bitmaptransforms.h>
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CTelBubbleImageScaler::CTelBubbleImageScaler(
+        MTelBubbleImageScalerObserver& aObserver) :
+    CActive(CActive::EPriorityStandard), iObserver(aObserver), iState(EScalingIdle),
+    iScaler( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CTelBubbleImageScaler* CTelBubbleImageScaler::NewLC(
+        MTelBubbleImageScalerObserver& aObserver)
+    {
+    CTelBubbleImageScaler* self = new (ELeave) CTelBubbleImageScaler(
+            aObserver);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CTelBubbleImageScaler* CTelBubbleImageScaler::NewL(
+        MTelBubbleImageScalerObserver& aObserver)
+    {
+    CTelBubbleImageScaler* self = CTelBubbleImageScaler::NewLC(aObserver);
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CTelBubbleImageScaler::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CTelBubbleImageScaler::~CTelBubbleImageScaler()
+    {
+    if ( iScaler )
+        {
+        iScaler->Cancel(); // Cancel any request, if outstanding
+        }
+    
+    delete iScaler;
+    iState = EScalingIdle;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::StartScaleL
+// ---------------------------------------------------------------------------
+//
+void CTelBubbleImageScaler::StartScaleL(CFbsBitmap* aSrc, CFbsBitmap* aTarget)
+    {
+    BM_TRACE_( "CTelBubbleImageScaler::StartScaleL()" );
+    if ( !iScaler )
+        {
+        iScaler = CBitmapScaler::NewL();
+        }
+
+    iScaledBitmap = aTarget;
+
+    iScaler->SetQualityAlgorithm( CBitmapScaler::EMaximumQuality );
+    iScaler->Scale( &iStatus, *aSrc, *aTarget, EFalse );
+    iState = EScalingStarted;
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CTelBubbleImageScaler::DoCancel()
+    {
+    BM_TRACE_( "CTelBubbleImageScaler::DoCancel()" );
+    if ( iScaler )
+        {
+        iScaler->Cancel();
+        }
+    
+    iObserver.ImageScalingComplete( KErrCancel, iScaledBitmap );
+    iState = EScalingDone;
+    iScaledBitmap = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::RunL
+// ---------------------------------------------------------------------------
+//
+void CTelBubbleImageScaler::RunL()
+    {
+    BM_TRACE_( "CTelBubbleImageScaler::RunL()" );
+    iState = EScalingDone;
+    TInt status = iStatus.Int();
+    iObserver.ImageScalingComplete( status, iScaledBitmap );
+    iScaledBitmap = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CTelBubbleImageScaler::RunError( TInt aError )
+    {
+    BM_TRACE_( "CTelBubbleImageScaler::RunError()" );
+    iState = EScalingDone;
+    iObserver.ImageScalingComplete( aError, iScaledBitmap );
+    iScaledBitmap = NULL;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::SetState
+// ---------------------------------------------------------------------------
+//
+void CTelBubbleImageScaler::SetState(TState aState)
+    {
+    BM_TRACE_1( "CTelBubbleImageScaler::SetState(): %d", aState );
+    iState = aState;
+    }
+
+// ---------------------------------------------------------------------------
+// CTelBubbleImageScaler::GetState
+// ---------------------------------------------------------------------------
+//
+TInt CTelBubbleImageScaler::GetState()
+    {
+    BM_TRACE_1( "CTelBubbleImageScaler::GetState(): %d", iState );
+    return iState;
+    }
--- a/phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -203,60 +203,68 @@
         {
         return;                    
         }
-    
-    // If bitmap is bigger than drawing area then clip from center.
-    TRect rect;
-    if ( IsFullScreenImage() )
-        {
-        rect = Rect();
-        }
-    else
-        {
-        rect = ImagePlacingArea();
-        }
-    
+        
+    // If bitmap is bigger than drawing area then clip from center of the image.
+    TRect rect = Rect();
     iSourceRect = iImage->SizeInPixels();
-    
+
     TInt offsetX = ( iSourceRect.Width() > rect.Width() ) ? 
                    ((iSourceRect.Width() - rect.Width()) / 2) : 0;
     TInt offsetY = ( iSourceRect.Height() > rect.Height() ) ? 
                    ((iSourceRect.Height() - rect.Height()) / 2) : 0;
-    iSourceRect.Shrink( offsetX, offsetY );    
     
-    // If bitmap is smaller than drawing area then center it.
+    iSourceRect.Shrink( offsetX, offsetY ); 
+    
+    // If bitmap is smaller than the drawing area then center the image on it.
     iOffset.iX = ( iSourceRect.Width() < rect.Width() ) ? 
                 ((rect.Width() - iSourceRect.Width()) / 2) : 0;
-    iOffset.iY = ( iSourceRect.Height() < rect.Height() ) ? 
-                ((rect.Height() - iSourceRect.Height()) / 2) : 0;
+    
+    iOffset.iY = 0;
+    
+    // lift the image higher if needed.
+    if ( iSourceRect.Height() < rect.Height() )
+        {
+        // check if it fits totally above the bubble
+        TInt height = iImagePlacingArea.iBr.iY - iImagePlacingArea.iTl.iY;
+      
+        if ( iSourceRect.Height() < height )
+            {
+            // if it fits then center it above the bubble
+            iOffset.iY = ( height - iSourceRect.Height() ) / 2;
+            }
+        }
     }
 
-
 // ---------------------------------------------------------------------------
 // CTelBubbleCallImage::Draw
 // ---------------------------------------------------------------------------
 //
 EXPORT_C void CTelBubbleCallImage::Draw( const TRect& /*aRect*/ ) const
     {
-    if ( iImage ) 
+    if ( iImage )
         {
         CWindowGc& gc = SystemGc();
-        const TPoint topLeft = IsFullScreenImage() ? Rect().iTl : iImagePlacingArea.iTl;
+    
+        const TPoint topLeft = Rect().iTl;
         const TPoint bitmapTopLeft = topLeft + iOffset;
-       
-        if( iMask ) 
+    
+        // if we have y offset then the image wont go under the bubble in any case and so
+        // no need for masking
+        if ( iMask && iOffset.iY == 0 ) 
             {
             gc.BitBltMasked( bitmapTopLeft,
-                             iImage, 
-                             iSourceRect, 
-                             iMask, 
-                             EFalse );
+                         iImage, 
+                         iSourceRect, 
+                         iMask, 
+                         EFalse );
             }
-        else            
+        else
             {
             gc.BitBlt( bitmapTopLeft,
-                       iImage,
-                       iSourceRect );    
+                   iImage,
+                   iSourceRect );    
             }
+    
         DrawRoundRect( gc, bitmapTopLeft, iSourceRect.Size() );
         }
     }
--- a/phoneuis/BubbleManager/eabi/bubblemanageru.def	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/eabi/bubblemanageru.def	Thu Jul 15 18:38:16 2010 +0300
@@ -138,4 +138,5 @@
 	_ZTV25CBubbleOutlookNumberEntry @ 137 NONAME
 	_ZTV29CBubbleOutlookBottomImageCnap @ 138 NONAME
 	_ZTV29CBubbleOutlookBottomRightCnap @ 139 NONAME
-
+	_ZTI21CTelBubbleImageScaler @ 140 NONAME
+	_ZTV21CTelBubbleImageScaler @ 141 NONAME
--- a/phoneuis/dialer/src/cdialertoolbarcontainer.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/dialer/src/cdialertoolbarcontainer.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -471,13 +471,13 @@
     keyEvent.iCode = 0; // key code is always 0 for key up and down events
     keyEvent.iScanCode = EStdKeyBackspace;
 
-    iCoeEnv->SimulateKeyEventL( keyEvent, EEventKeyDown );
+    TRAP_IGNORE( iCoeEnv->SimulateKeyEventL( keyEvent, EEventKeyDown ) );
 
     keyEvent.iCode = EKeyBackspace;
-    iCoeEnv->SimulateKeyEventL( keyEvent, EEventKey );
+    TRAP_IGNORE( iCoeEnv->SimulateKeyEventL( keyEvent, EEventKey ) );
     
     keyEvent.iCode = 0;
-    iCoeEnv->SimulateKeyEventL( keyEvent, EEventKeyUp );
+    TRAP_IGNORE( iCoeEnv->SimulateKeyEventL( keyEvent, EEventKeyUp ) );
     }
 
 // end of file
--- a/phoneuis/easydialing/src/easydialingutils.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/easydialing/src/easydialingutils.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -80,18 +80,20 @@
             ptr.Append( KNameSeparatorChar );
             ptr.Append( *firstName );
             }        
-        } 
-    
-    // If firstname and last name are missing, duplicate company name into name field.
+        }
+
+    // If firstname and last name are missing, put company name into the first field.
     if ( ptr.Length() == 0 )
         {
         ptr.Append( *companyName );
         }
-    
-    // Append company name using tab as a separator.
-    ptr.Append( KListFieldSeparatorChar );
-    ptr.Append( *companyName );
-    
+    else
+        {
+        // Otherwise add company name into the second field using tab as a separator.
+        ptr.Append( KListFieldSeparatorChar );
+        ptr.Append( *companyName );
+        }
+
     CleanupStack::Pop( string );
     CleanupStack::PopAndDestroy( 3, firstName );
     CleanupStack::PushL( string );