phoneapp/phoneuivoipextension/src/cphoneunattendedtransfercmdhandler.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
child 69 8baf28733c3d
--- a/phoneapp/phoneuivoipextension/src/cphoneunattendedtransfercmdhandler.cpp	Tue Aug 31 15:14:29 2010 +0300
+++ b/phoneapp/phoneuivoipextension/src/cphoneunattendedtransfercmdhandler.cpp	Wed Sep 01 12:30:10 2010 +0100
@@ -17,6 +17,8 @@
 
 #include <featmgr.h>
 #include <mpeengineinfo.h>
+#include <StringLoader.h>
+
 #include "cphoneunattendedtransfercmdhandler.h"
 
 #include "cphonelogger.h"
@@ -32,6 +34,9 @@
 #include "tphonecmdparamquery.h"
 #include "tphonecmdparamglobalnote.h"
 #include "cphonemainresourceresolver.h"
+#include "cphonestatemachinevoip.h"
+#include "cphonestateutilsvoip.h"
+
 
 
 // ======== MEMBER FUNCTIONS ========
@@ -140,10 +145,30 @@
             iStateMachine.SendPhoneEngineMessage( 
                 MPEPhoneModel::EPEMessageDoUnattendedTransfer );
             
-            ShowWaitingAcceptanceNoteL();
+            if ( KErrNone == iStateMachine.PhoneEngineInfo()->
+                    ErrorInfo().iErrorCode )
+                {
+                ShowWaitingAcceptanceNoteL();
+                }
             }
             break;
-        
+        case EPhoneCmdUnattendedTransferCallBackOk:
+            {
+            MPEEngineInfo* info = iStateMachine.PhoneEngineInfo();
+            const TDesC& callBackToAddr = info->CallBackAddress();
+            // Service id used for last call is used to call back
+            TUint32 serviceId = info->ServiceIdCommand();
+            static_cast<CPhoneStateMachineVoIP&>( 
+                iStateMachine ).StateUtils().SelectServiceAndDialL( 
+                    callBackToAddr, serviceId );
+            }
+            break;
+        case EPhoneCmdUnattendedTransferCallBackCancel:
+            {
+            MPEEngineInfo* info = iStateMachine.PhoneEngineInfo();
+            info->SetCallBackAddress( KNullDesC );
+            }
+            break;
         default:
             __PHONELOG( EOnlyFatal, PhoneUIVoIPExtension, 
                 "CPhoneUnattendedTransferCmdHandler::HandleCommandL, DEFAULT" );    
@@ -160,7 +185,66 @@
     {
     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
         "CPhoneUnattendedTransferCmdHandler::ShowTransferDialerL" )
-
+    
+    CPhoneState* phoneState = static_cast<CPhoneState*>( iStateMachine.State() );
+    if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) )
+        {
+        TPhoneCmdParamCustomDialer customDialerParam;
+        customDialerParam.SetDialerController( iTransferDialerController );
+           
+        // Set dialer to transfer mode.
+        iViewCommandHandle.ExecuteCommandL( 
+            EPhoneViewShowCustomizedDialer,
+            &customDialerParam );
+        
+        // Open transfer dialer
+        phoneState->BeginTransEffectLC( ECallUiDisappear );
+        iViewCommandHandle.ExecuteCommandL( EPhoneViewCreateNumberEntry );
+        phoneState->EndTransEffect();
+        
+        // Update CBA to transfer dialer CBA
+        TPhoneCmdParamInteger resourceId;
+        resourceId.SetInteger( CPhoneMainResourceResolver::Instance()->
+            ResolveResourceID( iTransferDialerController->CbaResourceId() ) );
+        iViewCommandHandle.ExecuteCommandL( EPhoneViewUpdateCba,
+            &resourceId );
+        }
+    else
+        {
+        HBufC *text = HBufC::NewLC( KPhoneNumberEntryBufferSize );
+        TPtr ptr( text->Des() );
+        // Pre-populate the query with the number entry contents, if it exists
+        if ( phoneState->IsNumberEntryUsedL() )
+            {
+            // get the number entry contents
+            TPhoneCmdParamString stringParam;
+            stringParam.SetString( &ptr );
+            iViewCommandHandle.ExecuteCommandL(
+                EPhoneViewGetLocalizedNumberFromEntry,
+                &stringParam );
+            }
+        
+        TPhoneCmdParamQuery queryDialogParam;
+        queryDialogParam.SetQueryType( EPhoneGenericTextQuery );
+        queryDialogParam.SetQueryResourceId( 
+            CPhoneMainResourceResolver::Instance()->
+            ResolveResourceID( EPhoneVoIPTransferAddressQuery ) );
+        
+        queryDialogParam.SetDefaultCba( CPhoneMainResourceResolver::Instance()->
+            ResolveResourceID( EPhoneVoIPTransferAddressQueryEmptySoftkeys ) );
+        
+        queryDialogParam.SetContentCba( CPhoneMainResourceResolver::Instance()->
+            ResolveResourceID( EPhoneVoIPTransferAddressQueryNotEmptySoftkeys ) );
+        
+        queryDialogParam.SetDataText( &ptr );
+        queryDialogParam.SetSendKeyEnabled( ETrue );
+        
+        // Display dialog        
+        iViewCommandHandle.ExecuteCommandL( 
+            EPhoneViewShowQuery, &queryDialogParam );
+        
+        CleanupStack::PopAndDestroy( text );
+        }
     }
 
 
@@ -186,6 +270,13 @@
         iViewCommandHandle.ExecuteCommand(
             EPhoneViewGetNumberFromEntry,
             &transferTarget );  
+        
+        phoneState->CloseCustomizedDialerL();
+        }
+    else
+        {
+        iViewCommandHandle.ExecuteCommandL( 
+            EPhoneViewGetTextQueryContent, &transferTarget );
         }
     
     // Set transfer to address to the phoneengine
@@ -193,7 +284,10 @@
     iStateMachine.SendPhoneEngineMessage( 
         MPEPhoneModel::EPEMessageDoUnattendedTransfer );
     
-    ShowWaitingAcceptanceNoteL();
+    if ( KErrNone == iStateMachine.PhoneEngineInfo()->ErrorInfo().iErrorCode )
+        {
+        ShowWaitingAcceptanceNoteL();
+        }
     CleanupStack::PopAndDestroy( content );
     }
 
@@ -206,6 +300,10 @@
     {
     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
         "CPhoneUnattendedTransferCmdHandler::CloseTransferDialerL" )
+    
+    CPhoneState* phoneState = 
+        static_cast< CPhoneState* >( iStateMachine.State() );
+    phoneState->CloseCustomizedDialerL();
     }
 
 
@@ -222,9 +320,9 @@
     TPhoneCmdParamInteger integerParam;
     integerParam.SetInteger( aFetchType );
     
-    /*iViewCommandHandle.HandleCommandL( 
+    iViewCommandHandle.HandleCommandL( 
         EPhoneViewOpenSingleItemFetchDialog, 
-        &integerParam );*/
+        &integerParam );
     }
 
 // ---------------------------------------------------------------------------
@@ -235,13 +333,58 @@
     {
     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
         "CPhoneUnattendedTransferCmdHandler::ShowWaitingAcceptanceNoteL" )
-    //TODO: Show "Waiting acceptance..." note
-//    TPhoneCmdParamGlobalNote globalNoteParam;
-//    globalNoteParam.SetType( EAknGlobalWaitNote );
-//    globalNoteParam.SetTone( EAvkonSIDNoSound );
-//    globalNoteParam.SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
-//    globalNoteParam.SetTextResourceId( CPhoneMainResourceResolver::Instance()->
-//        ResolveResourceID( EPhoneVoIPWaitingAcceptanceNote ) );
-//    iViewCommandHandle.ExecuteCommandL( 
-//        EPhoneViewShowGlobalNote, &globalNoteParam );
+    // Show "Waiting acceptance..." note
+    TPhoneCmdParamGlobalNote globalNoteParam;
+    globalNoteParam.SetType( EAknGlobalWaitNote );
+    globalNoteParam.SetTone( EAvkonSIDNoSound );
+    globalNoteParam.SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
+    globalNoteParam.SetTextResourceId( CPhoneMainResourceResolver::Instance()->
+        ResolveResourceID( EPhoneVoIPWaitingAcceptanceNote ) );
+    iViewCommandHandle.ExecuteCommandL( 
+        EPhoneViewShowGlobalNote, &globalNoteParam );
     }
+
+// ---------------------------------------------------------------------------
+// CPhoneUnattendedTransferCmdHandler::LaunchCallBackQuery
+// ---------------------------------------------------------------------------
+//
+void CPhoneUnattendedTransferCmdHandler::LaunchCallBackQueryL()
+    {
+    __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
+          "CPhoneUnattendedTransferCmdHandler::LaunchCallBackQueryL() ")
+    MPEEngineInfo* info = iStateMachine.PhoneEngineInfo();
+    const TDesC& callBackToAddr = info->CallBackAddress();
+    // We cannot do call back if original call had private address
+    if ( callBackToAddr.Compare( KNullDesC ) == 0 )
+        {
+        return;
+        }
+          
+    TPhoneCmdParamQuery queryParam;
+    queryParam.SetQueryType( EPhoneGlobalMsgQuery );
+    
+    HBufC* msgHeader = 
+      StringLoader::LoadLC( CPhoneMainResourceResolver::Instance()->
+          ResolveResourceID( EPhoneVoIPTransferCallBackHeader ) );
+    queryParam.SetQueryPrompt( *msgHeader );
+         
+    HBufC* queryText = 
+      StringLoader::LoadLC( CPhoneMainResourceResolver::Instance()->
+          ResolveResourceID( 
+                  EPhoneVoIPTransferCallBackText ), callBackToAddr );
+    
+    queryParam.SetDataText( &queryText->Des() );
+    
+    queryParam.SetDefaultCba( R_AVKON_SOFTKEYS_OK_CANCEL );
+    
+    // configure custom command mappings for user responses
+    queryParam.SetCbaCommandMapping( 
+      EAknSoftkeyOk, EPhoneCmdUnattendedTransferCallBackOk );
+    queryParam.SetCbaCommandMapping( 
+      EAknSoftkeyCancel, EPhoneCmdUnattendedTransferCallBackCancel );
+    
+    iViewCommandHandle.ExecuteCommandL( EPhoneViewShowQuery, &queryParam );
+    
+    CleanupStack::PopAndDestroy( queryText );
+    CleanupStack::PopAndDestroy( msgHeader );
+    }