phoneapp/phoneuivoipextension/src/cphonetransferdialercontroller.cpp
branchRCL_3
changeset 3 8871b09be73b
parent 0 5f000ab63145
child 24 41a7f70b3818
equal deleted inserted replaced
2:c84cf270c54f 3:8871b09be73b
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 
    18 
    19 // INCLUDES
    19 // INCLUDES
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 
    21 
    22 #include <akntoolbar.h>
       
    23 #include <AknsItemID.h>
    22 #include <AknsItemID.h>
       
    23 #include <AknsUtils.h>
    24 #include <StringLoader.h>
    24 #include <StringLoader.h>
    25 
    25 
    26 #include <phoneui.mbg>
    26 #include <phoneui.mbg>
    27 #include <phoneui.rsg>
    27 #include <phoneui.rsg>
    28 #include <phoneuivoip.rsg>
    28 #include <phoneuivoip.rsg>
    67 
    67 
    68 // C++ default constructor can NOT contain any code, that
    68 // C++ default constructor can NOT contain any code, that
    69 // might leave.
    69 // might leave.
    70 //  
    70 //  
    71 CPhoneTransferDialerController::CPhoneTransferDialerController()
    71 CPhoneTransferDialerController::CPhoneTransferDialerController()
       
    72     : CPhoneDialerController( NULL, *CCoeEnv::Static() )
    72     {
    73     {
    73     }
    74     }
    74 
    75 
    75 // -----------------------------------------------------------
    76 // -----------------------------------------------------------
    76 // CPhoneTransferDialerController::~CPhoneTransferDialerController()
    77 // CPhoneTransferDialerController::~CPhoneTransferDialerController()
    96   
    97   
    97     return self;
    98     return self;
    98     }
    99     }
    99 
   100 
   100 // -----------------------------------------------------------
   101 // -----------------------------------------------------------
   101 // CPhoneTransferDialerController::Initialize
       
   102 // -----------------------------------------------------------
       
   103 //
       
   104 void CPhoneTransferDialerController::InitializeL( CAknToolbar& aToolbar )
       
   105     {  
       
   106     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   107         "CPhoneTransferDialerController::InitializeL()"); 
       
   108     
       
   109     if ( !iIsInitialized )
       
   110         {    
       
   111         __PHONELOG1( 
       
   112                 EAll, 
       
   113                 PhoneUIVoIPExtension, 
       
   114                 "Toolbar control count:=%d", 
       
   115                 aToolbar.CountComponentControls());
       
   116         iToolbar = &aToolbar;
       
   117         // Create transfer specific buttons and add them to the 
       
   118         // toolbar starting from index 0
       
   119         CAknButton* button( NULL );
       
   120     
       
   121         for( TInt i = 0; i < KButtonCount; i++ )
       
   122             {
       
   123             TAknsItemID skinId = SkinId( bArray[i].iIconIndex );
       
   124             // Load tooltip text.
       
   125             HBufC* tooltipText = GetTooltipTextL( bArray[i].iCommandId );  
       
   126             CleanupStack::PushL( tooltipText );
       
   127             button = CreateButtonLC(
       
   128                     bArray[i].iIconIndex, 
       
   129                     bArray[i].iMaskIndex, 
       
   130                     *tooltipText, 
       
   131                     skinId );
       
   132             // Toolbar takes ownership of the button                    
       
   133             iToolbar->AddItemL( button, EAknCtButton, bArray[i].iCommandId, 0, i );
       
   134             CleanupStack::Pop( button );
       
   135             CleanupStack::PopAndDestroy( tooltipText );
       
   136             }      
       
   137         iIsInitialized = ETrue;
       
   138         }
       
   139    
       
   140     iNumberEntryIsEmpty = ETrue;
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------
       
   144 // CPhoneTransferDialerController::CbaResourceId
   102 // CPhoneTransferDialerController::CbaResourceId
   145 // -----------------------------------------------------------
   103 // -----------------------------------------------------------
   146 //
   104 //
   147 TInt CPhoneTransferDialerController::CbaResourceId() const
   105 TInt CPhoneTransferDialerController::CbaResourceId() const
   148     {
   106     {
   153 // CPhoneTransferDialerController::MenuResourceId
   111 // CPhoneTransferDialerController::MenuResourceId
   154 // -----------------------------------------------------------
   112 // -----------------------------------------------------------
   155 //
   113 //
   156 TInt CPhoneTransferDialerController::MenuResourceId() const
   114 TInt CPhoneTransferDialerController::MenuResourceId() const
   157     {
   115     {
   158     if ( iNumberEntryIsEmpty )
   116     if ( !iNumberAvailable )
   159         {
   117         {
   160         return EPhoneVoIPTransferDialerNumberEntryEmptyMenubar;
   118         return EPhoneVoIPTransferDialerNumberEntryEmptyMenubar;
   161         }
   119         }
   162     else
   120     else
   163         {
   121         {
   175         "CPhoneTransferDialerController::NumberEntryPromptTextL()");
   133         "CPhoneTransferDialerController::NumberEntryPromptTextL()");
   176     if ( !iNumberEntryPromptText )
   134     if ( !iNumberEntryPromptText )
   177         {
   135         {
   178         iNumberEntryPromptText = StringLoader::LoadL( 
   136         iNumberEntryPromptText = StringLoader::LoadL( 
   179             CPhoneMainResourceResolver::Instance()->
   137             CPhoneMainResourceResolver::Instance()->
   180             ResolveResourceID( EPhoneVoIPTransferAddress ) );
   138             ResolveResourceID( EPhoneVoIPTransferAddress ), &iCoeEnv );
   181         }  
   139         }  
   182     
   140     
   183     return *iNumberEntryPromptText;
   141     return *iNumberEntryPromptText;
   184     }
   142     }
   185 
   143 
   186 // -----------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   187 // CPhoneTransferDialerController::HandleNumberEntryIsEmpty
   145 // GetButtonData
   188 // -----------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   189 //
   147 //
   190 void CPhoneTransferDialerController::HandleNumberEntryIsEmpty( TBool aIsEmpty )
   148 TInt CPhoneTransferDialerController::GetButtonData( TButtonIndex aIndex, RPointerArray<CButtonData>& aData ) const
       
   149     {
       
   150     TInt err = KErrNone;
       
   151     
       
   152     TInt arrayIdx = KErrNotFound;
       
   153     if ( aIndex == ECallButton )
       
   154         {
       
   155         arrayIdx = 0;
       
   156         }
       
   157     else if ( aIndex == EPhonebookButton )
       
   158         {
       
   159         arrayIdx = 1;
       
   160         }
       
   161     
       
   162     if ( arrayIdx >= 0 )
       
   163         {
       
   164         const TPhoneDialerToolbarButton& arrItem = bArray[ arrayIdx ];
       
   165         CButtonData* btn = NULL;
       
   166         TRAP( err, btn = CreateButtonDataL( arrItem.iCommandId, 
       
   167                                             arrItem.iIconIndex, 
       
   168                                             arrItem.iMaskIndex ) );
       
   169         if ( !err )
       
   170             {
       
   171             err = aData.Append( btn );
       
   172             if ( err )
       
   173                 {
       
   174                 delete btn;
       
   175                 }
       
   176             }
       
   177         }
       
   178     else
       
   179         {
       
   180         // Trust base class on other buttons (i.e. the clear button)
       
   181         err = CPhoneDialerController::GetButtonData( aIndex, aData );
       
   182         }
       
   183     
       
   184     return err;
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // ButtonState
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt CPhoneTransferDialerController::ButtonState( TButtonIndex aIndex ) const
       
   192     {
       
   193     // Out button have only one state. Trust base class on clear button
       
   194     if ( aIndex == ECallButton || aIndex == EPhonebookButton )
       
   195         {
       
   196         return 0;
       
   197         }
       
   198     else
       
   199         {
       
   200         return CPhoneDialerController::ButtonState( aIndex );
       
   201         }
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // ButtonDimmed
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 TBool CPhoneTransferDialerController::ButtonDimmed( TButtonIndex aIndex ) const
       
   209     {
       
   210     TBool dimmed = EFalse;
       
   211     
       
   212     // Ok is dimmed when there's no number. Search is dimmed when there is
       
   213     // a number. Trust base class on clear button.
       
   214     if ( aIndex == ECallButton )
       
   215         {
       
   216         dimmed = !iNumberAvailable;
       
   217         }
       
   218     else if ( aIndex == EPhonebookButton )
       
   219         {
       
   220         dimmed = iNumberAvailable;
       
   221         }
       
   222     else
       
   223         {
       
   224         dimmed = CPhoneDialerController::ButtonDimmed( aIndex );
       
   225         }
       
   226     return dimmed;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // EasyDialingAllowed
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 TBool CPhoneTransferDialerController::EasyDialingAllowed() const
       
   234     {
       
   235     return EFalse;
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // PhoneTransferDialerController::CreateButtonDataL
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 MPhoneDialerController::CButtonData* CPhoneTransferDialerController::CreateButtonDataL(
       
   243         TInt aCommandId,
       
   244         TInt aNormalIconId,
       
   245         TInt aNormalMaskId ) const
   191     {
   246     {
   192     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
   247     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
   193         "CPhoneTransferDialerController::HandleNumberEntryIsEmpty()");
   248             "CPhoneTransferDialerController::CreateButtonDataL()");
   194     __ASSERT_DEBUG( iToolbar, Panic( EPhoneCtrlInvariant ) );
   249     
   195     iToolbar->SetItemDimmed( EPhoneCmdTransferDialerOk, aIsEmpty, EFalse );
   250     // Load tooltip text.
   196     iToolbar->SetItemDimmed( EPhoneCmdTransferDialerSearch, !aIsEmpty, EFalse );
   251     HBufC* tooltipText = GetTooltipTextL( aCommandId );
   197     iToolbar->SetItemDimmed( EPhoneDialerCmdClear, aIsEmpty, EFalse );
   252     CleanupStack::PushL( tooltipText );
   198     iNumberEntryIsEmpty = aIsEmpty;
   253     
   199     }
   254     // Load icon
   200 
       
   201 // -----------------------------------------------------------
       
   202 // CPhoneTransferDialerController::ShowButtons
       
   203 // -----------------------------------------------------------
       
   204 //
       
   205 void CPhoneTransferDialerController::ShowButtons( TBool aShow )
       
   206     {
       
   207     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   208         "CPhoneTransferDialerController::ShowButtons()");
       
   209     __ASSERT_DEBUG( iToolbar, Panic( EPhoneCtrlInvariant ) );
       
   210     for( TInt i = 0; i < KButtonCount; i++ )
       
   211         {
       
   212         iToolbar->HideItem( bArray[ i ].iCommandId, !aShow, EFalse );
       
   213         }    
       
   214     
       
   215     if ( aShow )
       
   216         {
       
   217         iToolbar->SetItemDimmed( EPhoneCmdTransferDialerOk, ETrue, EFalse ); 
       
   218         iToolbar->SetItemDimmed( EPhoneCmdTransferDialerSearch, EFalse, EFalse ); 
       
   219         iToolbar->SetItemDimmed( EPhoneDialerCmdClear, ETrue, EFalse ); 
       
   220         }
       
   221     
       
   222     iToolbar->DrawDeferred();
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // PhoneTransferDialerController::CreateButtonLC
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 CAknButton* CPhoneTransferDialerController::CreateButtonLC( 
       
   230     TInt aNormalIconId,
       
   231     TInt aNormalMaskId,
       
   232     const TDesC& aTooltipText,
       
   233     const TAknsItemID& aSkinIconId ) const
       
   234     {   
       
   235     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   236         "CPhoneTransferDialerController::CreateButtonLC()");
       
   237     TFileName mifPath( KDriveZ );
   255     TFileName mifPath( KDriveZ );
   238     mifPath.Append( KDC_APP_BITMAP_DIR );
   256     mifPath.Append( KDC_APP_BITMAP_DIR );
   239     mifPath.Append( KPhoneMifFileName );
   257     mifPath.Append( KPhoneMifFileName );
   240 
   258     
   241     CAknButton* button = CAknButton::NewLC( 
   259     TAknsItemID skinId = SkinId( aNormalIconId );
   242         mifPath,
   260     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   243         aNormalIconId,
   261     CGulIcon* icon = AknsUtils::CreateGulIconL( skin, skinId, mifPath, 
   244         aNormalMaskId,
   262                 aNormalIconId, aNormalMaskId );
   245         -1, -1, // dimmed
   263     CleanupStack::PushL( icon );
   246         -1, -1, // pressed
   264     
   247         -1, -1, // hover
   265     CButtonData* btnData = new (ELeave) CButtonData( aCommandId, icon, tooltipText );
   248         KNullDesC,
   266     CleanupStack::Pop( icon );
   249         aTooltipText, // help
   267     CleanupStack::Pop( tooltipText );
   250         0, // flags
   268     
   251         0, // state flags
   269     return btnData;
   252         aSkinIconId );
       
   253                                                                  
       
   254     button->SetFocusing( EFalse );
       
   255     button->SetBackground( iToolbar );
       
   256 
       
   257     return button;
       
   258     }
   270     }
   259 
   271 
   260 // ---------------------------------------------------------------------------
   272 // ---------------------------------------------------------------------------
   261 // CPhoneTransferDialerController::GetTooltipText
   273 // CPhoneTransferDialerController::GetTooltipText
   262 //
   274 //
   276             break;    
   288             break;    
   277         case EPhoneCmdTransferDialerSearch:
   289         case EPhoneCmdTransferDialerSearch:
   278             resourceId = R_VOIP_DIALER_TOOLTIP_SEARCH;
   290             resourceId = R_VOIP_DIALER_TOOLTIP_SEARCH;
   279             break;                      
   291             break;                      
   280        default:
   292        default:
   281            tooltip = KNullDesC().Alloc();
       
   282            break;
   293            break;
   283        }
   294        }
   284            
   295            
   285     if ( resourceId )
   296     if ( resourceId )
   286         {
   297         {
   287         tooltip = StringLoader::LoadL( resourceId, CCoeEnv::Static() );
   298         tooltip = StringLoader::LoadL( resourceId, &iCoeEnv );
       
   299         }
       
   300     else
       
   301         {
       
   302         tooltip = KNullDesC().AllocL();
   288         }
   303         }
   289     return tooltip;
   304     return tooltip;
   290     }
   305     }
   291 
   306 
   292 // ---------------------------------------------------------------------------
   307 // ---------------------------------------------------------------------------