phoneapp/phoneuivoipextension/src/cphonetransferdialercontroller.cpp
branchRCL_3
changeset 61 41a7f70b3818
parent 9 8871b09be73b
child 62 5266b1f337bd
--- a/phoneapp/phoneuivoipextension/src/cphonetransferdialercontroller.cpp	Thu Aug 19 09:54:27 2010 +0300
+++ b/phoneapp/phoneuivoipextension/src/cphonetransferdialercontroller.cpp	Tue Aug 31 15:14:29 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2008 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"
@@ -19,17 +19,13 @@
 // INCLUDES
 #include <e32base.h>
 
+#include <akntoolbar.h>
 #include <AknsItemID.h>
-#include <AknsUtils.h>
 #include <StringLoader.h>
-
-#include <phoneui.mbg>
-#include <phoneui.rsg>
-#include <phoneuivoip.rsg>
-#include <data_caging_path_literals.hrh> // For KDC_APP_BITMAP_DIR
-
+#include "phoneresourceids.h"
 #include "phoneui.pan"
 #include "phonelogger.h"
+#include <data_caging_path_literals.hrh>
 #include "cphonetransferdialercontroller.h"
 #include "cphonemainresourceresolver.h"
 #include "phonerssvoip.h"
@@ -40,36 +36,12 @@
 // CONSTANTS
 _LIT ( KPhoneMifFileName, "phoneui.mif" );
 
-// Number of buttons 
-const TInt KButtonCount = 2;
-
-class TPhoneDialerToolbarButton 
-    {
-public:
-    TInt iIconIndex;
-    TInt iMaskIndex;
-    TInt iCommandId;    
-    };
-
-const TPhoneDialerToolbarButton bArray[KButtonCount] = 
-        {  
-            { EMbmPhoneuiQgn_indi_button_send_dtmf,
-              EMbmPhoneuiQgn_indi_button_send_dtmf_mask,
-              EPhoneCmdTransferDialerOk
-            },
-            { EMbmPhoneuiQgn_indi_dialer_contacts,
-              EMbmPhoneuiQgn_indi_dialer_contacts_mask,
-              EPhoneCmdTransferDialerSearch
-            }                 
-        };  
-
 // ================= MEMBER FUNCTIONS =======================
 
 // C++ default constructor can NOT contain any code, that
 // might leave.
 //  
 CPhoneTransferDialerController::CPhoneTransferDialerController()
-    : CPhoneDialerController( NULL, *CCoeEnv::Static() )
     {
     }
 
@@ -99,6 +71,29 @@
     }
 
 // -----------------------------------------------------------
+// CPhoneTransferDialerController::Initialize
+// -----------------------------------------------------------
+//
+void CPhoneTransferDialerController::InitializeL( CAknToolbar& aToolbar )
+    {  
+    __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
+        "CPhoneTransferDialerController::InitializeL()"); 
+    
+    if ( !iIsInitialized )
+        {    
+        __PHONELOG1( 
+                EAll, 
+                PhoneUIVoIPExtension, 
+                "Toolbar control count:=%d", 
+                aToolbar.CountComponentControls());
+        iToolbar = &aToolbar;
+        iIsInitialized = ETrue;
+        }
+   
+    iNumberEntryIsEmpty = ETrue;
+    }
+
+// -----------------------------------------------------------
 // CPhoneTransferDialerController::CbaResourceId
 // -----------------------------------------------------------
 //
@@ -113,7 +108,7 @@
 //
 TInt CPhoneTransferDialerController::MenuResourceId() const
     {
-    if ( !iNumberAvailable )
+    if ( iNumberEntryIsEmpty )
         {
         return EPhoneVoIPTransferDialerNumberEntryEmptyMenubar;
         }
@@ -135,138 +130,77 @@
         {
         iNumberEntryPromptText = StringLoader::LoadL( 
             CPhoneMainResourceResolver::Instance()->
-            ResolveResourceID( EPhoneVoIPTransferAddress ), &iCoeEnv );
+            ResolveResourceID( EPhoneVoIPTransferAddress ) );
         }  
     
     return *iNumberEntryPromptText;
     }
 
-// ---------------------------------------------------------------------------
-// GetButtonData
-// ---------------------------------------------------------------------------
+// -----------------------------------------------------------
+// CPhoneTransferDialerController::HandleNumberEntryIsEmpty
+// -----------------------------------------------------------
 //
-TInt CPhoneTransferDialerController::GetButtonData( TButtonIndex aIndex, RPointerArray<CButtonData>& aData ) const
+void CPhoneTransferDialerController::HandleNumberEntryIsEmpty( TBool aIsEmpty )
     {
-    TInt err = KErrNone;
-    
-    TInt arrayIdx = KErrNotFound;
-    if ( aIndex == ECallButton )
-        {
-        arrayIdx = 0;
-        }
-    else if ( aIndex == EPhonebookButton )
-        {
-        arrayIdx = 1;
-        }
-    
-    if ( arrayIdx >= 0 )
-        {
-        const TPhoneDialerToolbarButton& arrItem = bArray[ arrayIdx ];
-        CButtonData* btn = NULL;
-        TRAP( err, btn = CreateButtonDataL( arrItem.iCommandId, 
-                                            arrItem.iIconIndex, 
-                                            arrItem.iMaskIndex ) );
-        if ( !err )
-            {
-            err = aData.Append( btn );
-            if ( err )
-                {
-                delete btn;
-                }
-            }
-        }
-    else
-        {
-        // Trust base class on other buttons (i.e. the clear button)
-        err = CPhoneDialerController::GetButtonData( aIndex, aData );
-        }
-    
-    return err;
+    __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
+        "CPhoneTransferDialerController::HandleNumberEntryIsEmpty()");
+    __ASSERT_DEBUG( iToolbar, Panic( EPhoneCtrlInvariant ) );
+    iToolbar->SetItemDimmed( EPhoneCmdTransferDialerOk, aIsEmpty, EFalse );
+    iToolbar->SetItemDimmed( EPhoneCmdTransferDialerSearch, !aIsEmpty, EFalse );
+    iToolbar->SetItemDimmed( EPhoneDialerCmdClear, aIsEmpty, EFalse );
+    iNumberEntryIsEmpty = aIsEmpty;
     }
 
-// ---------------------------------------------------------------------------
-// ButtonState
-// ---------------------------------------------------------------------------
+// -----------------------------------------------------------
+// CPhoneTransferDialerController::ShowButtons
+// -----------------------------------------------------------
 //
-TInt CPhoneTransferDialerController::ButtonState( TButtonIndex aIndex ) const
+void CPhoneTransferDialerController::ShowButtons( TBool aShow )
     {
-    // Out button have only one state. Trust base class on clear button
-    if ( aIndex == ECallButton || aIndex == EPhonebookButton )
+    __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
+        "CPhoneTransferDialerController::ShowButtons()");
+    __ASSERT_DEBUG( iToolbar, Panic( EPhoneCtrlInvariant ) );
+    if ( aShow )
         {
-        return 0;
-        }
-    else
-        {
-        return CPhoneDialerController::ButtonState( aIndex );
+        iToolbar->SetItemDimmed( EPhoneCmdTransferDialerOk, ETrue, EFalse ); 
+        iToolbar->SetItemDimmed( EPhoneCmdTransferDialerSearch, EFalse, EFalse ); 
+        iToolbar->SetItemDimmed( EPhoneDialerCmdClear, ETrue, EFalse ); 
         }
     }
 
 // ---------------------------------------------------------------------------
-// ButtonDimmed
+// PhoneTransferDialerController::CreateButtonLC
 // ---------------------------------------------------------------------------
 //
-TBool CPhoneTransferDialerController::ButtonDimmed( TButtonIndex aIndex ) const
-    {
-    TBool dimmed = EFalse;
-    
-    // Ok is dimmed when there's no number. Search is dimmed when there is
-    // a number. Trust base class on clear button.
-    if ( aIndex == ECallButton )
-        {
-        dimmed = !iNumberAvailable;
-        }
-    else if ( aIndex == EPhonebookButton )
-        {
-        dimmed = iNumberAvailable;
-        }
-    else
-        {
-        dimmed = CPhoneDialerController::ButtonDimmed( aIndex );
-        }
-    return dimmed;
-    }
-
-// ---------------------------------------------------------------------------
-// EasyDialingAllowed
-// ---------------------------------------------------------------------------
-//
-TBool CPhoneTransferDialerController::EasyDialingAllowed() const
-    {
-    return EFalse;
-    }
-
-// ---------------------------------------------------------------------------
-// PhoneTransferDialerController::CreateButtonDataL
-// ---------------------------------------------------------------------------
-//
-MPhoneDialerController::CButtonData* CPhoneTransferDialerController::CreateButtonDataL(
-        TInt aCommandId,
-        TInt aNormalIconId,
-        TInt aNormalMaskId ) const
-    {
+CAknButton* CPhoneTransferDialerController::CreateButtonLC( 
+    TInt aNormalIconId,
+    TInt aNormalMaskId,
+    const TDesC& aTooltipText,
+    const TAknsItemID& aSkinIconId ) const
+    {   
     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
-            "CPhoneTransferDialerController::CreateButtonDataL()");
-    
-    // Load tooltip text.
-    HBufC* tooltipText = GetTooltipTextL( aCommandId );
-    CleanupStack::PushL( tooltipText );
-    
-    // Load icon
+        "CPhoneTransferDialerController::CreateButtonLC()");
     TFileName mifPath( KDriveZ );
     mifPath.Append( KDC_APP_BITMAP_DIR );
     mifPath.Append( KPhoneMifFileName );
-    
-    TAknsItemID skinId = SkinId( aNormalIconId );
-    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-    CGulIcon* icon = AknsUtils::CreateGulIconL( skin, skinId, mifPath, 
-                aNormalIconId, aNormalMaskId );
-    CleanupStack::PushL( icon );
-    
-    CButtonData* btnData = new (ELeave) CButtonData( aCommandId, icon, tooltipText );
-    CleanupStack::Pop( icon );
-    CleanupStack::Pop( tooltipText );
-    
-    return btnData;
+
+    CAknButton* button = CAknButton::NewLC( 
+        mifPath,
+        aNormalIconId,
+        aNormalMaskId,
+        -1, -1, // dimmed
+        -1, -1, // pressed
+        -1, -1, // hover
+        KNullDesC,
+        aTooltipText, // help
+        0, // flags
+        0, // state flags
+        aSkinIconId );
+                                                                 
+    button->SetFocusing( EFalse );
+    button->SetBackground( iToolbar );
+
+    return button;
     }
 
 // ---------------------------------------------------------------------------
@@ -290,16 +224,13 @@
             resourceId = R_VOIP_DIALER_TOOLTIP_SEARCH;
             break;                      
        default:
+           tooltip = KNullDesC().Alloc();
            break;
        }
            
     if ( resourceId )
         {
-        tooltip = StringLoader::LoadL( resourceId, &iCoeEnv );
-        }
-    else
-        {
-        tooltip = KNullDesC().AllocL();
+        tooltip = StringLoader::LoadL( resourceId, CCoeEnv::Static() );
         }
     return tooltip;
     }
@@ -308,22 +239,9 @@
 // CPhoneTransferDialerController::SkinId
 // ---------------------------------------------------------------------------
 //    
-TAknsItemID CPhoneTransferDialerController::SkinId( TInt aIconIndex ) const
+TAknsItemID CPhoneTransferDialerController::SkinId( TInt /*aIconIndex*/ ) const
     {
     TAknsItemID skinId;
-    
-    switch ( aIconIndex )
-        {
-        case EMbmPhoneuiQgn_indi_button_send_dtmf:
-            skinId = KAknsIIDQgnIndiButtonSendDtmf;
-            break;
-        case EMbmPhoneuiQgn_indi_dialer_contacts:
-            skinId = KAknsIIDQgnIndiDialerContacts;
-            break;                     
-        default:
-            skinId = KAknsIIDNone;        
-            break;            
-        }
-    
+    skinId = KAknsIIDNone; 
     return skinId;  
     }