phoneapp/phoneuivoipextension/src/cphonetransferdialercontroller.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Implementation of CPhoneTransferDialerController class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <e32base.h>
       
    21 
       
    22 #include <akntoolbar.h>
       
    23 #include <AknsItemID.h>
       
    24 #include <StringLoader.h>
       
    25 
       
    26 #include <phoneui.mbg>
       
    27 #include <phoneui.rsg>
       
    28 #include <phoneuivoip.rsg>
       
    29 #include <data_caging_path_literals.hrh> // For KDC_APP_BITMAP_DIR
       
    30 
       
    31 #include "phoneui.pan"
       
    32 #include "phonelogger.h"
       
    33 #include "cphonetransferdialercontroller.h"
       
    34 #include "cphonemainresourceresolver.h"
       
    35 #include "phonerssvoip.h"
       
    36 #include "phoneappcommands.hrh"
       
    37 #include "phoneappvoipcommands.hrh"
       
    38 
       
    39 
       
    40 // CONSTANTS
       
    41 _LIT ( KPhoneMifFileName, "phoneui.mif" );
       
    42 
       
    43 // Number of buttons 
       
    44 const TInt KButtonCount = 2;
       
    45 
       
    46 class TPhoneDialerToolbarButton 
       
    47     {
       
    48 public:
       
    49     TInt iIconIndex;
       
    50     TInt iMaskIndex;
       
    51     TInt iCommandId;    
       
    52     };
       
    53 
       
    54 const TPhoneDialerToolbarButton bArray[KButtonCount] = 
       
    55         {  
       
    56             { EMbmPhoneuiQgn_indi_button_send_dtmf,
       
    57               EMbmPhoneuiQgn_indi_button_send_dtmf_mask,
       
    58               EPhoneCmdTransferDialerOk
       
    59             },
       
    60             { EMbmPhoneuiQgn_indi_dialer_contacts,
       
    61               EMbmPhoneuiQgn_indi_dialer_contacts_mask,
       
    62               EPhoneCmdTransferDialerSearch
       
    63             }                 
       
    64         };  
       
    65 
       
    66 // ================= MEMBER FUNCTIONS =======================
       
    67 
       
    68 // C++ default constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 //  
       
    71 CPhoneTransferDialerController::CPhoneTransferDialerController()
       
    72     {
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------
       
    76 // CPhoneTransferDialerController::~CPhoneTransferDialerController()
       
    77 // Destructor
       
    78 // -----------------------------------------------------------
       
    79 //
       
    80 CPhoneTransferDialerController::~CPhoneTransferDialerController()
       
    81     {
       
    82     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
    83         "CPhoneTransferDialerController::~CPhoneTransferDialerController()");
       
    84     delete iNumberEntryPromptText;
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------
       
    88 // CPhoneTransferDialerController::NewL()
       
    89 // Constructor
       
    90 // -----------------------------------------------------------
       
    91 //
       
    92 CPhoneTransferDialerController* CPhoneTransferDialerController::NewL()
       
    93     {
       
    94     CPhoneTransferDialerController* self = new (ELeave) 
       
    95         CPhoneTransferDialerController();
       
    96   
       
    97     return self;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------
       
   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
       
   145 // -----------------------------------------------------------
       
   146 //
       
   147 TInt CPhoneTransferDialerController::CbaResourceId() const
       
   148     {
       
   149     return EPhoneVoIPTransferDialerSoftkeys;
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------
       
   153 // CPhoneTransferDialerController::MenuResourceId
       
   154 // -----------------------------------------------------------
       
   155 //
       
   156 TInt CPhoneTransferDialerController::MenuResourceId() const
       
   157     {
       
   158     if ( iNumberEntryIsEmpty )
       
   159         {
       
   160         return EPhoneVoIPTransferDialerNumberEntryEmptyMenubar;
       
   161         }
       
   162     else
       
   163         {
       
   164         return EPhoneVoIPTransferDialerNumberEntryNotEmptyMenubar;
       
   165         }
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------
       
   169 // CPhoneTransferDialerController::NumberEntryPromptTextL
       
   170 // -----------------------------------------------------------
       
   171 //
       
   172 const TDesC& CPhoneTransferDialerController::NumberEntryPromptTextL()
       
   173     {
       
   174     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   175         "CPhoneTransferDialerController::NumberEntryPromptTextL()");
       
   176     if ( !iNumberEntryPromptText )
       
   177         {
       
   178         iNumberEntryPromptText = StringLoader::LoadL( 
       
   179             CPhoneMainResourceResolver::Instance()->
       
   180             ResolveResourceID( EPhoneVoIPTransferAddress ) );
       
   181         }  
       
   182     
       
   183     return *iNumberEntryPromptText;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------
       
   187 // CPhoneTransferDialerController::HandleNumberEntryIsEmpty
       
   188 // -----------------------------------------------------------
       
   189 //
       
   190 void CPhoneTransferDialerController::HandleNumberEntryIsEmpty( TBool aIsEmpty )
       
   191     {
       
   192     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   193         "CPhoneTransferDialerController::HandleNumberEntryIsEmpty()");
       
   194     __ASSERT_DEBUG( iToolbar, Panic( EPhoneCtrlInvariant ) );
       
   195     iToolbar->SetItemDimmed( EPhoneCmdTransferDialerOk, aIsEmpty, EFalse );
       
   196     iToolbar->SetItemDimmed( EPhoneCmdTransferDialerSearch, !aIsEmpty, EFalse );
       
   197     iToolbar->SetItemDimmed( EPhoneDialerCmdClear, aIsEmpty, EFalse );
       
   198     iNumberEntryIsEmpty = aIsEmpty;
       
   199     }
       
   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 );
       
   238     mifPath.Append( KDC_APP_BITMAP_DIR );
       
   239     mifPath.Append( KPhoneMifFileName );
       
   240 
       
   241     CAknButton* button = CAknButton::NewLC( 
       
   242         mifPath,
       
   243         aNormalIconId,
       
   244         aNormalMaskId,
       
   245         -1, -1, // dimmed
       
   246         -1, -1, // pressed
       
   247         -1, -1, // hover
       
   248         KNullDesC,
       
   249         aTooltipText, // help
       
   250         0, // flags
       
   251         0, // state flags
       
   252         aSkinIconId );
       
   253                                                                  
       
   254     button->SetFocusing( EFalse );
       
   255     button->SetBackground( iToolbar );
       
   256 
       
   257     return button;
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // CPhoneTransferDialerController::GetTooltipText
       
   262 //
       
   263 // Tooltip texts for toolbar buttons
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 HBufC* CPhoneTransferDialerController::GetTooltipTextL( TInt aCommandId ) const
       
   267     {
       
   268     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   269         "CPhoneTransferDialerController::GetTooltipTextL()");
       
   270     TInt resourceId = 0;
       
   271     HBufC* tooltip = NULL;
       
   272     switch( aCommandId )
       
   273         {                            
       
   274         case EPhoneCmdTransferDialerOk:
       
   275             resourceId = R_VOIP_DIALER_TOOLTIP_ACCEPT;
       
   276             break;    
       
   277         case EPhoneCmdTransferDialerSearch:
       
   278             resourceId = R_VOIP_DIALER_TOOLTIP_SEARCH;
       
   279             break;                      
       
   280        default:
       
   281            tooltip = KNullDesC().Alloc();
       
   282            break;
       
   283        }
       
   284            
       
   285     if ( resourceId )
       
   286         {
       
   287         tooltip = StringLoader::LoadL( resourceId, CCoeEnv::Static() );
       
   288         }
       
   289     return tooltip;
       
   290     }
       
   291 
       
   292 // ---------------------------------------------------------------------------
       
   293 // CPhoneTransferDialerController::SkinId
       
   294 // ---------------------------------------------------------------------------
       
   295 //    
       
   296 TAknsItemID CPhoneTransferDialerController::SkinId( TInt aIconIndex ) const
       
   297     {
       
   298     TAknsItemID skinId;
       
   299     
       
   300     switch ( aIconIndex )
       
   301         {
       
   302         case EMbmPhoneuiQgn_indi_button_send_dtmf:
       
   303             skinId = KAknsIIDQgnIndiButtonSendDtmf;
       
   304             break;
       
   305         case EMbmPhoneuiQgn_indi_dialer_contacts:
       
   306             skinId = KAknsIIDQgnIndiDialerContacts;
       
   307             break;                     
       
   308         default:
       
   309             skinId = KAknsIIDNone;        
       
   310             break;            
       
   311         }
       
   312     
       
   313     return skinId;  
       
   314     }