phonebookui/Speeddial/src/SpdiaContainer.cpp
branchRCL_3
changeset 20 f4a778e096c2
child 21 9da50d567e3c
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:     Declares container control for application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <AknGrid.h>
       
    25 #include <eikapp.h>
       
    26 #include <gulicon.h>
       
    27 #include <avkon.rsg>
       
    28 #include <aknkeys.h>
       
    29 #include <eikmenub.h>
       
    30 #include <eikimage.h>
       
    31 #include <csxhelp/sdm.hlp.hrh>
       
    32 #include <bldvariant.hrh>
       
    33 
       
    34 #include <StringLoader.h>
       
    35 #include <aknnotewrappers.h>
       
    36 #include <SpdCtrl.rsg>
       
    37 #include <AknsUtils.h>
       
    38 #include <AknIconUtils.h>
       
    39 #include <aknViewAppUi.h>
       
    40 #include <AknFepInternalCRKeys.h>
       
    41 #include <aknlists.h>
       
    42 
       
    43 #include <SpeedDial.rsg>
       
    44 
       
    45 #include "speeddial.hrh" 
       
    46 #include "SpdiaControl.hrh"
       
    47 #include "speeddialprivate.h"
       
    48 #include "SpdiaView.h"
       
    49 #include "SpdiaContainer.h"
       
    50 #include "SpdiaApplication.h"
       
    51 #include "SpdiaNote.h"
       
    52 #include "Speeddial.laf"
       
    53 #include <applayout.cdl.h>
       
    54 #include <layoutmetadata.cdl.h>
       
    55 #include <aknlayoutscalable_avkon.cdl.h>
       
    56 #include <aknlayoutscalable_apps.cdl.h>
       
    57 #include <vmnumber.h>
       
    58 #include "SpdiaAppUi.h"
       
    59 
       
    60 #include <featmgr.h>
       
    61 #include <NumberGrouping.h>
       
    62 
       
    63 #include <CVPbkContactStoreUriArray.h>
       
    64 #include <CPbk2StoreConfiguration.h>
       
    65 #include <voicemailboxdomaincrkeys.h>
       
    66 #include <telvmbxsettingscrkeys.h>
       
    67 
       
    68 
       
    69 // LOCAL CONSTANTS AND MACROS
       
    70 const TUint KShortcutKey0('0');
       
    71 const TInt KCellRowCount(3);
       
    72 const TInt KCellColCount(3);
       
    73 const TInt KMaxIndex(8);
       
    74 const TInt KInvalidIndex(10);
       
    75 const TInt KPhoneNumberMaxLen = 100;
       
    76 
       
    77 // ================= MEMBER FUNCTIONS =======================
       
    78 // Constructor
       
    79 CSpdiaContainer::CSpdiaContainer(CSpeedDialPrivate *aSpeedPrivate):iSpeedPrivate( aSpeedPrivate ),
       
    80     iLongTapUsed( EFalse ), iNoAssignedShown( EFalse ), iButton1DownIndex( 0 )
       
    81     {
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CSpdiaContainer::ConstructL
       
    86 // Symbian two phased constructor
       
    87 // 
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 void CSpdiaContainer::ConstructL(CAknView* aView)
       
    91     {
       
    92     CreateWindowL();
       
    93 
       
    94     iView = STATIC_CAST(CSpdiaView*, aView);
       
    95 
       
    96     CSpdiaAppUi* spdialUi = static_cast< CSpdiaAppUi* >( CEikonEnv::Static()->AppUi() );
       
    97     if ( !spdialUi->IsSettingType() )
       
    98         {
       
    99         iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION );
       
   100         }
       
   101     iAlreadyActive = EFalse;
       
   102 
       
   103     FeatureManager::InitializeLibL();
       
   104     if ( FeatureManager::FeatureSupported( KFeatureIdPhoneNumberGrouping ) )
       
   105         {
       
   106         iNumberGrouping = CPNGNumberGrouping::NewL( KPhoneNumberMaxLen );
       
   107         }
       
   108     // Create Grid
       
   109     iGrid = new(ELeave) CAknQdialStyleGrid;
       
   110     iGrid->SetContainerWindowL( *this );
       
   111     iGrid->ConstructL( this, CEikListBox::EMultipleSelection );
       
   112     iGrid->SetBorder(TGulBorder::ENone);
       
   113 
       
   114     iGrid->CreateScrollBarFrameL(ETrue);
       
   115     iGrid->SetListBoxObserver( this );
       
   116     // Create Grid-info
       
   117 
       
   118     TInt error = iSpeedPrivate->GetSpdCtrlLastError();
       
   119     if ( error != KErrNone )
       
   120         {
       
   121         CSpdiaAppUi* spdialUi = static_cast< CSpdiaAppUi* >( CEikonEnv::Static()->AppUi() );
       
   122         spdialUi->LaunchInfoNoteL();
       
   123         return ;
       
   124         }
       
   125     // Using KInvalidIndex here is not to init index in CreateGridDataL().
       
   126     iSpeedPrivate->CreateGridDataL( iGrid, KInvalidIndex );
       
   127     iSpeedPrivate->SetContainerWindowL( *this );
       
   128     iSpeedPrivate->SetRefreshObserver( this );
       
   129 
       
   130     // shortcut value must be set after adding items the the list.
       
   131     iGrid->SetShortcutValueFromPrevList( iGrid->ShortcutValueForNextList() );
       
   132     
       
   133     SetStatusPaneL();
       
   134 
       
   135     if ( AknLayoutUtils::LayoutMirrored() )
       
   136         {
       
   137         iGrid->SetCurrentDataIndex(0);
       
   138         }
       
   139     ActivateL();
       
   140     iAlreadyActive = EFalse;
       
   141     ivmbxvariation = CRepository::NewL( KCRUidVideoMailbox );
       
   142     ivmbxvariation->Get( KVideoMbxSupport, iVmbxsupported );
       
   143     delete ivmbxvariation;
       
   144     ivmbxvariation = NULL;
       
   145     LongTapDetectorL();
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CSpdiaContainer::RefreshGrid
       
   150 // It calls spdctrl CreateGridDataL to draw the grid on skin change.
       
   151 // 
       
   152 // ---------------------------------------------------------
       
   153 void CSpdiaContainer::RefreshGrid()
       
   154     {
       
   155 		TRAP_IGNORE( iSpeedPrivate->CreateGridDataL( iGrid, -1 ) );
       
   156     }
       
   157 
       
   158 // Destructor
       
   159 CSpdiaContainer::~CSpdiaContainer()
       
   160     {
       
   161     delete iGrid;
       
   162     if ( iSpeedPrivate )
       
   163         {    
       
   164         iSpeedPrivate->SetGridDataAsNull();
       
   165         }
       
   166     delete iNumberGrouping;        
       
   167     FeatureManager::UnInitializeLib();
       
   168 
       
   169     if ( iDialog )
       
   170         {
       
   171         delete iDialog;
       
   172         }
       
   173     delete iLongTapDetector;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // CSpdiaContainer::Control
       
   178 // Get a grid-model reference
       
   179 // ---------------------------------------------------------
       
   180 CSpeedDialPrivate& CSpdiaContainer::Control()
       
   181     {
       
   182     return *iSpeedPrivate;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------
       
   186 // CSpdiaContainer::IsVoiceMailBox
       
   187 // Check Voice Mail Box number
       
   188 // ---------------------------------------------------------
       
   189 TBool CSpdiaContainer::IsVoiceMailBox(TInt aIndex) const
       
   190     {
       
   191     if (aIndex < 0)
       
   192         {
       
   193         aIndex = iGrid->CurrentDataIndex();
       
   194         }
       
   195     return  iSpeedPrivate->VMBoxPosition() == aIndex? ETrue: EFalse;
       
   196     }
       
   197 // ---------------------------------------------------------
       
   198 // CSpdiaContainer::IsVdoMailBox
       
   199 // Check Voice Mail Box number
       
   200 // ---------------------------------------------------------
       
   201 TBool CSpdiaContainer::IsVdoMailBox(TInt aIndex) const
       
   202     {
       
   203     if ( !iVmbxsupported )
       
   204         {
       
   205         // Video Mailbox feature is disabled
       
   206         return EFalse;
       
   207         }
       
   208         
       
   209     if ( aIndex < 0 )
       
   210         {
       
   211         aIndex = iGrid->CurrentDataIndex();
       
   212         }
       
   213 
       
   214     return iSpeedPrivate->VdoMBoxPosition() == aIndex ? ETrue : EFalse;
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CSpdiaContainer::CurGridPosition
       
   219 // Get Current grid position
       
   220 // ---------------------------------------------------------
       
   221 TInt CSpdiaContainer::CurGridPosition() const
       
   222     {
       
   223    	return iGrid->CurrentDataIndex();
       
   224     }
       
   225 
       
   226 // ----------------------------------------------------
       
   227 // CSpdiaContainer::UpdatePhoneNumberL
       
   228 // 
       
   229 // ----------------------------------------------------
       
   230 //
       
   231 void CSpdiaContainer::UpdatePhoneNumberL(TInt aIndex)
       
   232     {
       
   233     //STATIC_CAST(CDesCArray* ,iGrid->Model()->ItemTextArray())->Reset();
       
   234     iSpeedPrivate->CreateGridDataL(iGrid, aIndex);
       
   235     iView->LoadCba(MenuResourceID());
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CSpdiaContainer::GetHelpContext
       
   240 // This function is called when Help application is launched.  
       
   241 // (other items were commented in a header).
       
   242 // ---------------------------------------------------------
       
   243 //
       
   244 void CSpdiaContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   245     {
       
   246     aContext.iMajor = KUidSpdia;
       
   247     aContext.iContext = KSDM_HLP_APP;
       
   248     }
       
   249 // ---------------------------------------------------------
       
   250 // CSpdiaContainer::HandleResourceChange()
       
   251 // Handle layout and skin change event.  
       
   252 // ---------------------------------------------------------
       
   253 //
       
   254 void CSpdiaContainer::HandleResourceChange( TInt aType )
       
   255     {   
       
   256     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   257         {
       
   258         // Refresh when grid is in foreground 
       
   259         if ( iSpeedPrivate->State() == CSpeedDialPrivate::STATE_IDLE && 
       
   260              iSpeedPrivate->GridStatus() == CSpeedDialPrivate::EGridUse )
       
   261             {
       
   262             // if refresh grid here, termination will be interrupt when edit type is full screen QWERTY.
       
   263             // RefreshGrid();
       
   264             iGrid->HandleResourceChange( aType );
       
   265 
       
   266             // Reload menubar when swap between landscape and portrait mode.
       
   267             iView->LoadCba( MenuResourceID() );
       
   268             DrawDeferred();
       
   269             }
       
   270         TRAP_IGNORE( SetStatusPaneL() );
       
   271         }
       
   272     else
       
   273         {
       
   274         CCoeControl::HandleResourceChange( aType );
       
   275         TRAP_IGNORE( SetLayoutL() );
       
   276         }
       
   277 
       
   278     // To hide the scrollbar of the grid
       
   279     TRAP_IGNORE( iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   280         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ) );
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------
       
   284 // CSpdiaContainer::SizeChanged
       
   285 // Called by framework when the view size is changed
       
   286 // ---------------------------------------------------------
       
   287 //
       
   288 void CSpdiaContainer::SizeChanged()
       
   289     {
       
   290     iView->iStatusPane->DrawNow();
       
   291     
       
   292     TRAP_IGNORE( SetLayoutL() );
       
   293     DrawNow();
       
   294     }
       
   295 // ---------------------------------------------------------
       
   296 // CSpdiaContainer::SetLayoutL
       
   297 // Called by framework when the view size is changed
       
   298 // ---------------------------------------------------------
       
   299 //
       
   300 void CSpdiaContainer::SetLayoutL()
       
   301     {
       
   302     TAknLayoutRect areaRect;
       
   303     TAknLayoutRect gridQdialPaneRect;
       
   304     TAknLayoutRect mainQdialPaneRect;
       
   305     TRect        mainPaneRect ;
       
   306     TRect        statusPaneRect;
       
   307     TRect        mainRect;
       
   308     TInt         width = 0;
       
   309     TInt         height =0;
       
   310  	
       
   311     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   312         {
       
   313         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   314             {
       
   315             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   316             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
   317             if( !AknLayoutUtils::PenEnabled() )
       
   318                 {
       
   319                 mainPaneRect.iTl = statusPaneRect.iTl;
       
   320                 mainRect = mainPaneRect;
       
   321                 mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
   322                 }
       
   323             else
       
   324                 {
       
   325                 mainPaneRect.iTl.iY -= mainPaneRect.iTl.iY;
       
   326                 mainPaneRect.iTl.iX -=statusPaneRect.iTl.iY;
       
   327                 mainRect = mainPaneRect;
       
   328                 }
       
   329             mainQdialPaneRect.LayoutRect( mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane().LayoutLine() );
       
   330             gridQdialPaneRect.LayoutRect( mainQdialPaneRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   331             AknLayoutUtils::LayoutControl( iGrid, mainQdialPaneRect.Rect(), AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   332             TAknWindowComponentLayout areaNew = AknLayoutScalable_Apps::cell_qdial_pane( 0, 0 ).LayoutLine();
       
   333   
       
   334             areaRect.LayoutRect( mainQdialPaneRect.Rect() ,areaNew.LayoutLine() );
       
   335 		 
       
   336             width  = areaRect.Rect().Width();
       
   337             height = areaRect.Rect().Height();
       
   338             }
       
   339         else
       
   340             {
       
   341             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   342             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
   343             mainPaneRect.iTl= statusPaneRect.iTl;
       
   344             mainRect = mainPaneRect;
       
   345             mainQdialPaneRect.LayoutRect( mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane().LayoutLine() );
       
   346             gridQdialPaneRect.LayoutRect( mainQdialPaneRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   347             AknLayoutUtils::LayoutControl( iGrid, mainQdialPaneRect.Rect(), AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   348             TAknWindowComponentLayout areaNew = AknLayoutScalable_Apps::cell_qdial_pane( 0, 0 ).LayoutLine();
       
   349             areaRect.LayoutRect( mainQdialPaneRect.Rect() ,areaNew.LayoutLine() );
       
   350 		 
       
   351             width  = ( mainPaneRect.Width() / 3 ) - 1;
       
   352             height = ( mainPaneRect.Height() / 3 ) - 7;
       
   353             }		
       
   354         }
       
   355     else
       
   356         {
       
   357         AknLayoutUtils::LayoutControl( iGrid, Rect(), AppLayout::Speed_Dial_descendants_Line_1() );
       
   358         TAknWindowLineLayout area = AppLayout::cell_qdial_pane( 0, 0 );		        
       
   359         areaRect.LayoutRect( Rect(), area );			
       
   360         }
       
   361     TInt language = User::Language();
       
   362     TBool LeftToRight( ETrue );
       
   363 
       
   364     // When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order
       
   365     // is not followed. Instead, the browsing order is the same as in Western variants.
       
   366     if ( language == ELangUrdu /*|| language == ELangArabic*/ )
       
   367         {
       
   368         LeftToRight = EFalse;
       
   369         }
       
   370     TRAP_IGNORE( iGrid->SetLayoutL(
       
   371             EFalse,                // aVerticalOrientation
       
   372             LeftToRight,           // aLeftToRight
       
   373             ETrue,                 // aTopToBottom
       
   374             KCellRowCount,         // aNumOfItemsInPrimaryOrient
       
   375             KCellColCount,         // aNumOfItemsInSecondaryOrient
       
   376             TSize( width, height ) // NewScalableUI changes
       
   377             )
       
   378         );
       
   379       
       
   380     TRAP_IGNORE( iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   381         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ) );
       
   382     iGrid->ScrollBarFrame()->VerticalScrollBar()->SetRect( TRect( 0,0,0,0 ) );
       
   383     CFormattedCellListBoxData* data = iGrid->ItemDrawer()->FormattedCellData();
       
   384 
       
   385     data->SetTransparentSubCellL( SDM_TN_CIF_TURNED, ETrue );  //5
       
   386     data->SetTransparentSubCellL( SDM_TN_CIF, ETrue );         //7
       
   387     data->SetTransparentSubCellL( SDM_TN_VGA_TURNED, ETrue );  //9
       
   388     data->SetTransparentSubCellL( SDM_TN_VGA, ETrue );         //11
       
   389     data->SetTransparentSubCellL( SDM_TN_OTHER, ETrue );       //13
       
   390 
       
   391     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   392         {
       
   393         data->SetBackgroundSkinStyle( &KAknsIIDQsnBgAreaMainQdial, mainRect );
       
   394         data->SetSkinStyle( &KAknsIIDQsnBgAreaMainQdial, mainRect );
       
   395         iSpeedPrivate->SetLayout( mainPaneRect );
       
   396         }
       
   397     else
       
   398         {
       
   399         data->SetBackgroundSkinStyle( &KAknsIIDQsnBgAreaMainQdial, Rect() );
       
   400         data->SetSkinStyle( &KAknsIIDQsnBgAreaMainQdial, Rect() );
       
   401         iSpeedPrivate->SetLayout( Rect() );
       
   402         }
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 // CSpdiaContainer::CountComponentControls
       
   407 //
       
   408 //  
       
   409 // ---------------------------------------------------------
       
   410 //
       
   411 TInt CSpdiaContainer::CountComponentControls() const
       
   412     {
       
   413     return 2; // return nbr of controls inside this container
       
   414     }
       
   415 
       
   416 // ---------------------------------------------------------
       
   417 // CSpdiaContainer::ComponentControl
       
   418 //
       
   419 // ---------------------------------------------------------
       
   420 //
       
   421 CCoeControl* CSpdiaContainer::ComponentControl(TInt aIndex) const
       
   422     {
       
   423     switch ( aIndex )
       
   424         {
       
   425         case 0:
       
   426             return iSpeedPrivate;
       
   427         case 1:
       
   428             return iGrid;
       
   429 
       
   430         default:
       
   431             return NULL;
       
   432         }
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------
       
   436 // CSpdiaContainer::Draw
       
   437 // 
       
   438 // ---------------------------------------------------------
       
   439 //
       
   440 void CSpdiaContainer::Draw(const TRect& aRect) const
       
   441     {
       
   442     iSpeedPrivate->Draw( aRect );
       
   443     }
       
   444 
       
   445 // ---------------------------------------------------------
       
   446 // CSpeedContainer::OfferKeyEventL
       
   447 // processing of a key event
       
   448 // ---------------------------------------------------------
       
   449 //
       
   450 TKeyResponse CSpdiaContainer::OfferKeyEventL(
       
   451                     const TKeyEvent& aKeyEvent, TEventCode aType)
       
   452     {
       
   453     if ( iSpeedPrivate->GetWait()->IsStarted() )
       
   454         {    
       
   455         return EKeyWasConsumed;
       
   456         }
       
   457 
       
   458     TInt index( 0 );
       
   459     
       
   460     if ( ( iView->IsFocused() ) && ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyDevice3 ) /*|| aKeyEvent.iCode == EKeyDevice3*/ )
       
   461         {
       
   462         index = iGrid->CurrentDataIndex();
       
   463         if ( !IsVoiceMailBox() && !IsVdoMailBox() && !iSpeedPrivate->Contact( index ) )
       
   464             {
       
   465             iView->CmdAssignNumberL();
       
   466             }
       
   467         else
       
   468             {
       
   469             CEikMenuBar* menuBar = iView->MenuBar();
       
   470             TInt barId( R_SPDIA_MENUBAR_VIEW_OK_ASSIGN );
       
   471             if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   472                 {
       
   473                 barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
   474                 }
       
   475             else if ( iSpeedPrivate->Contact( index ) )
       
   476                 {
       
   477                 barId = R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO;                
       
   478                 }
       
   479             menuBar->SetMenuType( CEikMenuBar::EMenuContext );
       
   480             menuBar->SetMenuTitleResourceId( barId );
       
   481 
       
   482             menuBar->TryDisplayMenuBarL();
       
   483             // For the reason at the time of being canceled, a menu is changed.
       
   484             menuBar->SetMenuTitleResourceId( MenuResourceID() );
       
   485             menuBar->SetMenuType( CEikMenuBar::EMenuOptions );
       
   486             }
       
   487         return EKeyWasConsumed;
       
   488         }
       
   489     // Check whether the focus exists.
       
   490     // If not, updated the option menu
       
   491     else if ( !iView->IsFocused() )
       
   492     	{
       
   493         iView->LoadCba( MenuResourceID() );
       
   494         MiddleSoftKeyL();
       
   495     	}
       
   496 
       
   497     TKeyResponse exitCode( EKeyWasNotConsumed );
       
   498     TChar code( aKeyEvent.iCode );
       
   499     MiddleSoftKeyL();
       
   500     TInt language = User::Language();
       
   501     // When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order
       
   502     // is not followed. Instead, the browsing order is the same as in Western variants.
       
   503     if ( language == ELangUrdu /*|| language == ELangArabic*/ )
       
   504         {
       
   505         if ( code == EKeyLeftArrow )
       
   506             {
       
   507             index = iGrid->CurrentDataIndex();
       
   508             if ( index == KMaxIndex )
       
   509                 {
       
   510                 iGrid->SetCurrentDataIndex( 0 );
       
   511                 iView->LoadCba( MenuResourceID() );
       
   512                 return EKeyWasConsumed; 
       
   513                 }
       
   514             }
       
   515 		
       
   516         if ( code == EKeyRightArrow )
       
   517             {
       
   518             index = iGrid->CurrentDataIndex();
       
   519             if ( index == 0 )
       
   520                 {
       
   521                 iGrid->SetCurrentDataIndex( KMaxIndex );
       
   522                 iView->LoadCba( MenuResourceID() );
       
   523                 return EKeyWasConsumed; 
       
   524                 }
       
   525             }	
       
   526         }
       
   527     else
       
   528         {
       
   529         if ( code == EKeyRightArrow )
       
   530             {
       
   531             index = iGrid->CurrentDataIndex();
       
   532             if ( index == KMaxIndex )
       
   533                 {
       
   534                 iGrid->SetCurrentDataIndex( 0 );
       
   535                 iView->LoadCba( MenuResourceID() );
       
   536                 return EKeyWasConsumed; 
       
   537                 }
       
   538             }
       
   539 	
       
   540         if ( code == EKeyLeftArrow )
       
   541             {
       
   542             index = iGrid->CurrentDataIndex();
       
   543             if ( index == 0 )
       
   544                 {
       
   545                 iGrid->SetCurrentDataIndex( KMaxIndex );
       
   546                 iView->LoadCba( MenuResourceID() );
       
   547                 return EKeyWasConsumed; 
       
   548                 }
       
   549             }
       
   550         }
       
   551 
       
   552     if ( aKeyEvent.iScanCode == EStdKeyYes )
       
   553         {
       
   554         // Send key is pressed, when menu or dialog is displayed, the call won't be created.
       
   555         if ( aType == EEventKey 
       
   556 		     && !static_cast<CSpdiaAppUi*>( CEikonEnv::Static()->AppUi() )->IsDisplayingDialog() 
       
   557 		     && !iView->MenuBar()->IsDisplayed() )
       
   558             {
       
   559             CallCreateL();
       
   560             }
       
   561         return EKeyWasConsumed;
       
   562         }
       
   563         
       
   564     exitCode = iGrid->OfferKeyEventL( aKeyEvent, aType );
       
   565     if ( exitCode != EKeyWasNotConsumed )
       
   566         {
       
   567         DrawDeferred();
       
   568         if ( code.IsDigit() )
       
   569             {
       
   570             if ( aKeyEvent.iCode - KShortcutKey0 > 0 )
       
   571                 {
       
   572                 iGrid->SetCurrentDataIndex( 
       
   573                         iSpeedPrivate->Index( aKeyEvent.iCode - KShortcutKey0 ) );
       
   574                 MiddleSoftKeyL();
       
   575                 iView->LoadCba( MenuResourceID() );
       
   576                 exitCode = EKeyWasConsumed;
       
   577                 }
       
   578             }
       
   579         else if ( code == EKeyLeftArrow ||
       
   580                 code == EKeyRightArrow ||
       
   581                 code == EKeyUpArrow ||
       
   582                 code == EKeyDownArrow )
       
   583             {
       
   584             iView->LoadCba( MenuResourceID() );
       
   585             MiddleSoftKeyL();
       
   586             }
       
   587         }
       
   588     return exitCode;
       
   589     }
       
   590 
       
   591 // ---------------------------------------------------------
       
   592 // CSpdiaContainer::HandleDatabaseEventL
       
   593 // Handles an database event of type aEventType.
       
   594 // ---------------------------------------------------------
       
   595 //
       
   596 void CSpdiaContainer::HandleDatabaseEventL(
       
   597          TContactDbObserverEvent aEvent)
       
   598     {
       
   599     switch( aEvent.iType )
       
   600         {
       
   601         case EContactDbObserverEventContactChanged:
       
   602         case EContactDbObserverEventContactDeleted:
       
   603         case EContactDbObserverEventContactAdded:
       
   604             break;
       
   605         case EContactDbObserverEventSpeedDialsChanged:
       
   606             if ( iDialog )
       
   607                 {
       
   608                 UpdatePhoneNumberL();
       
   609                 }
       
   610             iNeedUpdate = ETrue;
       
   611             break;
       
   612         default:
       
   613             break;
       
   614         }
       
   615     }
       
   616 
       
   617 // ---------------------------------------------------------
       
   618 // CSpdiaContainer::CallCreateL
       
   619 // Handles send key press.
       
   620 // ---------------------------------------------------------
       
   621 //
       
   622 void CSpdiaContainer::CallCreateL()
       
   623     {
       
   624     TPhCltTelephoneNumber number;
       
   625     TInt index( iGrid->CurrentDataIndex() );
       
   626     TInt numberType( ESpDialPbkFieldIdNone );
       
   627     TBool call( EFalse );
       
   628 
       
   629     // voice mailbox
       
   630     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   631         {
       
   632         //  call = iSpeedPrivate->VoiceMailL(number);
       
   633         iView->CmdNumberCallL(KAiwCmdCall, ETrue );
       
   634         TInt type = iSpeedPrivate->VoiceMailType();
       
   635         if( type == EVmbxIP )
       
   636             {
       
   637             numberType = ESpDialPbkFieldIdVOIP;
       
   638             }
       
   639         else if( type == EVmbxVideo )
       
   640             {
       
   641             numberType = ESpDialPbkFieldIdPhoneNumberVideo;
       
   642             }
       
   643         }
       
   644     else
       
   645         {
       
   646         // if contact does not exit call should not be created.
       
   647         if ( iSpeedPrivate->Contact( index ) != NULL )
       
   648             {
       
   649             call = ETrue;
       
   650             }
       
   651         
       
   652         if ( !iNoAssignedShown && iSpeedPrivate->Contact( index ) == NULL )
       
   653             {
       
   654             CAknQueryDialog* dlg = 
       
   655                         CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
       
   656             iNoAssignedShown = ETrue;
       
   657             
       
   658             // Assign it now?
       
   659             if ( !dlg->ExecuteLD( R_SPDIA_QUERY_ASSIGN ) || 
       
   660                                     !iView->CmdAssignNumberL() )
       
   661                 {
       
   662                 call = EFalse;
       
   663                 }
       
   664             else
       
   665                 {
       
   666                 call = ETrue;
       
   667                 }
       
   668             
       
   669             iNoAssignedShown = EFalse;
       
   670             }
       
   671         if ( call )
       
   672             {
       
   673             number = iSpeedPrivate->PhoneNumber( index );
       
   674             numberType = iSpeedPrivate->NumberType( index );
       
   675             }
       
   676         }
       
   677 
       
   678     if ( call )
       
   679         {
       
   680         iView->NumberCallL( number, numberType);
       
   681         }
       
   682     }
       
   683 
       
   684 // ----------------------------------------------------
       
   685 // CSpdiaContainer::MenuResourceID
       
   686 // 
       
   687 // ----------------------------------------------------
       
   688 //
       
   689 TInt CSpdiaContainer::MenuResourceID()
       
   690     {
       
   691     TInt id( R_SPDIA_MENUBAR_VIEW_VOICE );
       
   692     TInt index( iGrid->CurrentDataIndex() );
       
   693 
       
   694     if ( ( !IsVoiceMailBox() ) && ( !IsVdoMailBox() ) )
       
   695         {
       
   696         id = iSpeedPrivate->Contact(index) != NULL ?
       
   697             R_SPDIA_MENUBAR_VIEW : R_SPDIA_MENUBAR_VIEW_ASSIGN;
       
   698         }
       
   699     return id;
       
   700     }
       
   701 
       
   702 // ---------------------------------------------------------
       
   703 // CSpdiaContainer::ShowViewNumberL
       
   704 // 
       
   705 // ---------------------------------------------------------
       
   706 void CSpdiaContainer::ShowViewNumberL()
       
   707     {
       
   708     TInt gridIndex( CurGridPosition() );
       
   709     TInt textWidth( SDM_VIEW_NUMBER_TEXT_MAXWIDTH );
       
   710     MVPbkStoreContact* contact( iSpeedPrivate->Contact( gridIndex ) );
       
   711     
       
   712     iSpeedPrivate->SetCurrentGridIndex( gridIndex );
       
   713 
       
   714     if ( contact == NULL )
       
   715         {
       
   716         if( iDialog )
       
   717             {
       
   718             delete iDialog;
       
   719             }
       
   720         iDialog = NULL;
       
   721         iDialog = new( ELeave ) CSpdiaNoteDialog( &iDialog );
       
   722         iDialog->PrepareLC( R_SPDIA_NOTE_VIEWNUMBER );
       
   723         iDialog->RunLD();
       
   724         if ( iDialog )
       
   725             {
       
   726             delete iDialog;
       
   727             }
       
   728         iDialog = NULL;
       
   729         return;
       
   730         }	
       
   731     // The assign was deleted while the view number was displayed.
       
   732     delete iDialog;
       
   733     iDialog = NULL;
       
   734 
       
   735     iDialog = new(ELeave) CSpdiaNoteDialog( &iDialog );
       
   736     iDialog->PrepareLC( R_SPDIA_NOTE_VIEWNUMBER );
       
   737 
       
   738     CArrayPtr<CGulIcon>* imgArray = iSpeedPrivate->IconArray();
       
   739 
       
   740     // icon
       
   741     TInt imgIndex( iSpeedPrivate->SpdIconIndex(gridIndex) );
       
   742 
       
   743     if(imgIndex >= 0)
       
   744         {
       
   745         iDialog->SetIconL( CreateBitmapL(*(*imgArray)[imgIndex]) );
       
   746         textWidth -= SDM_ADDITIONAL_MARGIN_FOR_NUMBER_TYPE_ICON; 
       
   747         }
       
   748 
       
   749     // thumbnail
       
   750     imgIndex = iSpeedPrivate->ThumbIndex( gridIndex );
       
   751     CEikImage* image;
       
   752 		if ( imgIndex >= 0 )
       
   753         {
       
   754         image = CreateScaledBitmapL( *(*imgArray)[imgIndex] );
       
   755         iDialog->SetImageL( image );
       
   756         TSize size(image->Bitmap()->SizeInPixels());
       
   757         textWidth -= size.iWidth + SDM_MARGIN_BETWEEN_TEXT_AND_IMAGE;
       
   758         }
       
   759 
       
   760     HBufC* title = iSpeedPrivate->ContactTitleL( contact, ETrue);
       
   761     CleanupStack::PushL(title);
       
   762 
       
   763     // Information
       
   764     CDesCArray* locStr = new(ELeave) CDesCArrayFlat( 2 );
       
   765     CleanupStack::PushL( locStr );
       
   766     const CFont* font = iEikonEnv->NormalFont();
       
   767     if ( AknLayoutUtils::Variant() == EApacVariant )
       
   768         {
       
   769         font = ApacPlain16();
       
   770         }
       
   771 
       
   772     TPtr ptr = title->Des();
       
   773     TAknLayoutRect dialogRect;
       
   774     TAknLayoutText textLayout;
       
   775     TAknTextComponentLayout area;
       
   776     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   777         {
       
   778         TAknWindowLineLayout tempWidth = AknLayoutScalable_Avkon::popup_note_image_window().LayoutLine();
       
   779         dialogRect.LayoutRect(Rect(), tempWidth);
       
   780         area = AknLayoutScalable_Avkon::popup_note_image_window_t2((imgIndex >= 0) ? 2 : 0 );
       
   781 			
       
   782         textLayout.LayoutText( dialogRect.Rect() ,area );
       
   783         textWidth = textLayout.TextRect().Width();
       
   784         TextUtils::ClipToFit ( ptr, *AknLayoutUtils::FontFromId( area.Font()), textWidth );
       
   785         }
       
   786     else
       
   787         {
       
   788         TextUtils::ClipToFit ( ptr, *font,textWidth);
       
   789         }
       
   790     locStr->AppendL( title->Des() );
       
   791 
       
   792     const TDesC& phoneNumber = iSpeedPrivate->PhoneNumber( gridIndex );
       
   793     HBufC* phoneNumberBuf;
       
   794 	
       
   795     if ( iNumberGrouping )
       
   796         {
       
   797         iNumberGrouping->Set(phoneNumber);
       
   798         phoneNumberBuf = iNumberGrouping->FormattedNumber().AllocLC();			
       
   799         }        
       
   800     else
       
   801         {
       
   802         phoneNumberBuf = phoneNumber.AllocLC();
       
   803         }
       
   804     TPtr phoneNumberPtr = phoneNumberBuf->Des();
       
   805     AknTextUtils::LanguageSpecificNumberConversion( phoneNumberPtr );
       
   806 
       
   807     locStr->AppendL( phoneNumberPtr );
       
   808     HBufC* addprompt = StringLoader::LoadLC(R_SPDIA_TEXT_PROMPT, *locStr);
       
   809     
       
   810     HBufC* prompt = StringLoader::LoadL( R_SPDIA_TEXT_VIEWNUM, iSpeedPrivate->Number(gridIndex) );
       
   811     prompt = prompt->ReAlloc( prompt->Length() + addprompt->Length() );
       
   812     CleanupStack::PushL(prompt);
       
   813     prompt->Des().Append( addprompt->Des() );
       
   814 
       
   815     iDialog->SetTextL( *prompt );
       
   816     iDialog->SetPhoneNumberL( (*locStr)[1] );
       
   817 
       
   818     CleanupStack::PopAndDestroy( 5 ); // title, locStr, prompt, addprompt, phoneNumberBuf
       
   819     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   820         {
       
   821         TAknWindowLineLayout tempWidth = AknLayoutScalable_Avkon::popup_note_image_window().LayoutLine();
       
   822         dialogRect.LayoutRect(Rect(), tempWidth);
       
   823         area = AknLayoutScalable_Avkon::popup_note_image_window_t3((imgIndex >= 0) ? 2 : 0 );
       
   824 		
       
   825         textLayout.LayoutText(dialogRect.Rect() ,area );
       
   826         textWidth = textLayout.TextRect().Width();
       
   827         }
       
   828     iDialog->ClipPhoneNumberFromBeginningL( textWidth , 0 );
       
   829     iDialog->RunLD();
       
   830     }
       
   831 
       
   832 // ---------------------------------------------------------
       
   833 // CSpdiaContainer::DoUpdate
       
   834 // 
       
   835 // ---------------------------------------------------------
       
   836 void CSpdiaContainer::DoUpdateL()
       
   837     {
       
   838     MiddleSoftKeyL();
       
   839     if ( iSpeedPrivate && iSpeedPrivate->UpdateFlag() )
       
   840         { 
       
   841         DrawNow();        
       
   842         if ( iDialog )
       
   843             {
       
   844             ShowViewNumberL();   
       
   845             iSpeedPrivate->SetUpdateFlag( EFalse );
       
   846             }     
       
   847         iView->LoadCba( MenuResourceID() );
       
   848         }   
       
   849     }
       
   850 
       
   851 // ---------------------------------------------------------
       
   852 // CSpdiaContainer::Grid
       
   853 // 
       
   854 // ---------------------------------------------------------
       
   855 CAknQdialStyleGrid* CSpdiaContainer::Grid()
       
   856     {
       
   857     return iGrid;
       
   858     }
       
   859 
       
   860 // ---------------------------------------------------------
       
   861 // CSpdiaContainer::CreateBitmapL
       
   862 // 
       
   863 // ---------------------------------------------------------
       
   864 CEikImage* CSpdiaContainer::CreateBitmapL(const CGulIcon& aSrc)
       
   865     {
       
   866     if( aSrc.Bitmap() == NULL || aSrc.Mask() == NULL )
       
   867     	{
       
   868     	return NULL;
       
   869     	}
       
   870     CEikImage* image = new(ELeave) CEikImage;
       
   871     image->SetPictureOwnedExternally(EFalse);
       
   872     CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
       
   873     image->SetBitmap(bitmap);
       
   874     User::LeaveIfError(bitmap->Duplicate(aSrc.Bitmap()->Handle()));
       
   875     CFbsBitmap* bmpMask = aSrc.Mask();
       
   876     if ( bmpMask )
       
   877         {
       
   878         CFbsBitmap* mask = new(ELeave) CFbsBitmap;
       
   879         image->SetMask(mask);
       
   880         User::LeaveIfError( mask->Duplicate( aSrc.Mask()->Handle() ) );
       
   881         }
       
   882     return image;
       
   883     }
       
   884     
       
   885 // ---------------------------------------------------------
       
   886 // CSpdiaContainer::FocusChanged
       
   887 // 
       
   888 // ---------------------------------------------------------
       
   889 void CSpdiaContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   890     {
       
   891     if( iGrid )
       
   892         {
       
   893         iGrid->SetFocus( IsFocused() );
       
   894         }
       
   895     }
       
   896 // ---------------------------------------------------------
       
   897 // CSpdiaContainer::CreateScaledBitmapL
       
   898 // 
       
   899 // ---------------------------------------------------------
       
   900 CEikImage* CSpdiaContainer::CreateScaledBitmapL(const CGulIcon& aSrc)
       
   901     {
       
   902     TRect 		   mainPaneRect ;
       
   903     TRect 		   statusPaneRect;
       
   904     TRect 		   mainRect;
       
   905     TAknLayoutRect windowParentRect;
       
   906     TAknLayoutRect imageRect;
       
   907     
       
   908     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   909         {
       
   910         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
   911         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
   912         mainPaneRect.iTl = statusPaneRect.iTl;
       
   913         mainRect = mainPaneRect;
       
   914         mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
   915         windowParentRect.LayoutRect(mainRect, AknLayoutScalable_Avkon::popup_note_image_window(0));
       
   916         imageRect.LayoutRect(windowParentRect.Rect(), AknLayoutScalable_Avkon::popup_note_image_window_g2(1));
       
   917         }
       
   918     else
       
   919         {	
       
   920         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
   921         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
   922         mainPaneRect.iTl= statusPaneRect.iTl;
       
   923         mainRect = mainPaneRect;
       
   924         windowParentRect.LayoutRect(mainRect, AknLayoutScalable_Avkon::popup_note_image_window(0));
       
   925         imageRect.LayoutRect(windowParentRect.Rect(), AknLayoutScalable_Avkon::popup_note_image_window_g2(1));;
       
   926         }
       
   927      
       
   928     TSize imagesize(imageRect.Rect().Size());
       
   929      
       
   930     CFbsBitmap* bmporg= new (ELeave) CFbsBitmap();
       
   931     bmporg->Create(aSrc.Bitmap()->SizeInPixels(), aSrc.Bitmap()->DisplayMode() );
       
   932     bmporg->Duplicate(aSrc.Bitmap()->Handle());
       
   933        
       
   934     CAknIcon* tmpIcon = CAknIcon::NewL();
       
   935     tmpIcon->SetBitmap( bmporg);
       
   936     CAknIcon* scaledIcon = AknIconUtils::CreateIconL(tmpIcon);
       
   937     AknIconUtils::SetSize(scaledIcon->Bitmap(),imagesize,EAspectRatioNotPreserved);
       
   938 
       
   939     CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
       
   940     TInt err1 = bmp->Duplicate( scaledIcon->Bitmap()->Handle() );
       
   941 
       
   942     // CEikImage	
       
   943     CEikImage* image = new(ELeave) CEikImage;
       
   944     image->SetPictureOwnedExternally( EFalse );
       
   945     image->SetBitmap( bmp );
       
   946     delete scaledIcon;
       
   947   
       
   948     return image;
       
   949     }
       
   950 
       
   951 // ---------------------------------------------------------
       
   952 // CSpdiaContainer::VoiceMailDialogLaunched(
       
   953 // 
       
   954 // ---------------------------------------------------------
       
   955 void CSpdiaContainer::VoiceMailDialogLaunched(TBool aBool)
       
   956     {
       
   957     iVoiceDialog = aBool;
       
   958     }
       
   959 // ------------------------------------------------------
       
   960 // CSpdiaContainer::MiddleSoftKeyL
       
   961 // 
       
   962 // ----------------------------------------------------------
       
   963 
       
   964 void CSpdiaContainer::MiddleSoftKeyL()
       
   965     {
       
   966     TInt index( Grid()->CurrentDataIndex() );
       
   967     if ( ( index < 0 ) || ( index > 8 ) )
       
   968         {
       
   969         return;
       
   970         }
       
   971     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   972         {
       
   973         //If cba is not changed back here, changing to context sensitive menu does not work
       
   974         if ( iView->IsSettingType() )
       
   975             {
       
   976             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
   977             }
       
   978         else
       
   979             {
       
   980             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
   981             }
       
   982         iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_CALL );
       
   983         }
       
   984     else if ( Control().Contact( index ) != NULL )
       
   985         {
       
   986         if ( iView->IsSettingType() )
       
   987             {
       
   988             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
   989             }
       
   990         else
       
   991             {
       
   992             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
   993             }
       
   994         iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO );
       
   995         }
       
   996     else
       
   997         {
       
   998         //when number not assigned in 5.0, MSK versions, display "Assign"
       
   999         if ( AknLayoutUtils::MSKEnabled() )
       
  1000             {
       
  1001             if ( iView->IsSettingType()  )
       
  1002                 {
       
  1003                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_BACK_ASSIGN );
       
  1004                 }
       
  1005             else
       
  1006                 {
       
  1007                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_EXIT_ASSIGN ); 
       
  1008                 }
       
  1009             }
       
  1010         else if(AknLayoutUtils::PenEnabled())
       
  1011             {
       
  1012             if ( iView->IsSettingType() )
       
  1013                 {
       
  1014                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_BACK );
       
  1015                 }
       
  1016             else
       
  1017                 {
       
  1018                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_EXIT ); 
       
  1019                 }
       
  1020             }
       
  1021         else
       
  1022             {
       
  1023             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION );
       
  1024             if ( iView->IsSettingType()  )
       
  1025                 {
       
  1026                 iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
  1027                 }
       
  1028             else
       
  1029                 {
       
  1030                 iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
  1031                 }
       
  1032             iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_ASSIGN );
       
  1033             }
       
  1034         }
       
  1035     }
       
  1036 		
       
  1037 // ----------------------------------------------------------------------------
       
  1038 // CSpdiaContainer::HandlePointerEventL
       
  1039 // Function to handle all touch (pointer events)
       
  1040 // ----------------------------------------------------------------------------
       
  1041 void CSpdiaContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  1042     {
       
  1043     if ( !iView->IsAssignCompleted() )
       
  1044         {
       
  1045         return;
       
  1046         }
       
  1047 
       
  1048     // check if the position is in grid view
       
  1049     CAknGridView* gridView = iGrid->GridView();
       
  1050     TInt itemIndex = 0;        
       
  1051     TRect visibleItemsRect(gridView->ViewRect().iTl, 
       
  1052                  TSize(gridView->ItemSize(itemIndex).iWidth * gridView->NumberOfColsInView(), 
       
  1053                  gridView->ItemSize(itemIndex).iHeight * gridView->NumberOfRowsInView()));
       
  1054     if (!visibleItemsRect.Contains(aPointerEvent.iPosition))
       
  1055         {
       
  1056         return;
       
  1057         }
       
  1058 
       
  1059     // Check if touch is enabled or not.
       
  1060     if ( !AknLayoutUtils::PenEnabled() )
       
  1061         {
       
  1062         return;
       
  1063         }
       
  1064   
       
  1065     //reset iLongTapUsed 
       
  1066     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1067         {
       
  1068         iLongTapUsed = EFalse;
       
  1069         }
       
  1070     
       
  1071     if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down ) ||
       
  1072              ( aPointerEvent.iType == TPointerEvent::EButton1Up ) )
       
  1073     	{
       
  1074         if ( iLongTapDetector )
       
  1075             {
       
  1076             iLongTapDetector->PointerEventL( aPointerEvent );
       
  1077             }
       
  1078     	}
       
  1079     // Process only once when the grid control has been pressed
       
  1080     if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down ) ||
       
  1081          ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
       
  1082          ( aPointerEvent.iType == TPointerEvent::EButton1Up ) )
       
  1083         {        
       
  1084         // Ask the grid to process the handlepointerevent
       
  1085         iGrid->HandlePointerEventL( aPointerEvent );
       
  1086         
       
  1087         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1088         	{
       
  1089         	iButton1DownIndex = iGrid->CurrentDataIndex();
       
  1090         	}
       
  1091         // If already highlighted, activate the grid element
       
  1092         if ( iGrid->CurrentDataIndex() == iButton1DownIndex ) 
       
  1093             {
       
  1094             TInt pointedItemIndex;
       
  1095             if ( ( aPointerEvent.iType == TPointerEvent::EButton1Up ) &&
       
  1096                 iGrid->View()->XYPosToItemIndex(
       
  1097                     aPointerEvent.iPosition, pointedItemIndex ) &&
       
  1098                 ( pointedItemIndex == iButton1DownIndex ) )
       
  1099                 {
       
  1100                 if ( iLongTapUsed == EFalse )
       
  1101                     {
       
  1102                     // Need filtrate IsVoiceMailBox and IsVdoMailBox
       
  1103                     if ( !IsVoiceMailBox() && !IsVdoMailBox() 
       
  1104                          && iSpeedPrivate->Contact( iButton1DownIndex ) == NULL )
       
  1105                         {
       
  1106                         // Open phonebook fetch list
       
  1107                         iView->CmdAssignNumberL();	
       
  1108                         // No need to launch the menu
       
  1109                         return;
       
  1110                         }
       
  1111                     else if ( iSpeedPrivate->Contact( iButton1DownIndex ) != NULL )
       
  1112                         {
       
  1113                         CallCreateL( );
       
  1114                         return;
       
  1115                         }
       
  1116                     CEikMenuBar* menuBar = iView->MenuBar();
       
  1117                     TInt barId(R_SPDIA_MENUBAR_VIEW_OK_ASSIGN);
       
  1118             
       
  1119                     // If focus is on voicemailbox
       
  1120                     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
  1121                         {
       
  1122                         barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
  1123                         }
       
  1124                     // If a number is assigned then provide call option
       
  1125                     else if ( iSpeedPrivate->Contact( iButton1DownIndex ) != NULL )
       
  1126                         {
       
  1127                         barId = R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO;
       
  1128                         }
       
  1129                     menuBar->StopDisplayingMenuBar();
       
  1130                     menuBar->SetMenuType( CEikMenuBar::EMenuContext );
       
  1131                     menuBar->SetMenuTitleResourceId( barId );
       
  1132                     menuBar->TryDisplayMenuBarL();
       
  1133                     // At the time of being canceled, a menu is changed.
       
  1134                     menuBar->SetMenuTitleResourceId( MenuResourceID() );
       
  1135                     menuBar->SetMenuType( CEikMenuBar::EMenuOptions );
       
  1136                     }
       
  1137                 iLongTapUsed = EFalse;
       
  1138                 }
       
  1139             }
       
  1140         // Else just reload the cba buttons based on the context
       
  1141         else 
       
  1142             {
       
  1143             MiddleSoftKeyL();
       
  1144             iView->LoadCba( MenuResourceID() );
       
  1145             }
       
  1146         }
       
  1147     }
       
  1148 
       
  1149 // --------------------------------------------------------------------------
       
  1150 // CSpdiaContainer::LongTapDetectorL
       
  1151 // --------------------------------------------------------------------------
       
  1152 //    
       
  1153 CAknLongTapDetector& CSpdiaContainer::LongTapDetectorL()
       
  1154     {
       
  1155     if ( !iLongTapDetector )
       
  1156         {
       
  1157         iLongTapDetector = CAknLongTapDetector::NewL( this );
       
  1158         }
       
  1159     return *iLongTapDetector;
       
  1160     }
       
  1161     
       
  1162 // --------------------------------------------------------------------------
       
  1163 // CSpdiaContainer::HandleLongTapEventL
       
  1164 // --------------------------------------------------------------------------
       
  1165 //    
       
  1166  void CSpdiaContainer::HandleLongTapEventL(
       
  1167         const TPoint& aPenEventLocation, 
       
  1168         const TPoint& /*aPenEventScreenLocation*/ )
       
  1169     {
       
  1170     // Get the Current Data Index
       
  1171     TInt itemIndex( KErrNotFound );
       
  1172 
       
  1173     // Get position when user press screen
       
  1174     iGrid->View()->XYPosToItemIndex( aPenEventLocation, itemIndex );
       
  1175 
       
  1176     // Compare two index
       
  1177     if ( AknLayoutUtils::PenEnabled() && ( itemIndex == iGrid->CurrentDataIndex() ) )
       
  1178         {
       
  1179         iLongTapUsed = ETrue;   	    
       
  1180         TInt index = iGrid->CurrentDataIndex();
       
  1181         if ( IsVoiceMailBox() || IsVdoMailBox())
       
  1182             {
       
  1183             CEikMenuBar* menuBar = iView->MenuBar();
       
  1184             TInt barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
  1185             
       
  1186             menuBar->StopDisplayingMenuBar();
       
  1187             menuBar->SetMenuType(CEikMenuBar::EMenuContext);
       
  1188             menuBar->SetMenuTitleResourceId(barId);
       
  1189             menuBar->TryDisplayMenuBarL();
       
  1190             //For the reason at the time of being canceled, a menu is changed.
       
  1191             menuBar->SetMenuTitleResourceId(MenuResourceID());
       
  1192             menuBar->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1193             }
       
  1194         }
       
  1195     }
       
  1196     
       
  1197 // --------------------------------------------------------------------------
       
  1198 // CSpdiaContainer::SetStatusPaneL
       
  1199 // --------------------------------------------------------------------------
       
  1200 //    
       
  1201  void CSpdiaContainer::SetStatusPaneL()
       
  1202      {
       
  1203      CEikStatusPane* statusPane = iView->iStatusPane;
       
  1204 
       
  1205      if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1206          {
       
  1207          statusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
  1208          statusPane->MakeVisible( ETrue );
       
  1209          statusPane->DrawNow();
       
  1210          }
       
  1211      else
       
  1212          {
       
  1213          TInt resouceId = statusPane->CurrentLayoutResId();
       
  1214 
       
  1215          if ( resouceId != R_AVKON_STATUS_PANE_LAYOUT_USUAL && 
       
  1216              resouceId != R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT )
       
  1217              {
       
  1218              statusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
  1219              }
       
  1220 
       
  1221          if ( statusPane->IsVisible()&&(!iView->IsShowVmbxDlg()) )
       
  1222              {
       
  1223              statusPane->MakeVisible( EFalse );
       
  1224              }
       
  1225 
       
  1226          TRect mainPaneRect;
       
  1227          AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
  1228 
       
  1229          TRect statusPaneRect;
       
  1230          AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
  1231          if ( !iView->IsShowMsgDlg() && !iView->IsShowVmbxDlg())
       
  1232              {
       
  1233              mainPaneRect.iTl = statusPaneRect.iTl;
       
  1234              }
       
  1235          SetRect( mainPaneRect );
       
  1236          }
       
  1237      }
       
  1238 
       
  1239  // --------------------------------------------------------------------------
       
  1240  // CSpdiaContainer::RefreshDialog
       
  1241  // from MRefreshObserver
       
  1242  // --------------------------------------------------------------------------
       
  1243  // 
       
  1244  void CSpdiaContainer::RefreshDialog()
       
  1245      {
       
  1246      if ( iDialog )
       
  1247          {
       
  1248          TRAP_IGNORE( DoUpdateL() );
       
  1249          }
       
  1250      }
       
  1251  
       
  1252  // --------------------------------------------------------------------------
       
  1253  // CSpdiaContainer::RefreshDialog
       
  1254  // From MEikListBoxObserver, Handles an event of listbox.
       
  1255  // --------------------------------------------------------------------------
       
  1256  // 
       
  1257  void CSpdiaContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
  1258     {
       
  1259     switch(aEventType)
       
  1260         {
       
  1261         case EEventPenDownOnItem:
       
  1262             iView->LoadCba( MenuResourceID() );
       
  1263             MiddleSoftKeyL();
       
  1264             break;
       
  1265         }
       
  1266     }
       
  1267  
       
  1268  // --------------------------------------------------------------------------
       
  1269  // CSpdiaContainer::GetViewDialogStatus
       
  1270  // Check whether the view note is displaying when making speeddial to background.
       
  1271  // --------------------------------------------------------------------------
       
  1272  // 
       
  1273  CSpdiaNoteDialog* CSpdiaContainer::GetViewDialogStatus()
       
  1274     {
       
  1275     return iDialog;
       
  1276     }
       
  1277  // End of File