phoneuis/BubbleManager/Src/BMBubbleManager.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Manager for the whole subsystem
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include    "BMBubbleManager.h"
       
    22 #include    "BMBubbleImageManager.h"
       
    23 #include    "BMResourceManager.h"
       
    24 #include    "BMCustomManager.h"
       
    25 #include    "BMBubbleOutlook.h"
       
    26 #include    "BMBubbleOutlookMiddle.h"
       
    27 #include    "BMBubbleOutlookConference.h"
       
    28 #include    "BMBubbleOutlookNE.h"
       
    29 #include    "BMCallHeader.h"
       
    30 #include    "BMConfHeader.h"
       
    31 #include    "BMPanic.h"
       
    32 #include    "BMUtils.h"
       
    33 #include    "BMLayout.h"
       
    34 #include    "BMBubbleImage.h"
       
    35 #include    "BubbleManagerPaths.h"
       
    36 #include    "BMCallObjectManager.h"
       
    37 #include    "BMLayout2.h"
       
    38 #include    "BMLayout3.h"
       
    39 #include    "BMLayout4.h"
       
    40 #include    "BMLayout6.h"
       
    41 #include    "BMCallObjectUtils.h"
       
    42 #include    "BMVideoController.h"
       
    43 #include    "BMTouchPane.h"
       
    44 #include    "BMTouchPaneInterface.h"
       
    45 #include    "BMMainPaneControl.h"
       
    46 #include    <eikimage.h>    // for muted-image
       
    47 #include    <coemain.h>
       
    48 #include    <PbkFields.hrh> // for field id
       
    49 #include    <ConeResLoader.h> 
       
    50 #include    <AknsUtils.h>
       
    51 #include    <NumberGrouping.h>
       
    52 #include    <AknDef.h>
       
    53 #include    <layoutmetadata.cdl.h>
       
    54 
       
    55 #include    <featmgr.h> 
       
    56 #include    <telephonyvariant.hrh>
       
    57 
       
    58 #include <centralrepository.h>
       
    59 #include    <NumberGroupingCRKeys.h>
       
    60 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
    61 #include <gfxtranseffect/gfxtranseffect.h> 
       
    62 #include <akntransitionutils.h>
       
    63 #endif
       
    64 
       
    65 #include    "BMBubbleDebug.h"
       
    66 
       
    67 // ========================= MEMBER FUNCTIONS ================================
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CBubbleManager::NewL
       
    71 // Symbian OS two phased constructor
       
    72 // 
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C CBubbleManager* CBubbleManager::NewL( const CCoeControl& aContainer, 
       
    76                                                const TRect& aRect )
       
    77     {
       
    78     CBubbleManager* self = new( ELeave )CBubbleManager;    
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL( aContainer , aRect, EFalse );
       
    81     CleanupStack::Pop();    // self
       
    82     return self;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CBubbleManager::NewL
       
    87 // Symbian OS two phased constructor
       
    88 // 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CBubbleManager* CBubbleManager::NewL( const CCoeControl& aContainer, 
       
    92                                                const TRect& aRect,
       
    93                                                TBool aBigNEInIdle )
       
    94     {
       
    95     CBubbleManager* self = new( ELeave )CBubbleManager;    
       
    96     CleanupStack::PushL( self );
       
    97     self->ConstructL( aContainer , aRect, aBigNEInIdle );
       
    98     CleanupStack::Pop();    // self
       
    99     return self;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CBubbleManager::ConstructL
       
   104 // Symbian OS two phased constructor
       
   105 // 
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 
       
   109 void CBubbleManager::ConstructL( 
       
   110     const CCoeControl& aContainer, 
       
   111     const TRect& aRect,
       
   112     TBool aBigNEInIdle )
       
   113     {    
       
   114     // Call object display
       
   115     if ( FeatureManager::FeatureSupported( KFeatureIdCallImagetext ) )
       
   116         {
       
   117         iConfigFlags |= EBMCallObjectDisplay;    
       
   118         }
       
   119     
       
   120     // Bigger number entry window in idle    
       
   121     if ( aBigNEInIdle )
       
   122         {
       
   123         iConfigFlags |= EBMBigNEInIdleState;    
       
   124         }
       
   125    
       
   126      // Touch CallHandling.
       
   127     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
   128         {
       
   129         iConfigFlags |= EBMTouchCallhandling;    
       
   130         }
       
   131                
       
   132     // set window
       
   133     SetContainerWindowL( aContainer );
       
   134     SetParent( const_cast<CCoeControl*>(&aContainer) );
       
   135     iParentControl = &aContainer;
       
   136     
       
   137     // load resource file for animation and number entry component.
       
   138     RConeResourceLoader resourceLoader( *iCoeEnv ); 
       
   139     TFileName fileName; 
       
   140     BubbleUtils::BubbleResourceFileName( fileName ); 
       
   141     resourceLoader.OpenL(fileName); 
       
   142     CleanupClosePushL( resourceLoader );
       
   143     
       
   144     // create image manager
       
   145     iImageManager = CBubbleImageManager::NewL(
       
   146         iConfigFlags & EBMCallObjectDisplay );
       
   147 
       
   148     // create resource pool
       
   149     iResourceManager = CBubbleResourceManager::NewL( *this );
       
   150     
       
   151     // create custom manager
       
   152     iCustomManager = CBubbleCustomManager::NewL(*this);
       
   153     
       
   154     // muted image
       
   155     iIsMuted = EFalse;
       
   156     iMutedImage = new( ELeave ) CBubbleImage;
       
   157     iMutedImage->SetContainerWindowL( *this );
       
   158     iMutedImage->SetParent( this );
       
   159     iMutedImage->SetPictureOwnedExternally( ETrue );
       
   160     iMutedImage->MakeVisible( iIsMuted );
       
   161     
       
   162     // create array of call headers
       
   163     CBubbleCallHeader* header;
       
   164     iCallHeaders = new( ELeave ) CArrayPtrFlat<CBubbleCallHeader>( 1 );
       
   165     iCallHeaders->SetReserveL( KBubbleCallMaxAmount );
       
   166     for ( TUint8 i = 0 ; i < KBubbleCallMaxAmount ; i++ )
       
   167         {
       
   168         header = CBubbleCallHeader::NewL( i );
       
   169         iCallHeaders->InsertL( i , header );    // can't leave
       
   170         }
       
   171     
       
   172     // set reserve for active headers
       
   173     iActiveHeaders = new ( ELeave ) CArrayPtrFlat<CBubbleHeader>( 1 );
       
   174     // 1 is for conference
       
   175     iActiveHeaders->SetReserveL( KBubbleCallMaxAmount + 1 ); 
       
   176         
       
   177     // create conference header
       
   178     iConfHeader = CBubbleConfHeader::NewL( KBubbleConferenceId );
       
   179     
       
   180     // create number entry
       
   181     iNumberEntry = new ( ELeave ) CBubbleOutlookNumberEntry( *this, 
       
   182                                                              *iMutedImage );
       
   183     iNumberEntry->SetCallObjectDisplay( 
       
   184         iConfigFlags & EBMCallObjectDisplay );
       
   185     iNumberEntry->SetContainerWindowL( *this );
       
   186     iNumberEntry->SetParent( this );
       
   187     iNumberEntry->ConstructL();
       
   188     iNumberEntry->MakeVisible( EFalse ); //add
       
   189     
       
   190     // create places and their contents ( outlooks )
       
   191     TInt maxAmount = (iConfigFlags & EBMTouchCallhandling) ?
       
   192         KBubblePlaceMaxAmountTouch : KBubblePlaceMaxAmount;
       
   193     CBubblePlace* place;
       
   194     iBubblePlaces = new ( ELeave ) CArrayPtrFlat<CBubblePlace>( 1 );
       
   195     iBubblePlaces->SetReserveL( maxAmount );
       
   196     for ( TUint8 e = 0 ; e < maxAmount ; e++  )
       
   197         {
       
   198         place = new ( ELeave ) CBubblePlace;
       
   199         CleanupStack::PushL( place );
       
   200         place->SetContainerWindowL( *this );
       
   201         place->SetParent( this );
       
   202         place->ConstructL( CBubblePlace::TPhoneBubblePlace ( e ) , *this );
       
   203         place->GetBubbleOutlook().SetCallObjectDisplay( 
       
   204             iConfigFlags & EBMCallObjectDisplay );
       
   205         iBubblePlaces->InsertL( e , place );
       
   206         CleanupStack::Pop(); //place
       
   207         }
       
   208     
       
   209     // reserve space for active places
       
   210     iActivePlaces = 
       
   211         new (ELeave) CArrayPtrFlat<CBubblePlace>( KBubblePlaceMaxVisible );
       
   212     iActivePlaces->SetReserveL( KBubblePlaceMaxVisible );
       
   213     
       
   214     // reserve space for label text
       
   215     iLabelBuf = HBufC::NewMaxL ( KBubbleLabelMaxLength );
       
   216 
       
   217     // call object manager
       
   218     if ( iConfigFlags & EBMCallObjectDisplay )
       
   219         {
       
   220         iCallObjectManager = CBubbleCallObjectManager::NewL( *this );
       
   221         
       
   222         // Main pane control is not set as component control,
       
   223         // it just controls the drawing of the call image to
       
   224         // the main pane.
       
   225         iMainPaneControl = CBubbleMainPaneControl::NewL(
       
   226                 *this,
       
   227                 *iCallObjectManager );
       
   228         iMainPaneControl->ActivateL();
       
   229         iMainPaneControl->SetContainerWindowL( *this );
       
   230         iMainPaneControl->MakeVisible( EFalse );
       
   231         }
       
   232         
       
   233     // Video ringtone
       
   234     iVideoController = CBubbleVideoController::NewL( *this );
       
   235     
       
   236     // Touch pane
       
   237     if ( iConfigFlags & EBMTouchCallhandling )
       
   238         {
       
   239         iTouchPane = CBubbleTouchPane::NewL();
       
   240         iTouchPane->SetContainerWindowL( *this );
       
   241         iTouchPane->SetParent( this );
       
   242         iTouchPane->MakeVisible( EFalse );
       
   243         iTouchPane->ActivateL();
       
   244         }   
       
   245     
       
   246     SetRect( aRect );
       
   247     ActivateL();
       
   248     iResourceManager->ActivateL();
       
   249     iIsReadyToDraw = 0;
       
   250 
       
   251     // Resource file isn't needed anymore so it can be closed.
       
   252     CleanupStack::PopAndDestroy(); // resourceLoader   
       
   253     
       
   254     TInt pngErr( KErrNone );
       
   255     TInt pngSupported( 0 );
       
   256     CRepository* repository = CRepository::NewL( KCRUidNumberGrouping );
       
   257     pngErr = repository->Get( KNumberGrouping, pngSupported );
       
   258     delete repository;
       
   259 
       
   260     if ( KErrNone == pngErr && pngSupported != 0 )
       
   261         {
       
   262         iNumberGrouping = CPNGNumberGrouping::NewL(KBubbleLabelMaxLength);
       
   263         }
       
   264 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
   265     // Register the number entry popup in the transition server
       
   266     GfxTransEffect::Register( iNumberEntry, KGfxNumberEntryPopupUid, EFalse );
       
   267 
       
   268     CAknTransitionUtils::SetData( (TInt) this, 0 );
       
   269 #endif
       
   270     }
       
   271 
       
   272 // Destructor
       
   273 EXPORT_C CBubbleManager::~CBubbleManager()
       
   274     {
       
   275 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
   276     CAknTransitionUtils::RemoveData( (TInt) this );
       
   277     GfxTransEffect::Deregister( iNumberEntry );
       
   278 #endif
       
   279     AknsUtils::DeregisterControlPosition( this );
       
   280     
       
   281     delete iMutedImage;
       
   282     
       
   283     if ( iActiveHeaders )
       
   284         {
       
   285         iActiveHeaders->Reset( );
       
   286         delete iActiveHeaders;
       
   287         }
       
   288 
       
   289     delete iLabelBuf;
       
   290     
       
   291     if ( iActivePlaces )
       
   292         {
       
   293         iActivePlaces->Reset( );
       
   294         delete iActivePlaces;
       
   295         }
       
   296     
       
   297     if ( iBubblePlaces )
       
   298         {
       
   299         iBubblePlaces->ResetAndDestroy() ;
       
   300         delete iBubblePlaces;
       
   301         }
       
   302     
       
   303     delete iNumberEntry;
       
   304     
       
   305     delete iConfHeader;
       
   306     
       
   307     
       
   308     if ( iCallHeaders )
       
   309         {
       
   310         iCallHeaders->ResetAndDestroy() ;
       
   311         delete iCallHeaders;
       
   312         }
       
   313 
       
   314     delete iResourceManager;
       
   315     
       
   316     delete iImageManager;
       
   317     
       
   318     delete iCustomManager;
       
   319     
       
   320     delete iNumberGrouping;
       
   321 
       
   322     delete iCallObjectManager;
       
   323     
       
   324     delete iMainPaneControl;
       
   325 
       
   326     delete iVideoController;
       
   327     
       
   328     delete iTouchPane;
       
   329     }
       
   330 
       
   331 // ---------------------------------------------------------------------------
       
   332 // CBubbleManager::SizeChanged()
       
   333 // called by framework when the view size is changed
       
   334 //  
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 void CBubbleManager::SizeChanged()
       
   338     {
       
   339     AknsUtils::RegisterControlPosition( this );
       
   340     
       
   341     if ( iConfigFlags & EBMTouchCallhandling )
       
   342         {
       
   343         MBubbleTouchPaneInterface* touchPaneIf =
       
   344             static_cast<MBubbleTouchPaneInterface*> (iTouchPane);             
       
   345         
       
   346         if ( iTouchPane->IsVisible() )
       
   347             {
       
   348             TInt variety = 0;
       
   349             // Popups
       
   350             TAknLayoutRect windowsPane;        
       
   351             windowsPane.LayoutRect( 
       
   352                 Rect(), 
       
   353                 BubbleLayout6::call6_windows_pane(variety));
       
   354 
       
   355             iMainPaneControl->SetRect( windowsPane.Rect() );
       
   356             
       
   357             DoLayoutCall4Bubbles( windowsPane.Rect() );    
       
   358             }
       
   359         else
       
   360             {
       
   361             iMainPaneControl->SetRect( Rect() );
       
   362             
       
   363             DoLayoutCall4Bubbles( Rect() );    
       
   364             }            
       
   365             
       
   366                     
       
   367         // Muted icon
       
   368         AknLayoutUtils::LayoutImage( 
       
   369             iMutedImage, Rect(), 
       
   370             BubbleLayout::main_pane_elements_muted( EFalse ) );    
       
   371         
       
   372         // Touch pane
       
   373 
       
   374         TInt variety = 0;
       
   375         AknLayoutUtils::LayoutControl( 
       
   376             iTouchPane, 
       
   377             Rect(), 
       
   378             BubbleLayout6::call6_button_grp_pane(variety) );
       
   379         
       
   380         }
       
   381     else if ( iConfigFlags & EBMCallObjectDisplay )
       
   382         {
       
   383         // call object layout
       
   384         iMainPaneControl->SetRect( Rect() );
       
   385         DoLayoutCall2Bubbles();    
       
   386         }        
       
   387     else
       
   388         {
       
   389         // old thumbnail layout
       
   390         DoLayoutCall1Bubbles();    
       
   391         }
       
   392     
       
   393     // Layout number entry
       
   394     TInt neIndex;
       
   395     switch ( iNumberEntry->Place() )
       
   396         {
       
   397         case CBubbleOutlookNumberEntry::ENEBottomRight:
       
   398             neIndex = 1;
       
   399             break;
       
   400         case CBubbleOutlookNumberEntry::ENEIdleState:
       
   401             neIndex = 4;
       
   402             break;
       
   403         default: // CBubbleOutlookNumberEntry::ENEBottom
       
   404             neIndex = 0;
       
   405             break;                        
       
   406         }
       
   407 
       
   408     AknLayoutUtils::LayoutControl( 
       
   409         iNumberEntry, Rect( ), 
       
   410         BubbleLayout::popup_number_entry_window( neIndex ) );        
       
   411     
       
   412     // Layout muted icon
       
   413     if ( !(iConfigFlags & EBMTouchCallhandling) )
       
   414         {
       
   415         AknLayoutUtils::LayoutImage( 
       
   416             iMutedImage, Rect(), 
       
   417             BubbleLayout::main_pane_elements_muted( iNumberEntry->IsUsed() ) );        
       
   418         }
       
   419     }
       
   420 
       
   421 // ---------------------------------------------------------------------------
       
   422 // CBubbleManager::DoLayoutCall1Bubbles
       
   423 // ---------------------------------------------------------------------------
       
   424 //
       
   425 void CBubbleManager::DoLayoutCall1Bubbles()
       
   426     {
       
   427     CBubblePlace* tempBubblePlace = NULL;
       
   428     TUint8 placeCount( TUint8( iBubblePlaces->Count( ) ) );
       
   429     TAknWindowLineLayout placeLayout;
       
   430     
       
   431     for ( TUint8 index = 0 ; index < placeCount ; index++  ) 
       
   432         {
       
   433         tempBubblePlace = iBubblePlaces->At( index );
       
   434         CBubblePlace::TPhoneBubblePlace place = 
       
   435             tempBubblePlace->GetBubblePlace();
       
   436                     
       
   437         switch ( place )
       
   438             {
       
   439             case CBubblePlace::EBottom:
       
   440                 placeLayout = BubbleLayout::popup_call_audio_in_window(1);    
       
   441                 break;
       
   442                 
       
   443             case CBubblePlace::EBottomRightActive:
       
   444                 placeLayout = BubbleLayout::popup_call_audio_second_window(1);
       
   445                 break;
       
   446                 
       
   447             case CBubblePlace::EBottomRightHeld:
       
   448                 placeLayout = BubbleLayout::popup_call_audio_second_window(2);
       
   449                 break;
       
   450                 
       
   451             case CBubblePlace::EMiddleActive:
       
   452                 placeLayout = BubbleLayout::popup_call_audio_first_window(3);
       
   453                 break;
       
   454                 
       
   455             case CBubblePlace::EMiddleHeld:
       
   456                 if ( iBubblePlaces->At( CBubblePlace::EBottomCnap )->IsUsed() )
       
   457                     {
       
   458                     placeLayout = BubbleLayout::popup_call_audio_first_window(7);
       
   459                     }
       
   460                 else
       
   461                     {
       
   462                     placeLayout = BubbleLayout::popup_call_audio_first_window(2);
       
   463                     }
       
   464                 break;
       
   465                 
       
   466             case CBubblePlace::ETopLeft:
       
   467                 placeLayout = BubbleLayout::popup_call_audio_first_window(4);
       
   468                 break;
       
   469                 
       
   470             case CBubblePlace::ETopRight:
       
   471                 placeLayout = BubbleLayout::popup_call_audio_second_window(3);
       
   472                 break;
       
   473                 
       
   474             case CBubblePlace::EHide:
       
   475                 {
       
   476                 TInt v = AknLayoutUtils::ScalableLayoutInterfaceAvailable() ?
       
   477                          5 : 6;
       
   478                 placeLayout = BubbleLayout::popup_call_audio_first_window(v);
       
   479                 }
       
   480                 break;
       
   481                 
       
   482             case CBubblePlace::E2InConf:
       
   483                 placeLayout = BubbleLayout::popup_call_audio_conf_window(1);
       
   484                 break;
       
   485                 
       
   486             case CBubblePlace::E3InConf:
       
   487                 placeLayout = BubbleLayout::popup_call_audio_conf_window(2);
       
   488                 break;
       
   489                 
       
   490             case CBubblePlace::E4InConf:
       
   491                 placeLayout = BubbleLayout::popup_call_audio_conf_window(3);
       
   492                 break;
       
   493                 
       
   494             case CBubblePlace::E5InConf:
       
   495                 placeLayout = BubbleLayout::popup_call_audio_conf_window(4);
       
   496                 break;
       
   497                 
       
   498             case CBubblePlace::EBottomCnap:
       
   499                 placeLayout = BubbleLayout::popup_call_audio_in_window(3);
       
   500                 break;
       
   501                 
       
   502             case CBubblePlace::EMiddleCnap:
       
   503                 placeLayout = BubbleLayout::popup_call_audio_in_window(4);
       
   504                 break;
       
   505                 
       
   506             case CBubblePlace::EVideo:
       
   507                 placeLayout = BubbleLayout3::popup_call3_audio_in_window(0);
       
   508                 break;
       
   509 
       
   510             case CBubblePlace::EVideoCnap:
       
   511                 placeLayout = BubbleLayout3::popup_call3_audio_in_window(0);
       
   512                 break;                                                 
       
   513 
       
   514             case CBubblePlace::EBottomText: // not active
       
   515             case CBubblePlace::EBottomImage: // not active
       
   516             case CBubblePlace::EBottomRightCnap: // not active
       
   517             case CBubblePlace::EBottomImageCnap: // not active
       
   518                 placeLayout = BubbleLayout::popup_call_audio_in_window(1);
       
   519                 break;                 
       
   520                 
       
   521             default:
       
   522                 Panic( EBMPanicPlaceEnumerationDoesNotExist );
       
   523                 break;
       
   524             }
       
   525         
       
   526         AknLayoutUtils::LayoutControl( tempBubblePlace , Rect() , placeLayout );
       
   527         }    
       
   528     }
       
   529     
       
   530 // ---------------------------------------------------------------------------
       
   531 // CBubbleManager::DoLayoutCall2Bubbles
       
   532 // ---------------------------------------------------------------------------
       
   533 //
       
   534 void CBubbleManager::DoLayoutCall2Bubbles()
       
   535     {
       
   536     CBubblePlace* tempBubblePlace = NULL;
       
   537     TUint8 placeCount( TUint8( iBubblePlaces->Count( ) ) );
       
   538     TAknWindowLineLayout placeLayout;
       
   539     
       
   540     for ( TUint8 index = 0 ; index < placeCount ; index++  ) 
       
   541         {
       
   542         tempBubblePlace = iBubblePlaces->At( index );
       
   543         CBubblePlace::TPhoneBubblePlace place = 
       
   544             tempBubblePlace->GetBubblePlace();
       
   545         
       
   546         switch ( place )
       
   547             {
       
   548             case CBubblePlace::EBottom:
       
   549                 placeLayout = BubbleLayout2::popup_call2_audio_in_window(0);
       
   550                 break;
       
   551                 
       
   552             case CBubblePlace::EBottomRightActive:
       
   553                 placeLayout = BubbleLayout2::popup_call2_audio_second_window(0);
       
   554                 break;
       
   555                 
       
   556             case CBubblePlace::EBottomRightHeld:
       
   557                 placeLayout = BubbleLayout2::popup_call2_audio_second_window(1);    
       
   558                 break;
       
   559                 
       
   560             case CBubblePlace::EMiddleActive:
       
   561                 placeLayout = BubbleLayout2::popup_call2_audio_first_window(2);    
       
   562                 break;
       
   563                 
       
   564             case CBubblePlace::EMiddleHeld:
       
   565                 if ( iBubblePlaces->At( CBubblePlace::EBottomRightCnap )->IsUsed() )
       
   566                     {
       
   567                     placeLayout = BubbleLayout2::popup_call2_audio_first_window(18);
       
   568                     }
       
   569                 else
       
   570                     {
       
   571                     placeLayout = BubbleLayout2::popup_call2_audio_first_window(1);    
       
   572                     }                    
       
   573                 break;
       
   574                 
       
   575             case CBubblePlace::ETopLeft:
       
   576                 placeLayout = BubbleLayout2::popup_call2_audio_first_window(3);    
       
   577                 break;
       
   578                 
       
   579             case CBubblePlace::ETopRight:
       
   580                 placeLayout = BubbleLayout2::popup_call2_audio_second_window(2);    
       
   581                 break;
       
   582                 
       
   583             case CBubblePlace::EHide:
       
   584                 placeLayout = BubbleLayout2::popup_call2_audio_first_window(4);    
       
   585                 break;
       
   586                 
       
   587             case CBubblePlace::E2InConf:
       
   588                 placeLayout = BubbleLayout2::popup_call2_audio_conf_window(0);    
       
   589                 break;
       
   590                 
       
   591             case CBubblePlace::E3InConf:
       
   592                 placeLayout = BubbleLayout2::popup_call2_audio_conf_window(1);       
       
   593                 break;
       
   594                 
       
   595             case CBubblePlace::E4InConf:
       
   596                 placeLayout = BubbleLayout2::popup_call2_audio_conf_window(2);        
       
   597                 break;
       
   598                 
       
   599             case CBubblePlace::E5InConf:
       
   600                 placeLayout = BubbleLayout2::popup_call2_audio_conf_window(3);        
       
   601                 break;
       
   602                 
       
   603             case CBubblePlace::EBottomCnap:
       
   604                 placeLayout = BubbleLayout2::popup_call2_audio_in_window(2);    
       
   605                 break;
       
   606                 
       
   607             case CBubblePlace::EMiddleCnap:
       
   608                 placeLayout = BubbleLayout2::popup_call2_audio_in_window(3);    
       
   609                 break;
       
   610                 
       
   611             case CBubblePlace::EBottomText:
       
   612                 placeLayout = BubbleLayout2::popup_call2_audio_in_window(8);
       
   613                 break;                
       
   614 
       
   615             case CBubblePlace::EBottomImage:
       
   616                 placeLayout = BubbleLayout2::popup_call2_audio_first_window(0);
       
   617                 break;                
       
   618                 
       
   619             case CBubblePlace::EVideo:
       
   620                 placeLayout = BubbleLayout3::popup_call3_audio_in_window(0);
       
   621                 break;
       
   622 
       
   623             case CBubblePlace::EVideoCnap:
       
   624                 placeLayout = BubbleLayout3::popup_call3_audio_in_window(0);
       
   625                 break;
       
   626 
       
   627             case CBubblePlace::EBottomRightCnap:
       
   628                 placeLayout = BubbleLayout2::popup_call2_audio_wait_window(9);    
       
   629                 break;
       
   630                 
       
   631             case CBubblePlace::EBottomImageCnap:
       
   632                 placeLayout = BubbleLayout2::popup_call2_audio_first_window(0);    
       
   633                 break;                
       
   634                 
       
   635             default:
       
   636                 Panic( EBMPanicPlaceEnumerationDoesNotExist );
       
   637                 break;
       
   638             }
       
   639        
       
   640         AknLayoutUtils::LayoutControl( tempBubblePlace , Rect() , placeLayout );
       
   641         }    
       
   642     }    
       
   643 
       
   644 // ---------------------------------------------------------------------------
       
   645 // CBubbleManager::DoLayoutCall4Bubbles
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 void CBubbleManager::DoLayoutCall4Bubbles( const TRect& aWindowPane )
       
   649     {
       
   650     CBubblePlace* tempBubblePlace = NULL;
       
   651     TUint8 placeCount( TUint8( iBubblePlaces->Count( ) ) );
       
   652     TAknWindowLineLayout placeLayout;
       
   653     TBool initCall = InitializingCall();
       
   654     
       
   655     for ( TUint8 index = 0 ; index < placeCount ; index++  ) 
       
   656         {
       
   657         tempBubblePlace = iBubblePlaces->At( index );
       
   658         CBubblePlace::TPhoneBubblePlace place = 
       
   659             tempBubblePlace->GetBubblePlace();
       
   660         
       
   661         switch ( place )
       
   662             {
       
   663             case CBubblePlace::EBottom:
       
   664             case CBubblePlace::EBottomCnap:
       
   665                 if ( initCall )
       
   666                     {
       
   667                     // in / out
       
   668                     placeLayout = 
       
   669                         BubbleLayout4::popup_call4_audio_in_window(4);
       
   670                     }
       
   671                 else
       
   672                     {
       
   673                     // incall
       
   674                     placeLayout =
       
   675                         BubbleLayout6::popup_call6_audio_first_window(0);    
       
   676                     }
       
   677                 
       
   678                 break;
       
   679                 
       
   680             // in / out with text
       
   681             case CBubblePlace::EBottomText:
       
   682                 placeLayout = BubbleLayout2::popup_call2_audio_in_window(8);
       
   683                 break;                
       
   684 
       
   685             // in with video                
       
   686             case CBubblePlace::EVideo:
       
   687             case CBubblePlace::EVideoCnap:
       
   688                 placeLayout = BubbleLayout3::popup_call3_audio_in_window(0);
       
   689                 break;
       
   690 
       
   691             // first
       
   692             case CBubblePlace::EBottomImage:
       
   693             case CBubblePlace::EBottomImageCnap:
       
   694                 placeLayout = BubbleLayout6::popup_call6_audio_first_window(0);
       
   695                 break;                
       
   696 
       
   697             // two calls - active
       
   698             case CBubblePlace::EBottomRightActiveTouch:
       
   699             case CBubblePlace::EBottomRightActiveCnapTouch:                
       
   700                 placeLayout = BubbleLayout4::popup_call4_audio_second_window(0);
       
   701                 break;
       
   702             // two calls - active                
       
   703             case CBubblePlace::EMiddleHeldTouch:                
       
   704                 placeLayout = BubbleLayout4::popup_call4_audio_first_window(1);          
       
   705                 break;                
       
   706             
       
   707             // three calls - held
       
   708             case CBubblePlace::ETopRight:
       
   709                 placeLayout = BubbleLayout4::popup_call4_audio_second_window(1);    
       
   710                 break;
       
   711             // two or three calls - active
       
   712             case CBubblePlace::ETopLeft:
       
   713                 placeLayout = BubbleLayout4::popup_call4_audio_first_window(2);    
       
   714                 break;
       
   715             // two or three calls - waiting    
       
   716             case CBubblePlace::EBottomRightActive:
       
   717             case CBubblePlace::EBottomRightCnap:
       
   718             case CBubblePlace::EBottomRightHeld:
       
   719                 placeLayout = BubbleLayout4::popup_call4_audio_wait_window(0);    
       
   720                 break;
       
   721             
       
   722             // conference
       
   723             case CBubblePlace::E2InConf:
       
   724                 placeLayout = BubbleLayout4::popup_call4_audio_conference_window(3);    
       
   725                 break;
       
   726                 
       
   727             case CBubblePlace::E3InConf:
       
   728                 placeLayout = BubbleLayout4::popup_call4_audio_conference_window(2);       
       
   729                 break;
       
   730                 
       
   731             case CBubblePlace::E4InConf:
       
   732                 placeLayout = BubbleLayout4::popup_call4_audio_conference_window(1);        
       
   733                 break;
       
   734                 
       
   735             case CBubblePlace::E5InConf:
       
   736                 placeLayout = BubbleLayout4::popup_call4_audio_conference_window(0);        
       
   737                 break;
       
   738 
       
   739             // not used in touch
       
   740             case CBubblePlace::EMiddleActive:
       
   741             case CBubblePlace::EMiddleHeld:
       
   742             case CBubblePlace::EMiddleCnap:
       
   743             case CBubblePlace::EHide:
       
   744                 continue;
       
   745                 
       
   746             default:
       
   747                 Panic( EBMPanicPlaceEnumerationDoesNotExist );
       
   748                 break;
       
   749             }
       
   750        
       
   751         AknLayoutUtils::LayoutControl( tempBubblePlace , aWindowPane , placeLayout );
       
   752         }    
       
   753     }    
       
   754 
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // CBubbleManager::PositionChanged
       
   758 // ---------------------------------------------------------------------------
       
   759 //
       
   760 void CBubbleManager::PositionChanged()
       
   761     {
       
   762     AknsUtils::RegisterControlPosition( this );
       
   763     }
       
   764 
       
   765 // ---------------------------------------------------------------------------
       
   766 // CBubbleManager::CountComponentControls() const
       
   767 //
       
   768 //  Controls: NumberEntry, MutedImage and ActivePlaces
       
   769 // ---------------------------------------------------------------------------
       
   770 //
       
   771 TInt CBubbleManager::CountComponentControls() const
       
   772     {
       
   773     if ( ( iConfigFlags & EBMTouchCallhandling ) && 
       
   774          ( iTouchPane->IsVisible() ) )
       
   775         {
       
   776         return 3 + iActivePlaces->Count(); // ne + muted + touchpane + places
       
   777         }
       
   778     else
       
   779         {
       
   780         return 2 + iActivePlaces->Count(); // ne + muted + places
       
   781         }       
       
   782     }
       
   783 
       
   784 // ---------------------------------------------------------------------------
       
   785 // CBubbleManager::ComponentControl(TInt aIndex) const
       
   786 //
       
   787 //  First give active places. Then possible NE, muted-image and AnimStarter
       
   788 // ---------------------------------------------------------------------------
       
   789 //
       
   790 CCoeControl* CBubbleManager::ComponentControl( TInt aIndex ) const
       
   791     {
       
   792     TInt activePlacesCount = iActivePlaces->Count();
       
   793 
       
   794     // If too high value, return NULL
       
   795     if ( aIndex >= activePlacesCount + 3 )
       
   796         {
       
   797         return NULL;
       
   798         }
       
   799 
       
   800     if ( aIndex < activePlacesCount )
       
   801         {
       
   802         return iActivePlaces->At( aIndex  );
       
   803         }
       
   804 
       
   805     if ( aIndex == activePlacesCount )
       
   806         {
       
   807         return iNumberEntry;
       
   808         }
       
   809 
       
   810     if ( iConfigFlags & EBMTouchCallhandling )
       
   811         {
       
   812         if ( aIndex == ( activePlacesCount + 1 ) )
       
   813             {
       
   814             return iMutedImage;    
       
   815             }
       
   816 
       
   817         return iTouchPane;
       
   818         }
       
   819     else
       
   820         {
       
   821         return iMutedImage;    
       
   822         }
       
   823     }
       
   824 
       
   825 // ---------------------------------------------------------------------------
       
   826 // CBubbleManager::Draw
       
   827 // ---------------------------------------------------------------------------
       
   828 //
       
   829 void CBubbleManager::Draw( const TRect& aRect ) const
       
   830     {
       
   831     // clear the backround area.
       
   832     CWindowGc& gc = SystemGc();
       
   833     gc.SetBrushColor( AKN_LAF_COLOR( BubbleLayout::LayoutColourWhite() ) );
       
   834 
       
   835     // Draw just the bitmaps
       
   836     if ( iMainPaneControl &&
       
   837          iMainPaneControl->IsVisible() )
       
   838         {
       
   839         // main pane image
       
   840         iMainPaneControl->DrawBitmaps( aRect );
       
   841         }
       
   842     
       
   843     for ( TInt i = 0 ; i < iActivePlaces->Count() ; i++ )
       
   844         {
       
   845         iActivePlaces->At(i)->GetBubbleOutlook().DrawBitmaps( gc );
       
   846         }
       
   847     
       
   848     if ( iNumberEntry->IsUsed() )
       
   849         {
       
   850         iNumberEntry->DrawBitmaps(  gc );
       
   851         }
       
   852     }
       
   853     
       
   854 // ---------------------------------------------------------------------------
       
   855 //  CBubbleManager::MakeVisible
       
   856 //  
       
   857 // 
       
   858 // ---------------------------------------------------------------------------
       
   859 //
       
   860 void CBubbleManager::MakeVisible( TBool aVisible )
       
   861     {
       
   862     CCoeControl::MakeVisible( aVisible );
       
   863     
       
   864     if ( aVisible )    
       
   865         {
       
   866         StartAnimations();    
       
   867         }        
       
   868     }
       
   869 
       
   870 // ---------------------------------------------------------------------------
       
   871 // CBubbleManager::StartChanges
       
   872 //  
       
   873 //  Reset all places so there won't be anything wrong left.
       
   874 // ---------------------------------------------------------------------------
       
   875 //
       
   876 EXPORT_C void CBubbleManager::StartChanges( )
       
   877     {
       
   878     BM_TRACE_( "[BUBBLEMANAGER] CBubbleManager::StartChanges" );
       
   879     iIsReadyToDraw++;
       
   880     if ( iIsReadyToDraw > 1 ) // is this called already?
       
   881         {
       
   882         return;
       
   883         }
       
   884     
       
   885     // clear all used areas
       
   886     CBubblePlace* tempBubblePlace = NULL;
       
   887     TInt placeCount = iBubblePlaces->Count();
       
   888     for ( TUint8 index = 0 ; index < placeCount ; index++  ) 
       
   889         {
       
   890         tempBubblePlace = iBubblePlaces->At( index );
       
   891         if ( tempBubblePlace->IsUsed() )
       
   892             {
       
   893             Window().Invalidate( tempBubblePlace->Rect() );
       
   894             tempBubblePlace->SetIsUsed( EFalse );
       
   895             }
       
   896         }
       
   897     
       
   898     iActivePlaces->Delete( 0 , iActivePlaces->Count() ); // do not compress!!
       
   899 
       
   900     if ( iTouchPane )
       
   901         {
       
   902         iTouchPane->SetUpdating( ETrue );                
       
   903         }
       
   904     }
       
   905 
       
   906 // ---------------------------------------------------------------------------
       
   907 // CBubbleManager::EndChanges
       
   908 //  
       
   909 //  Check the situation and decide which outlook to take. 
       
   910 // ---------------------------------------------------------------------------
       
   911 //
       
   912 EXPORT_C void CBubbleManager::EndChanges( )
       
   913     {
       
   914     BM_TRACE_( "[BUBBLEMANAGER] CBubbleManager::EndChanges" );
       
   915      
       
   916     __ASSERT_ALWAYS( 
       
   917         iIsReadyToDraw > 0 , Panic( EBMPanicErrorInStartAndEndChanges ) );
       
   918 
       
   919     iIsReadyToDraw--;
       
   920     if ( iIsReadyToDraw != 0 )
       
   921         {
       
   922         return;
       
   923         }
       
   924 
       
   925     if ( iConfHeader->IsExpanded() )
       
   926         {
       
   927         BuildExpandedConference();
       
   928         }
       
   929     else if ( iNumberEntry->IsUsed() && iNumberEntry->IsVisible() )
       
   930         {
       
   931         BuildBubblesWithNE();
       
   932         }
       
   933     else if ( ( iConfigFlags & EBMTouchCallhandling ) )
       
   934         {
       
   935         BuildBubblesForTouch();    
       
   936         }
       
   937     else
       
   938         {
       
   939         BuildBubbles();
       
   940         }
       
   941 
       
   942     // Stop video if playing and video bubble is not active.
       
   943     if ( ( iVideoFlags & EBMVideoPlayingVideo ) &&
       
   944          !( iVideoFlags & EBMVideoBubbleActive ) )
       
   945         {
       
   946         StopAndDeleteVideoPlayer();
       
   947         }                
       
   948 
       
   949     // Touch pane        
       
   950     if ( iConfigFlags & EBMTouchCallhandling )
       
   951         {
       
   952         if ( iTouchPaneSetVisible &&        // Client sets
       
   953              iActiveHeaders->Count() > 0 && // Incall situation                   
       
   954              !iNumberEntry->IsVisible() )   
       
   955             {
       
   956             iTouchPane->MakeVisible( ETrue );
       
   957             }
       
   958         else
       
   959             {
       
   960             iTouchPane->MakeVisible( EFalse );    
       
   961             }    
       
   962         }
       
   963 
       
   964     if ( ( iConfigFlags & EBMCallObjectDisplay ) && 
       
   965          iActiveHeaders->Count() > 0 &&
       
   966          !( iVideoFlags & EBMVideoBubbleActive ) )
       
   967         {
       
   968         // Image is created only for incoming & outgoing
       
   969         // calls, check is inside method.
       
   970         BuildMainPaneImage();
       
   971         }
       
   972     
       
   973     SizeChanged();
       
   974     
       
   975     // Invalidate the new areas.
       
   976     for ( TInt i = 0 ; i < iActivePlaces->Count() ; i++ )
       
   977         {
       
   978         iActivePlaces->At(i)->GetBubbleOutlook().DrawDeferred();
       
   979         }
       
   980     if ( iNumberEntry->IsUsed() )
       
   981         {
       
   982         iNumberEntry->DrawDeferred();
       
   983         iNumberEntry->GetEditor()->DrawDeferred();
       
   984         }
       
   985         
       
   986     if ( iTouchPane )
       
   987         {
       
   988         iTouchPane->SetUpdating( EFalse );
       
   989         }
       
   990             
       
   991 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
   992     TBool calledBegin = (TBool) CAknTransitionUtils::GetData( ( TInt ) this );
       
   993     // Only draw parent control if no number entry exists, the number entry is
       
   994     // used or if begin has not been called.
       
   995     if ( !iNumberEntry || iNumberEntry->IsUsed() || !calledBegin )
       
   996         {
       
   997         // Do redraw. Do not use DrawDeferred() here!
       
   998         iParentControl->DrawNow();
       
   999         }
       
  1000 #else
       
  1001     // Do redraw. Do not use DrawDeferred() here!
       
  1002     iParentControl->DrawNow();
       
  1003 #endif
       
  1004     // Start animations. 
       
  1005     StartAnimations();
       
  1006     
       
  1007     // Start video if video bubble is active.
       
  1008     if ( ( iVideoFlags & EBMVideoBubbleActive ) &&
       
  1009          !( iVideoFlags & EBMVideoPlayingVideo ) )
       
  1010         {
       
  1011         CreateVideoPlayerAndPlay();
       
  1012         }
       
  1013 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
  1014     if ( calledBegin )
       
  1015         {
       
  1016         // Initialize transition effect
       
  1017         CAknTransitionUtils::SetAllParents( iNumberEntry );
       
  1018         GfxTransEffect::SetDemarcation( iNumberEntry, iNumberEntry->Rect() );
       
  1019         GfxTransEffect::End( iNumberEntry );
       
  1020 
       
  1021         // Reset begin call reminder
       
  1022         CAknTransitionUtils::SetData( (TInt) this, 0 );
       
  1023         }
       
  1024     // SetFocus here instead of in SetNumberEntryVisible
       
  1025     if ( iNumberEntry->IsVisible() )
       
  1026         {
       
  1027         iNumberEntry->SetFocus( ETrue );
       
  1028         }
       
  1029 #endif
       
  1030     return;
       
  1031     }
       
  1032 
       
  1033 
       
  1034 // ---------------------------------------------------------------------------
       
  1035 //  CBubbleManager::SetActivePlace
       
  1036 //  
       
  1037 //  This helps the EndChanges() to make bubble places active.
       
  1038 // ---------------------------------------------------------------------------
       
  1039 //
       
  1040 void CBubbleManager::SetActivePlace( 
       
  1041     const CBubblePlace::TPhoneBubblePlace& aPlace , 
       
  1042     CBubbleHeader& aHeader )
       
  1043     {
       
  1044     CBubblePlace* place = iBubblePlaces->At( aPlace );
       
  1045     place->SetIsUsed( ETrue );
       
  1046     CBubbleOutlook& bubbleOutlook = place->GetBubbleOutlook( );
       
  1047     bubbleOutlook.ReadBubbleHeader( aHeader );
       
  1048     iActivePlaces->InsertL( iActivePlaces->Count( ), place ); // Can't leave
       
  1049     }
       
  1050 
       
  1051 
       
  1052 void CBubbleManager::BuildExpandedConference()
       
  1053     {
       
  1054     iNumberEntry->SetPlace( CBubbleOutlookNumberEntry::ENENone );
       
  1055     switch ( iConfHeader->RowCount() )
       
  1056         {
       
  1057         // Cases mean number of calls in conference.
       
  1058         case 2:
       
  1059             SetActivePlace( CBubblePlace::E2InConf , *iConfHeader );
       
  1060             break;
       
  1061         case 3:
       
  1062             SetActivePlace( CBubblePlace::E3InConf , *iConfHeader );
       
  1063             break;
       
  1064         case 4:
       
  1065             SetActivePlace( CBubblePlace::E4InConf , *iConfHeader );
       
  1066             break;
       
  1067         case 5:
       
  1068             SetActivePlace( CBubblePlace::E5InConf , *iConfHeader );
       
  1069             break;
       
  1070         default:
       
  1071             Panic( EBMPanicPlaceEnumerationDoesNotExist );
       
  1072             break;
       
  1073         }
       
  1074     return;
       
  1075     }
       
  1076 
       
  1077 
       
  1078 // ---------------------------------------------------------------------------
       
  1079 //  CBubbleManager::FindNextDrawableHeader
       
  1080 //  
       
  1081 // 
       
  1082 // ---------------------------------------------------------------------------
       
  1083 //
       
  1084 void CBubbleManager::FindNextDrawableHeader( TUint8& aIndex )
       
  1085     {
       
  1086     while( iActiveHeaders->At( aIndex )->IsInConference() ) 
       
  1087         {
       
  1088         aIndex++;
       
  1089         }
       
  1090     }
       
  1091 
       
  1092 // ---------------------------------------------------------------------------
       
  1093 //  CBubbleManager::ShownHeaderCount
       
  1094 // ---------------------------------------------------------------------------
       
  1095 //
       
  1096 EXPORT_C TUint8 CBubbleManager::ShownHeaderCount() const
       
  1097     {
       
  1098     // We have to find headers that are really shown. 
       
  1099     // That means headers which are 
       
  1100     // used and are NOT in conference. 
       
  1101     TUint8 bubbleAmount = 0;
       
  1102     TUint activeCount = iActiveHeaders->Count();
       
  1103     for (TUint8 i = 0 ; i < activeCount ; i++ )
       
  1104         {
       
  1105         if ( !iActiveHeaders->At(i)->IsInConference() )
       
  1106             {
       
  1107             bubbleAmount++;
       
  1108             }
       
  1109         }
       
  1110     return bubbleAmount;
       
  1111     }
       
  1112 
       
  1113 // ---------------------------------------------------------------------------
       
  1114 //  CBubbleManager::BuildBubbles
       
  1115 //  
       
  1116 // 
       
  1117 // ---------------------------------------------------------------------------
       
  1118 //
       
  1119 void CBubbleManager::BuildBubbles()
       
  1120     { 
       
  1121     const TUint8 bubbleAmount = ShownHeaderCount();
       
  1122     iVideoFlags &= ~EBMVideoBubbleActive;
       
  1123     
       
  1124     // Without number entry.
       
  1125     switch ( bubbleAmount )
       
  1126         {
       
  1127         case 0:
       
  1128             break;
       
  1129         case 1:
       
  1130             {
       
  1131             TUint8 index = 0;
       
  1132             FindNextDrawableHeader( index );
       
  1133             CBubbleHeader* header = iActiveHeaders->At( index );
       
  1134             TPhoneCallState callState = header->CallState();
       
  1135             TBool callObjectText( 
       
  1136                   ( iConfigFlags & EBMCallObjectDisplay ) && 
       
  1137                   ( header->CallObjectText().Length() > 0) );
       
  1138             TBool callObjectImage( 
       
  1139                   ( iConfigFlags & EBMCallObjectDisplay ) && 
       
  1140                   header->CallObjectImage() );                  
       
  1141             
       
  1142             TInt cnapLength = header->CNAP().Length();
       
  1143 
       
  1144             // Video
       
  1145             if ( callState == EIncoming && 
       
  1146                  iVideoFlags & EBMVideoSetAsRingTone )
       
  1147                 {
       
  1148                 if ( cnapLength ) // 3-lines
       
  1149                     {
       
  1150                     SetActivePlace( CBubblePlace::EVideoCnap, 
       
  1151                                     *header );
       
  1152                                     iVideoFlags |= EBMVideoBubbleActive;
       
  1153                     }
       
  1154                 else
       
  1155                     {
       
  1156                     SetActivePlace( CBubblePlace::EVideo, 
       
  1157                                     *header );
       
  1158                                     iVideoFlags |= EBMVideoBubbleActive;    
       
  1159                     }                            
       
  1160                 }
       
  1161             // Caller text                    
       
  1162             else if ( callObjectText && ( callState == EIncoming || 
       
  1163                                           callState == EOutgoing ||
       
  1164                                           callState == EAlerting ||
       
  1165                                           callState == EAlertToDisconnected ) )
       
  1166                 {
       
  1167                 SetActivePlace( CBubblePlace::EBottomText,
       
  1168                                 *header );                            
       
  1169                 }
       
  1170             // Caller image
       
  1171             else if ( callObjectImage && ( callState == EActive ||
       
  1172                                            callState == EOnHold ||
       
  1173                                            callState == EDisconnected ) )
       
  1174                 {
       
  1175                 CBubbleHeader::TBMCallObjectImageType imageType = 
       
  1176                     header->CallObjectImageType();
       
  1177 
       
  1178                 // Theme image -> use normal bubble                        
       
  1179                 if ( imageType == CBubbleHeader::EThemeImage ||
       
  1180                      imageType == CBubbleHeader::ETextBasedImage )
       
  1181                     {
       
  1182                     if ( cnapLength ) // 3-lines
       
  1183                         {
       
  1184                         SetActivePlace( CBubblePlace::EBottomCnap,
       
  1185                                         *header );    
       
  1186                         }
       
  1187                     else
       
  1188                         {
       
  1189                         SetActivePlace( CBubblePlace::EBottom,
       
  1190                                         *header );    
       
  1191                         }                                
       
  1192                     }
       
  1193                 // Caller image -> use bigger bubble                                                    
       
  1194                 else
       
  1195                     {
       
  1196                     TSize imageSize = header->CallObjectImage()->SizeInPixels();
       
  1197                     TSize tinySize = CallObjectImageIncallSize( ETrue );
       
  1198                     TBool tiny = imageSize.iHeight < tinySize.iHeight;
       
  1199                     iBottomImageVariety = tiny ? 0 : 4;
       
  1200                     
       
  1201                     if ( cnapLength ) // 3-lines
       
  1202                         {
       
  1203                         CBubblePlace::TPhoneBubblePlace place = tiny ?
       
  1204                             CBubblePlace::EBottomCnap : CBubblePlace::EBottomImageCnap;
       
  1205                         
       
  1206                         SetActivePlace( place,
       
  1207                                         *header );                        
       
  1208                         }
       
  1209                     else 
       
  1210                         {
       
  1211                         CBubblePlace::TPhoneBubblePlace place = tiny ?
       
  1212                             CBubblePlace::EBottom : CBubblePlace::EBottomImage;
       
  1213                         
       
  1214                         SetActivePlace( place,
       
  1215                                         *header );                        
       
  1216                         }                           
       
  1217                     }
       
  1218                 }
       
  1219             // Basic
       
  1220             else
       
  1221                 {
       
  1222                 if ( cnapLength ) // 3-lines
       
  1223                     {
       
  1224                     SetActivePlace( CBubblePlace::EBottomCnap,
       
  1225                                     *header );
       
  1226                     }
       
  1227                 else
       
  1228                     {
       
  1229                     SetActivePlace( CBubblePlace::EBottom ,
       
  1230                                     *header );
       
  1231                     }    
       
  1232                 }
       
  1233             break;
       
  1234             }
       
  1235         case 2:
       
  1236             {
       
  1237             // first call: middle held/active
       
  1238             TUint8 index = 0;
       
  1239             FindNextDrawableHeader( index );
       
  1240             TPhoneCallState callState = 
       
  1241                 iActiveHeaders->At( index )->CallState();
       
  1242             TInt cnapLength = iActiveHeaders->At( index )->CNAP().Length();                
       
  1243 
       
  1244             // second call: bottom held/active
       
  1245             TUint8 index2 = TUint8(index + 1);
       
  1246             FindNextDrawableHeader( index2 );
       
  1247             TInt cnapLength2 = iActiveHeaders->At( index2 )->CNAP().Length();
       
  1248             TPhoneCallState callState2 = 
       
  1249                 iActiveHeaders->At( index2 )->CallState();
       
  1250 
       
  1251             
       
  1252             CBubblePlace::TPhoneBubblePlace place;
       
  1253             
       
  1254             if ( callState == EOnHold  )
       
  1255                 {
       
  1256                 place = CBubblePlace::EMiddleHeld;
       
  1257                 }
       
  1258             else if ( cnapLength  ) // and not held
       
  1259                 {
       
  1260                 place = CBubblePlace::EMiddleCnap;    
       
  1261                 }
       
  1262             else
       
  1263                 {
       
  1264                 place = CBubblePlace::EMiddleActive;
       
  1265                 }                
       
  1266             
       
  1267             CBubblePlace::TPhoneBubblePlace place2 = 
       
  1268                 CBubblePlace::EBottomRightActive;
       
  1269             
       
  1270             if ( callState2 == EOnHold )
       
  1271                 {
       
  1272                 place2 = CBubblePlace::EBottomRightHeld;
       
  1273                 }
       
  1274             else if ( cnapLength2 ) // and not held
       
  1275                 {
       
  1276                 if ( cnapLength == 0 ||
       
  1277                      callState2 == EOutgoing ||
       
  1278                      callState2 == EAlerting || 
       
  1279                      callState2 == EAlertToDisconnected ||
       
  1280                      callState2 == EWaiting ||
       
  1281                      callState2 == EActive )                
       
  1282                     {
       
  1283                     // bottom shows 3-lines
       
  1284                     place = CBubblePlace::EMiddleHeld;
       
  1285                     place2 = CBubblePlace::EBottomRightCnap;
       
  1286                     }
       
  1287                 else
       
  1288                     {
       
  1289                     place2 = CBubblePlace::EBottomRightHeld;
       
  1290                     }                    
       
  1291                 }
       
  1292             else
       
  1293                 {
       
  1294                 place2 = CBubblePlace::EBottomRightActive;    
       
  1295                 }                
       
  1296             
       
  1297             // set drawing order
       
  1298             if ( callState2 > callState )
       
  1299                 {
       
  1300                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1301                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1302                 }
       
  1303             else
       
  1304                 {
       
  1305                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1306                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1307                 }                    
       
  1308             }
       
  1309             break;
       
  1310         case 3:
       
  1311             {
       
  1312             TUint8 index = 0;
       
  1313             FindNextDrawableHeader( index );
       
  1314             
       
  1315             TUint8 index2 = TUint8( index + 1 );
       
  1316             FindNextDrawableHeader( index2 );
       
  1317             
       
  1318             if ( iActiveHeaders->At( index2 )->CallState( ) 
       
  1319                 > iActiveHeaders->At( index )->CallState( ) )
       
  1320                 {
       
  1321                 SetActivePlace( 
       
  1322                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index ) );
       
  1323                 SetActivePlace( 
       
  1324                     CBubblePlace::ETopRight , *iActiveHeaders->At( index2 ) );
       
  1325                 }
       
  1326             else
       
  1327                 {
       
  1328                 SetActivePlace( 
       
  1329                     CBubblePlace::ETopRight , *iActiveHeaders->At( index2 ) );
       
  1330                 SetActivePlace( 
       
  1331                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index ) );
       
  1332                 }
       
  1333             
       
  1334             
       
  1335             index = TUint8( index2 + 1 );
       
  1336             FindNextDrawableHeader( index );
       
  1337             SetActivePlace( 
       
  1338                 CBubblePlace::EBottom , *iActiveHeaders->At( index ) );
       
  1339             break;
       
  1340             }
       
  1341         default:
       
  1342             Panic( EBMPanicInvalidNumberOfHeaders );
       
  1343             break;
       
  1344         }
       
  1345     }
       
  1346     
       
  1347 // ---------------------------------------------------------------------------
       
  1348 //  CBubbleManager::BuildBubblesWithNE
       
  1349 //  
       
  1350 // 
       
  1351 // ---------------------------------------------------------------------------
       
  1352 //
       
  1353 void CBubbleManager::BuildBubblesWithNE()
       
  1354     { 
       
  1355     const TUint8 bubbleAmount = ShownHeaderCount();
       
  1356     iVideoFlags &= ~EBMVideoBubbleActive;
       
  1357     
       
  1358     switch ( bubbleAmount )
       
  1359         {
       
  1360         case 0:
       
  1361             if ( iConfigFlags & EBMBigNEInIdleState )
       
  1362                 {
       
  1363                 iNumberEntry->SetPlace(
       
  1364                     CBubbleOutlookNumberEntry::ENEIdleState );
       
  1365                 }
       
  1366             else
       
  1367                 {
       
  1368                 iNumberEntry->SetPlace(
       
  1369                     CBubbleOutlookNumberEntry::ENEBottom );
       
  1370                 }                
       
  1371             break;
       
  1372         case 1:
       
  1373             {
       
  1374             // NE is placed according to it's activation time compared 
       
  1375             // to call's activation.
       
  1376             TUint8 index = 0;
       
  1377             FindNextDrawableHeader( index );
       
  1378             TInt cnapLength = iActiveHeaders->At( index )->CNAP().Length();
       
  1379             TPhoneCallState callState = 
       
  1380                 iActiveHeaders->At( index )->CallState();
       
  1381 
       
  1382             CBubbleOutlook& bubbleOutlook = 
       
  1383                 iBubblePlaces->
       
  1384                     At( CBubblePlace::EMiddleHeld )->GetBubbleOutlook( );
       
  1385             CBubbleOutlookMiddle& bubbleMiddle =  
       
  1386                 static_cast< CBubbleOutlookMiddle& >( bubbleOutlook ) ;
       
  1387             bubbleMiddle.SetIsUnder( ETrue );
       
  1388 
       
  1389             if ( cnapLength )
       
  1390                 {
       
  1391                 SetActivePlace( CBubblePlace::EMiddleCnap ,
       
  1392                                 *iActiveHeaders->At( index ) );
       
  1393                 }
       
  1394             else
       
  1395                 {
       
  1396                 SetActivePlace( CBubblePlace::EMiddleHeld ,
       
  1397                                 *iActiveHeaders->At( index ) );
       
  1398                 }
       
  1399             iNumberEntry->SetPlace( CBubbleOutlookNumberEntry::ENEBottomRight );
       
  1400             break;
       
  1401             }
       
  1402         case 2:
       
  1403             {
       
  1404             // NE goes top left. Calls go like second and waiting 
       
  1405             // call when there are three calls.
       
  1406             iNumberEntry->SetPlace( CBubbleOutlookNumberEntry::ENEBottom );
       
  1407                         
       
  1408             // first call: middle held/active
       
  1409             TUint8 index = 0;
       
  1410             FindNextDrawableHeader( index );
       
  1411             CBubblePlace::TPhoneBubblePlace place = CBubblePlace::ETopLeft;
       
  1412             
       
  1413             // second call: bottom held/active
       
  1414             TUint8 index2 = TUint8(index + 1);
       
  1415             FindNextDrawableHeader( index2 );
       
  1416             CBubblePlace::TPhoneBubblePlace place2 = CBubblePlace::ETopRight;
       
  1417                         
       
  1418             // set drawing order
       
  1419             if ( iActiveHeaders->At( index2 )->CallState( ) 
       
  1420                 > iActiveHeaders->At( index )->CallState( ) )
       
  1421                 {
       
  1422                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1423                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1424                 }
       
  1425             else
       
  1426                 {
       
  1427                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1428                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1429                 }                    
       
  1430             
       
  1431             break;
       
  1432             }
       
  1433         case 3:
       
  1434             {
       
  1435             iNumberEntry->SetPlace( CBubbleOutlookNumberEntry::ENEBottom );
       
  1436             
       
  1437             TUint8 index = 0;
       
  1438             FindNextDrawableHeader( index );
       
  1439             
       
  1440             TUint8 index2 = TUint8( index + 1 );
       
  1441             FindNextDrawableHeader( index2 );
       
  1442                         
       
  1443             if ( iActiveHeaders->At( index2 )->CallState( ) 
       
  1444                 > iActiveHeaders->At( index )->CallState( ) )
       
  1445                 {
       
  1446                 SetActivePlace( 
       
  1447                     CBubblePlace::EHide , *iActiveHeaders->At( index ) );
       
  1448                 SetActivePlace( 
       
  1449                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index2 ) );
       
  1450                 }
       
  1451             else
       
  1452                 {
       
  1453                 SetActivePlace( 
       
  1454                     CBubblePlace::EHide , *iActiveHeaders->At( index2 ) );
       
  1455                 SetActivePlace( 
       
  1456                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index ) );
       
  1457                 }
       
  1458             
       
  1459             index = TUint8( index2 + 1 );
       
  1460             FindNextDrawableHeader( index );
       
  1461             SetActivePlace( 
       
  1462                 CBubblePlace::ETopRight , *iActiveHeaders->At( index ) );
       
  1463             break;
       
  1464             }
       
  1465         default:
       
  1466             Panic( EBMPanicInvalidNumberOfHeaders );
       
  1467             break;
       
  1468         }
       
  1469     return;           
       
  1470     }
       
  1471 
       
  1472 // ---------------------------------------------------------------------------
       
  1473 //  CBubbleManager::BuildBubblesForTouch
       
  1474 //  
       
  1475 // 
       
  1476 // ---------------------------------------------------------------------------
       
  1477 //
       
  1478 void CBubbleManager::BuildBubblesForTouch()
       
  1479     {
       
  1480     const TUint8 bubbleAmount = ShownHeaderCount();
       
  1481     iVideoFlags &= ~EBMVideoBubbleActive;
       
  1482     
       
  1483     // Without number entry.
       
  1484     switch ( bubbleAmount )
       
  1485         {
       
  1486         case 0:
       
  1487             break;
       
  1488         case 1:
       
  1489             {
       
  1490             TUint8 index = 0;
       
  1491             FindNextDrawableHeader( index );
       
  1492             CBubbleHeader* header = iActiveHeaders->At( index );
       
  1493             TPhoneCallState callState = header->CallState();
       
  1494             TBool callObjectText( 
       
  1495                   ( iConfigFlags & EBMCallObjectDisplay ) && 
       
  1496                   ( header->CallObjectText().Length() > 0) );
       
  1497             TBool callObjectImage( 
       
  1498                   ( iConfigFlags & EBMCallObjectDisplay ) && 
       
  1499                   header->CallObjectImage() );                  
       
  1500             
       
  1501             TInt cnapLength = header->CNAP().Length();
       
  1502 
       
  1503             // Video
       
  1504             if ( iVideoFlags & EBMVideoSetAsRingTone &&
       
  1505                  ( callState == EIncoming || callState == EAlertToDisconnected ) )
       
  1506                 {
       
  1507                 if ( cnapLength ) // 3-lines
       
  1508                     {
       
  1509                     SetActivePlace( CBubblePlace::EVideoCnap, 
       
  1510                                     *header );
       
  1511                                     iVideoFlags |= EBMVideoBubbleActive;
       
  1512                     }
       
  1513                 else
       
  1514                     {
       
  1515                     SetActivePlace( CBubblePlace::EVideo, 
       
  1516                                     *header );
       
  1517                                     iVideoFlags |= EBMVideoBubbleActive;    
       
  1518                     }                            
       
  1519                 }
       
  1520             // Caller text                    
       
  1521             else if ( callObjectText && ( callState == EIncoming || 
       
  1522                                           callState == EOutgoing ||
       
  1523                                           callState == EAlerting ||
       
  1524                                           callState == EAlertToDisconnected ) )
       
  1525                 {
       
  1526                 SetActivePlace( CBubblePlace::EBottomText,
       
  1527                                 *header );                            
       
  1528                 }
       
  1529             // Incall
       
  1530             else if ( ( callState == EActive ||
       
  1531                         callState == EOnHold ||
       
  1532                         callState == EDisconnected ) )                
       
  1533                 {
       
  1534                 CBubbleHeader::TBMCallObjectImageType imageType = 
       
  1535                     header->CallObjectImageType();
       
  1536                 
       
  1537                 if ( callObjectImage && 
       
  1538                      ( imageType == CBubbleHeader::EGalleryImage ) )
       
  1539                     {
       
  1540                     TSize imageSize = header->CallObjectImage()->SizeInPixels();
       
  1541                     TSize tinySize = CallObjectImageIncallSize( ETrue );
       
  1542                     TBool tiny = imageSize.iHeight < tinySize.iHeight;
       
  1543                     iBottomImageVariety = tiny ? 0 : 4;
       
  1544                     
       
  1545                     CBubblePlace::TPhoneBubblePlace place;
       
  1546                     place = cnapLength ? CBubblePlace::EBottomImageCnap :
       
  1547                                          CBubblePlace::EBottomImage;
       
  1548                     
       
  1549                     SetActivePlace( place,
       
  1550                                     *header );                        
       
  1551                     }
       
  1552                 else
       
  1553                     {
       
  1554                     CBubblePlace::TPhoneBubblePlace place =
       
  1555                         cnapLength ? CBubblePlace::EBottomCnap :
       
  1556                                      CBubblePlace::EBottom;
       
  1557                     
       
  1558                     SetActivePlace( place,
       
  1559                                     *header );
       
  1560                     }
       
  1561                 }
       
  1562             // Initializing call
       
  1563             else
       
  1564                 {
       
  1565                 if ( cnapLength ) // 3-lines
       
  1566                     {
       
  1567                     SetActivePlace( CBubblePlace::EBottomCnap,
       
  1568                                     *header );
       
  1569                     }
       
  1570                 else
       
  1571                     {
       
  1572                     SetActivePlace( CBubblePlace::EBottom ,
       
  1573                                     *header );
       
  1574                     }    
       
  1575                 }                
       
  1576             break;
       
  1577             }
       
  1578         case 2:
       
  1579             {
       
  1580             // first call: middle held/active
       
  1581             TUint8 index = 0;
       
  1582             FindNextDrawableHeader( index );
       
  1583             TPhoneCallState callState = 
       
  1584                 iActiveHeaders->At( index )->CallState();
       
  1585             TInt cnapLength = iActiveHeaders->At( index )->CNAP().Length();                
       
  1586 
       
  1587             // second call: bottom held/active
       
  1588             TUint8 index2 = TUint8(index + 1);
       
  1589             FindNextDrawableHeader( index2 );
       
  1590             TInt cnapLength2 = iActiveHeaders->At( index2 )->CNAP().Length();
       
  1591             TPhoneCallState callState2 = 
       
  1592                 iActiveHeaders->At( index2 )->CallState();
       
  1593             TPhoneCallState previousState = 
       
  1594                 iActiveHeaders->At( index )->PreviousCallState();                
       
  1595             TPhoneCallState previousState2 = 
       
  1596                 iActiveHeaders->At( index2 )->PreviousCallState();                
       
  1597 
       
  1598             CBubblePlace::TPhoneBubblePlace place;
       
  1599             CBubblePlace::TPhoneBubblePlace place2;
       
  1600             
       
  1601             if ( !InitializingCall() ) // Incall
       
  1602                 {
       
  1603                 if ( ( callState == EActive  ) ||
       
  1604                      ( callState == EDisconnected &&
       
  1605                        previousState == EActive ) )
       
  1606                     {
       
  1607                     // First call shown on bottom
       
  1608                     place = cnapLength ? 
       
  1609                             CBubblePlace::EBottomRightActiveCnapTouch :
       
  1610                             CBubblePlace::EBottomRightActiveTouch;
       
  1611                     place2 = CBubblePlace::EMiddleHeldTouch;    
       
  1612                     }
       
  1613                 else if ( ( callState2 == EActive )  ||
       
  1614                           ( callState2 == EDisconnected &&
       
  1615                             previousState2 == EActive ) )
       
  1616                     {
       
  1617                     // Second call is shown on bottom
       
  1618                     place = CBubblePlace::EMiddleHeldTouch;
       
  1619                     place2 = cnapLength2 ? 
       
  1620                              CBubblePlace::EBottomRightActiveCnapTouch :
       
  1621                              CBubblePlace::EBottomRightActiveTouch;    
       
  1622                     }
       
  1623                 else 
       
  1624                     {
       
  1625                     // The call that was shown in the held call position
       
  1626                     // keeps that position.
       
  1627                     if ( previousState == EOnHold )
       
  1628                         {
       
  1629                         place = CBubblePlace::EMiddleHeldTouch;
       
  1630                         place2 = cnapLength2 ? 
       
  1631                                  CBubblePlace::EBottomRightActiveCnapTouch :
       
  1632                                  CBubblePlace::EBottomRightActiveTouch;    
       
  1633                         }
       
  1634                     else
       
  1635                         {
       
  1636                         place = cnapLength ? 
       
  1637                                 CBubblePlace::EBottomRightActiveCnapTouch :
       
  1638                                 CBubblePlace::EBottomRightActiveTouch;
       
  1639                         place2 = CBubblePlace::EMiddleHeldTouch;    
       
  1640                         }
       
  1641                     }
       
  1642                 }
       
  1643             else // Initializing call
       
  1644                 {
       
  1645                 // the call that is in initializing state is shown in
       
  1646                 // primary position.
       
  1647                 place = CBubblePlace::ETopLeft;
       
  1648                 place2 =  cnapLength2 ? CBubblePlace::EBottomRightCnap :
       
  1649                                         CBubblePlace::EBottomRightActive;
       
  1650                 }                
       
  1651             
       
  1652             // set drawing order
       
  1653             if ( callState2 > callState )
       
  1654                 {
       
  1655                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1656                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1657                 }
       
  1658             else
       
  1659                 {
       
  1660                 SetActivePlace( place2 , *iActiveHeaders->At( index2 ) );
       
  1661                 SetActivePlace( place , *iActiveHeaders->At( index ) );
       
  1662                 }                    
       
  1663             }
       
  1664             break;
       
  1665         case 3:
       
  1666             {
       
  1667             TUint8 index = 0;
       
  1668             FindNextDrawableHeader( index );
       
  1669             
       
  1670             TUint8 index2 = TUint8( index + 1 );
       
  1671             FindNextDrawableHeader( index2 );
       
  1672             
       
  1673             if ( iActiveHeaders->At( index2 )->CallState( ) 
       
  1674                 > iActiveHeaders->At( index )->CallState( ) )
       
  1675                 {
       
  1676                 SetActivePlace( 
       
  1677                     CBubblePlace::ETopRight , *iActiveHeaders->At( index ) );
       
  1678                 SetActivePlace( 
       
  1679                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index2 ) );
       
  1680                 }
       
  1681             else
       
  1682                 {
       
  1683                 SetActivePlace( 
       
  1684                     CBubblePlace::ETopRight , *iActiveHeaders->At( index2 ) );
       
  1685                 SetActivePlace( 
       
  1686                     CBubblePlace::ETopLeft , *iActiveHeaders->At( index ) );
       
  1687                 }
       
  1688             
       
  1689             
       
  1690             index = TUint8( index2 + 1 );
       
  1691             FindNextDrawableHeader( index );
       
  1692             SetActivePlace( 
       
  1693                 CBubblePlace::EBottomRightActive , *iActiveHeaders->At( index ) );
       
  1694             break;
       
  1695             }
       
  1696         default:
       
  1697             Panic( EBMPanicInvalidNumberOfHeaders );
       
  1698             break;
       
  1699         }    
       
  1700     }
       
  1701     
       
  1702 // ---------------------------------------------------------------------------
       
  1703 //  CBubbleManager::SetPhoneMuted
       
  1704 //  
       
  1705 // 
       
  1706 // ---------------------------------------------------------------------------
       
  1707 //
       
  1708 EXPORT_C void CBubbleManager::SetPhoneMuted( const TBool& aIsMuted )
       
  1709     {
       
  1710     __ASSERT_ALWAYS( 
       
  1711         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1712 
       
  1713     if ( aIsMuted && iMutedImage->Bitmap() == NULL )
       
  1714         {
       
  1715         iImageManager->SetBitmapToImage( iMutedImage , 
       
  1716                                      EQgn_indi_call_muted , 
       
  1717                                      EQgn_indi_call_muted_mask );
       
  1718         }
       
  1719 
       
  1720     iIsMuted = aIsMuted;
       
  1721     iMutedImage->MakeVisible( iIsMuted );
       
  1722     if ( !iIsMuted )
       
  1723         {
       
  1724         iMutedImage->DrawDeferred();
       
  1725         }
       
  1726     }
       
  1727 
       
  1728 // ---------------------------------------------------------------------------
       
  1729 //  CBubbleManager::CreateCallHeader
       
  1730 //  
       
  1731 // 
       
  1732 // ---------------------------------------------------------------------------
       
  1733 //
       
  1734 EXPORT_C CBubbleManager::TBubbleId CBubbleManager::CreateCallHeader( )
       
  1735     {
       
  1736     __ASSERT_ALWAYS( 
       
  1737         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1738     
       
  1739     // find unused call header for use.
       
  1740     
       
  1741     TUint8 index = 0;
       
  1742     while ( iCallHeaders->At( index )->IsUsed( ) )
       
  1743         {
       
  1744         index++;
       
  1745         __ASSERT_ALWAYS( index < iCallHeaders->Count( ), 
       
  1746                          Panic( EBMPanicInvalidNumberOfHeaders ) );
       
  1747         }
       
  1748 
       
  1749     CBubbleCallHeader* header = iCallHeaders->At( index );
       
  1750     
       
  1751     header->SetIsUsed( ETrue );
       
  1752     iActiveHeaders->InsertL( iActiveHeaders->Count( ), header );// Can't leave
       
  1753     
       
  1754     return header->BubbleId( );
       
  1755     }
       
  1756     
       
  1757 // ---------------------------------------------------------------------------
       
  1758 //  CBubbleManager::RemoveCallHeader
       
  1759 //  
       
  1760 // 
       
  1761 // ---------------------------------------------------------------------------
       
  1762 //
       
  1763 EXPORT_C void CBubbleManager::RemoveCallHeader( const TBubbleId& aBubbleId )
       
  1764     {
       
  1765     __ASSERT_ALWAYS( 
       
  1766         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1767     
       
  1768     // find header
       
  1769     CBubbleHeader* header = NULL;
       
  1770     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  1771                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  1772     
       
  1773     if ( header->IsConference() )
       
  1774         {
       
  1775         __ASSERT_DEBUG( 
       
  1776             EFalse , Panic( EBMPanicReferredHeaderIsConferenceHeader ) );
       
  1777         return;
       
  1778         }
       
  1779     
       
  1780     if ( header->IsInConference() )
       
  1781         {
       
  1782         __ASSERT_DEBUG( 
       
  1783             EFalse , Panic( EBMPanicReferredCallHeaderIsInConferenceCall ) );
       
  1784         return;
       
  1785         }
       
  1786     
       
  1787     header->Reset();
       
  1788     
       
  1789     
       
  1790     // find the active header from array
       
  1791     TUint8 index = 0;
       
  1792     while ( iActiveHeaders->At( index )->BubbleId( ) != aBubbleId )
       
  1793         {
       
  1794         index++;
       
  1795         }
       
  1796         
       
  1797     iActiveHeaders->Delete( index );
       
  1798     
       
  1799     iCustomManager->RemoveCustomElements( aBubbleId );
       
  1800     
       
  1801     // remove main pane call object
       
  1802     if ( iMainPaneControl && 
       
  1803          iMainPaneControl->BubbleId() == aBubbleId )
       
  1804         {
       
  1805         iMainPaneControl->Reset();
       
  1806         }
       
  1807         
       
  1808     if ( ( iConfigFlags & EBMCallObjectDisplay ) && iCallObjectManager )
       
  1809         {
       
  1810         iCallObjectManager->CancelCallObjectLoading( aBubbleId );            
       
  1811         }
       
  1812     }
       
  1813 
       
  1814 
       
  1815 // ---------------------------------------------------------------------------
       
  1816 //  CBubbleManager::SetState
       
  1817 //  
       
  1818 //  for conf also (active/on hold/ none)
       
  1819 // ---------------------------------------------------------------------------
       
  1820 //
       
  1821 EXPORT_C void CBubbleManager::SetState( const TBubbleId& aBubbleId, 
       
  1822                                         const TPhoneCallState& aState )
       
  1823     {    
       
  1824     
       
  1825     __ASSERT_ALWAYS( 
       
  1826         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1827     
       
  1828     // find header
       
  1829     CBubbleHeader* header = NULL;
       
  1830     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  1831                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  1832     
       
  1833     TPhoneCallState oldstate = header->CallState();
       
  1834     header->SetCallState( aState );
       
  1835 
       
  1836     TUint activeCount = iActiveHeaders->Count();
       
  1837     
       
  1838     //check if we have to change the bubble order
       
  1839     if ( (oldstate == EAlerting || oldstate == EOutgoing 
       
  1840         || oldstate == EWaiting || oldstate == EIncoming ) 
       
  1841         && aState == EActive 
       
  1842         && iActiveHeaders->At( activeCount - 1 )->BubbleId() == aBubbleId)
       
  1843         {
       
  1844         //so we know that the connected call was the last
       
  1845         if ( activeCount > 1 )
       
  1846             {
       
  1847             //we know that there is another call
       
  1848             TPhoneCallState previouscallstate = 
       
  1849                 iActiveHeaders->At( activeCount - 2 )->CallState();
       
  1850             
       
  1851             if ( previouscallstate == EAlerting 
       
  1852                 || previouscallstate == EOutgoing 
       
  1853                 || previouscallstate == EWaiting 
       
  1854                 || previouscallstate == EIncoming 
       
  1855                 || previouscallstate == EAlertToDisconnected )
       
  1856                 {
       
  1857                 //we know that it's too about to get connection
       
  1858                 
       
  1859                 // now we must change the bubble order so active bubble
       
  1860                 // don't stay under rectangular bubble.
       
  1861                 
       
  1862                 CBubbleHeader* tempBubble = 
       
  1863                     iActiveHeaders->At( activeCount-2 );
       
  1864                 iActiveHeaders->At( activeCount-2 ) = 
       
  1865                                     iActiveHeaders->At(activeCount-1 );
       
  1866                 iActiveHeaders->At( activeCount-1 ) = tempBubble;
       
  1867                 }
       
  1868             
       
  1869             }
       
  1870         
       
  1871         }
       
  1872 
       
  1873     // Call collision exception cases:
       
  1874 
       
  1875     // Case: AlertToDisconnected + Waiting
       
  1876     // We have change the drawing order:
       
  1877     if ( activeCount == 2 )
       
  1878         {
       
  1879         if ( iActiveHeaders->At(0)->CallState() == EAlertToDisconnected
       
  1880             && iActiveHeaders->At(1)->CallState() == EWaiting )
       
  1881             {
       
  1882             // now we must change the bubble order so waiting bubble
       
  1883             // don't stay under alerttodisconnected bubble.
       
  1884             CBubbleHeader* tempBubble = iActiveHeaders->At(0);
       
  1885             iActiveHeaders->At(0) = iActiveHeaders->At(1);
       
  1886             iActiveHeaders->At(1) = tempBubble;
       
  1887             }
       
  1888         }
       
  1889     
       
  1890     }
       
  1891 
       
  1892 
       
  1893 // ---------------------------------------------------------------------------
       
  1894 //  CBubbleManager::SetLabel
       
  1895 //  
       
  1896 //  for conf also 
       
  1897 // ---------------------------------------------------------------------------
       
  1898 //
       
  1899 EXPORT_C void CBubbleManager::SetLabel( 
       
  1900     const TBubbleId& aBubbleId, 
       
  1901     const TDesC& aText, 
       
  1902     const TPhoneClippingDirection& aClipDirection)
       
  1903     {
       
  1904     __ASSERT_ALWAYS( 
       
  1905         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1906     
       
  1907     // find header
       
  1908     CBubbleHeader* header = NULL;
       
  1909     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,
       
  1910         Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  1911     
       
  1912     BubbleUtils::AddTextToHeader( *header, 
       
  1913                                   BubbleUtils::EBubbleHeaderLabel , 
       
  1914                                   aText , 
       
  1915                                   KBubbleLabelMaxLength ,
       
  1916                                   aClipDirection ); 
       
  1917     }
       
  1918 
       
  1919 // ---------------------------------------------------------------------------
       
  1920 //  CBubbleManager::SetLabel
       
  1921 //  
       
  1922 //  for conf also 
       
  1923 // ---------------------------------------------------------------------------
       
  1924 //
       
  1925 EXPORT_C void CBubbleManager::SetLabel( 
       
  1926     const TBubbleId& aBubbleId, 
       
  1927     const TDesC& aLongText, 
       
  1928     const TDesC& aShortText, 
       
  1929     const TPhoneClippingDirection& aClipDirection)
       
  1930     {
       
  1931     __ASSERT_ALWAYS( 
       
  1932         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  1933     
       
  1934     // find header
       
  1935     CBubbleHeader* header = NULL;
       
  1936     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  1937         Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  1938     
       
  1939     // set both text to single buffer. text are cut from the end.
       
  1940     TInt shortLength = aShortText.Length();
       
  1941     TInt longLength = aLongText.Length();
       
  1942     TInt textLength = longLength + shortLength + 1;
       
  1943 
       
  1944     TPtr16 textPtr = iLabelBuf->Des();
       
  1945     textPtr.Zero();
       
  1946     if ( textPtr.MaxLength() < textLength )
       
  1947         {        
       
  1948         TRAPD ( err, iLabelBuf = iLabelBuf->ReAllocL( textLength ) );
       
  1949         textPtr.Set( iLabelBuf->Des() );
       
  1950         textPtr.Zero();
       
  1951         if ( longLength > 0 )
       
  1952             {
       
  1953             if ( err != KErrNone )
       
  1954                 {
       
  1955                 longLength = textPtr.MaxLength() - shortLength - 1;
       
  1956                 textPtr.Append( aLongText.Left( longLength ) );
       
  1957                 }
       
  1958             else
       
  1959                 {
       
  1960                 textPtr.Append( aLongText );
       
  1961                 }
       
  1962             }
       
  1963         else
       
  1964             {
       
  1965             textPtr.Append( KNullDesC );
       
  1966             }
       
  1967         }
       
  1968     else
       
  1969         {
       
  1970         if ( longLength > 0 )
       
  1971             {
       
  1972             textPtr.Append( aLongText );
       
  1973             }
       
  1974         else
       
  1975             {
       
  1976             textPtr.Append( KNullDesC );
       
  1977             }
       
  1978         }
       
  1979 
       
  1980     textPtr.Append( KBubbleTextSeparator );
       
  1981 
       
  1982     if ( shortLength > 0 )
       
  1983         {
       
  1984         textPtr.Append( aShortText );
       
  1985         }
       
  1986     else
       
  1987         {
       
  1988         textPtr.Append( KNullDesC );
       
  1989         }
       
  1990 
       
  1991     header->SetText( textPtr , aClipDirection );
       
  1992     }
       
  1993 
       
  1994 
       
  1995 // ---------------------------------------------------------------------------
       
  1996 //  CBubbleManager::SetCLI
       
  1997 //  
       
  1998 //  for conf also 
       
  1999 // ---------------------------------------------------------------------------
       
  2000 //
       
  2001 EXPORT_C void CBubbleManager::SetCLI( 
       
  2002     const TBubbleId& aBubbleId, 
       
  2003     const TDesC& aCLIText, 
       
  2004     const TPhoneClippingDirection& aClipDirection  )
       
  2005     {
       
  2006     __ASSERT_ALWAYS( 
       
  2007         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2008     
       
  2009     // find header
       
  2010     CBubbleHeader* header = NULL;
       
  2011     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2012         Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2013     
       
  2014 
       
  2015     // We have a number
       
  2016     if ( aClipDirection == ELeft )
       
  2017         {
       
  2018         BubbleUtils::AddTextToHeader( *header, 
       
  2019                                   BubbleUtils::EBubbleHeaderCLI , 
       
  2020                                   NumberGroup( aCLIText ), 
       
  2021                                   KBubbleLabelMaxLength ,
       
  2022                                   aClipDirection ); 
       
  2023         }
       
  2024     else
       
  2025         {
       
  2026         BubbleUtils::AddTextToHeader( *header, 
       
  2027                                   BubbleUtils::EBubbleHeaderCLI , 
       
  2028                                   aCLIText , 
       
  2029                                   KBubbleLabelMaxLength ,
       
  2030                                   aClipDirection ); 
       
  2031         }
       
  2032     }
       
  2033 
       
  2034 // ---------------------------------------------------------------------------
       
  2035 //  CBubbleManager::UpdateCLI
       
  2036 //  
       
  2037 //  for conf also 
       
  2038 // ---------------------------------------------------------------------------
       
  2039 //
       
  2040 EXPORT_C void CBubbleManager::UpdateCLI( 
       
  2041     const TBubbleId& aBubbleId, 
       
  2042     const TDesC& aCLIText, 
       
  2043     const TPhoneClippingDirection& aClipDirection )
       
  2044     {
       
  2045     // find header
       
  2046     CBubbleHeader* header = NULL;
       
  2047     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2048                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2049     
       
  2050     BubbleUtils::AddTextToHeader( *header, 
       
  2051                                   BubbleUtils::EBubbleHeaderCLI , 
       
  2052                                   aCLIText , 
       
  2053                                   KBubbleLabelMaxLength ,
       
  2054                                   aClipDirection );
       
  2055     
       
  2056     
       
  2057     // Tell active bubbles to update their CLI if it's visible.
       
  2058     CBubbleOutlook* outlook = NULL;
       
  2059     TInt placeCount = iActivePlaces->Count();
       
  2060     for ( TUint8 index = 0 ; index < placeCount ; index++ )
       
  2061         {
       
  2062         outlook = &iActivePlaces->At( index )->GetBubbleOutlook( );
       
  2063         outlook->DrawCLINow();
       
  2064         }
       
  2065     
       
  2066     }
       
  2067 
       
  2068 // ---------------------------------------------------------------------------
       
  2069 //  CBubbleManager::SetCallTime
       
  2070 //  
       
  2071 //  for conf also 
       
  2072 // ---------------------------------------------------------------------------
       
  2073 //
       
  2074 EXPORT_C void CBubbleManager::SetCallTime( const TBubbleId& aBubbleId, 
       
  2075                                            const TDesC& aCallTime )
       
  2076     {
       
  2077     __ASSERT_ALWAYS( 
       
  2078         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2079     
       
  2080     // find header
       
  2081     CBubbleHeader* header = NULL;
       
  2082     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2083         Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2084     
       
  2085 
       
  2086     BubbleUtils::AddTextToHeader( *header, 
       
  2087                                   BubbleUtils::EBubbleHeaderTimerCost , 
       
  2088                                   aCallTime , 
       
  2089                                   KBubbleLabelMaxLength ,
       
  2090                                   CBubbleManager::ERight );
       
  2091 
       
  2092     }
       
  2093 
       
  2094 // ---------------------------------------------------------------------------
       
  2095 //  CBubbleManager::UpdateCallTime
       
  2096 //  
       
  2097 //  for conf also 
       
  2098 // ---------------------------------------------------------------------------
       
  2099 //
       
  2100 EXPORT_C void CBubbleManager::UpdateCallTime( const TBubbleId& aBubbleId, 
       
  2101                                               const TDesC& aCallTime )
       
  2102     {
       
  2103     // find header
       
  2104     CBubbleHeader* header = NULL;
       
  2105     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2106                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2107     
       
  2108     BubbleUtils::AddTextToHeader( *header, 
       
  2109                                   BubbleUtils::EBubbleHeaderTimerCost , 
       
  2110                                   aCallTime , 
       
  2111                                   KBubbleLabelMaxLength ,
       
  2112                                   CBubbleManager::ERight );
       
  2113     
       
  2114     // Tell active bubbles to update their timer/cost text if it's visible.
       
  2115     CBubbleOutlook* outlook = NULL;
       
  2116     TInt placeCount = iActivePlaces->Count();
       
  2117     for ( TUint8 index = 0 ; index < placeCount ; index++ )
       
  2118         {
       
  2119         outlook = &iActivePlaces->At( index )->GetBubbleOutlook( );
       
  2120         outlook->DrawTimerCostNow();
       
  2121         }
       
  2122     
       
  2123     }
       
  2124 
       
  2125 // ---------------------------------------------------------------------------
       
  2126 //  CBubbleManager::UpdateCallHeaderText
       
  2127 //  
       
  2128 //  for conf also 
       
  2129 // ---------------------------------------------------------------------------
       
  2130 //
       
  2131 EXPORT_C void CBubbleManager::UpdateCallHeaderText( const TBubbleId& aBubbleId, 
       
  2132                                             const TDesC& aLongText, 
       
  2133                                             const TDesC& aShortText, 
       
  2134                                             const TPhoneClippingDirection& aClipDirection )
       
  2135     {
       
  2136     // find header
       
  2137     CBubbleHeader* header = NULL;
       
  2138     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2139                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2140     
       
  2141     iIsReadyToDraw++;
       
  2142     SetLabel( aBubbleId, aLongText, aShortText, aClipDirection);
       
  2143     iIsReadyToDraw--;
       
  2144 
       
  2145     // Tell active bubbles to update call header text if it's visible.
       
  2146     CBubbleOutlook* outlook = NULL;
       
  2147     TInt placeCount = iActivePlaces->Count();
       
  2148     for ( TUint8 index = 0 ; index < placeCount ; index++ )
       
  2149         {
       
  2150         outlook = &iActivePlaces->At( index )->GetBubbleOutlook( );        
       
  2151         outlook->DrawCallHeaderText();
       
  2152         }
       
  2153     
       
  2154     }
       
  2155 
       
  2156 // ---------------------------------------------------------------------------
       
  2157 //  CBubbleManager::SetThumbnail
       
  2158 //  
       
  2159 // 
       
  2160 // ---------------------------------------------------------------------------
       
  2161 //
       
  2162 EXPORT_C void CBubbleManager::SetThumbnail( const TBubbleId& aBubbleId, 
       
  2163                                             CFbsBitmap* aTnBitmap, 
       
  2164                                             CFbsBitmap* aTnBitmapMask,
       
  2165                                             TBool aDataOwnershipTransferred )
       
  2166     {
       
  2167     if ( !(iConfigFlags & EBMCallObjectDisplay) )
       
  2168         {
       
  2169         __ASSERT_ALWAYS( 
       
  2170             iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2171         }
       
  2172     
       
  2173     // find header
       
  2174     CBubbleHeader* header = NULL;
       
  2175     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2176                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2177     
       
  2178     header->SetTnBitmap( aTnBitmap );
       
  2179     header->SetTnBitmapMask( aTnBitmapMask );
       
  2180     header->SetTnDataOwnership( aDataOwnershipTransferred );
       
  2181     }
       
  2182 
       
  2183 // ---------------------------------------------------------------------------
       
  2184 //  CBubbleManager::SetCallFlags
       
  2185 //  
       
  2186 //  for conf also 
       
  2187 // ---------------------------------------------------------------------------
       
  2188 //
       
  2189 EXPORT_C void CBubbleManager::SetCallFlags( const TBubbleId& aBubbleId, 
       
  2190                                             const TUint32& aFlags ) 
       
  2191     {
       
  2192     __ASSERT_ALWAYS( 
       
  2193         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2194     
       
  2195     // find header
       
  2196     CBubbleHeader* header = NULL;
       
  2197     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2198                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2199     
       
  2200     header->SetCallFlags( aFlags );
       
  2201     }
       
  2202 
       
  2203 // ---------------------------------------------------------------------------
       
  2204 //  CBubbleManager::SetCallFlag
       
  2205 //  
       
  2206 //  for conf also 
       
  2207 // ---------------------------------------------------------------------------
       
  2208 //
       
  2209 EXPORT_C void CBubbleManager::SetCallFlag( const TBubbleId& aBubbleId, 
       
  2210                                            const TPhoneCallTypeFlags& aFlag, 
       
  2211                                            const TBool& aSet )
       
  2212     {
       
  2213     __ASSERT_ALWAYS( 
       
  2214         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2215     
       
  2216     // find header
       
  2217     CBubbleHeader* header = NULL;
       
  2218     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2219                                        Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2220     
       
  2221     if ( aSet )
       
  2222         {
       
  2223         header->SetCallFlag( aFlag );
       
  2224         }
       
  2225     else 
       
  2226         {
       
  2227         header->RemoveCallFlag( aFlag );
       
  2228         } 
       
  2229     }
       
  2230 
       
  2231 // ---------------------------------------------------------------------------
       
  2232 //  CBubbleManager::SetNumberType
       
  2233 //  
       
  2234 //  
       
  2235 // ---------------------------------------------------------------------------
       
  2236 //
       
  2237 EXPORT_C void CBubbleManager::SetNumberType( const TBubbleId& aBubbleId, 
       
  2238                                              const TPhoneNumberType& aNumType )
       
  2239     {
       
  2240     __ASSERT_ALWAYS( 
       
  2241         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2242     
       
  2243     // find header
       
  2244     CBubbleHeader* header = NULL;
       
  2245     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2246                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2247     
       
  2248     header->SetNumberType( aNumType );
       
  2249     }
       
  2250 
       
  2251 
       
  2252 // ---------------------------------------------------------------------------
       
  2253 //  CBubbleManager::SetPbkNumberType
       
  2254 //  
       
  2255 //  
       
  2256 // ---------------------------------------------------------------------------
       
  2257 //
       
  2258 EXPORT_C void CBubbleManager::SetPbkNumberType( const TBubbleId& aBubbleId, 
       
  2259                                                 const TInt aNumType )
       
  2260     {
       
  2261     TPhoneNumberType numType = ENotSet;
       
  2262     switch ( aNumType )
       
  2263         {  
       
  2264         case EPbkFieldIdPhoneNumberMobile:
       
  2265             numType = EMobile;
       
  2266             break;
       
  2267         case EPbkFieldIdPhoneNumberStandard:
       
  2268         case EPbkFieldIdPhoneNumberHome:
       
  2269         case EPbkFieldIdPhoneNumberWork:
       
  2270             numType = EPhone;
       
  2271             break;
       
  2272         case EPbkFieldIdFaxNumber:
       
  2273             numType = EFaxNumber;
       
  2274             break;
       
  2275         case EPbkFieldIdPagerNumber:
       
  2276             numType = EPager;
       
  2277             break;
       
  2278         case EPbkFieldIdCarNumber:
       
  2279             numType = ECar;
       
  2280             break;            
       
  2281         case EPbkFieldIdAssistantNumber:
       
  2282             numType = EAssistant;
       
  2283             break;            
       
  2284         case EPbkFieldIdNone:       // flow through
       
  2285         default:
       
  2286             numType = ENotSet;
       
  2287             break;
       
  2288         }
       
  2289     SetNumberType( aBubbleId , numType );
       
  2290     }
       
  2291 
       
  2292 // ---------------------------------------------------------------------------
       
  2293 //  CBubbleManager::SetPhCntNumberType
       
  2294 //  
       
  2295 //  
       
  2296 // ---------------------------------------------------------------------------
       
  2297 //
       
  2298 EXPORT_C void CBubbleManager::SetPhCntNumberType( 
       
  2299     const TBubbleId& aBubbleId,
       
  2300     const MPhCntMatch::TNumberType aNumberType )    
       
  2301     {
       
  2302 #ifdef RD_VIRTUAL_PHONEBOOK
       
  2303     TPhoneNumberType numType = ENotSet;
       
  2304     switch( aNumberType ) 
       
  2305         {
       
  2306         case MPhCntMatch::EMobileNumber:
       
  2307             numType = EMobile;
       
  2308             break;
       
  2309 
       
  2310         case MPhCntMatch::EVoipNumber:            
       
  2311         case MPhCntMatch::EStandardNumber:
       
  2312             numType = EPhone;
       
  2313             break;
       
  2314             
       
  2315         case MPhCntMatch::EFaxNumber:
       
  2316             numType = EFaxNumber;
       
  2317             break;
       
  2318             
       
  2319         case MPhCntMatch::EPagerNumber:
       
  2320             numType = EPager;
       
  2321             break;
       
  2322         case MPhCntMatch::EAssistantNumber:
       
  2323         	numType = EAssistant;
       
  2324         	break;
       
  2325         case MPhCntMatch::ECarNumber:
       
  2326         	numType = ECar;
       
  2327         	break;
       
  2328         default:
       
  2329             break;
       
  2330         }
       
  2331     SetNumberType( aBubbleId, numType );
       
  2332 #else
       
  2333     (void) aBubbleId;
       
  2334     (void) aNumberType;	    
       
  2335 #endif // RD_VIRTUAL_PHONEBOOK
       
  2336     }
       
  2337 
       
  2338 // ---------------------------------------------------------------------------
       
  2339 //  CBubbleManager::CreateConference
       
  2340 //  
       
  2341 //  For conference calls only
       
  2342 // ---------------------------------------------------------------------------
       
  2343 //
       
  2344 EXPORT_C CBubbleManager::TBubbleId CBubbleManager::CreateConference( 
       
  2345                                                 const TBubbleId& aBubble1, 
       
  2346                                                 const TBubbleId& aBubble2 )
       
  2347     {
       
  2348     __ASSERT_ALWAYS( 
       
  2349         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2350     __ASSERT_ALWAYS( iActiveHeaders->Count() < KBubblePlaceMaxVisible, 
       
  2351                      Panic( EBMPanicInvalidNumberOfHeaders ) );
       
  2352     __ASSERT_DEBUG( !iConfHeader->IsUsed() , Panic( EBMPanicConferenceIsUsed ) );
       
  2353     
       
  2354     iConfHeader->SetIsUsed( ETrue );
       
  2355     
       
  2356     AddRowToConference( aBubble1 );
       
  2357     AddRowToConference( aBubble2 );
       
  2358     
       
  2359     // Put conference header to first so it will be drawn always on top.
       
  2360     iActiveHeaders->InsertL( 0 , iConfHeader ); //Can't leave
       
  2361     
       
  2362     return iConfHeader->BubbleId( );    
       
  2363     }
       
  2364 
       
  2365 // ---------------------------------------------------------------------------
       
  2366 //  CBubbleManager::RemoveConference
       
  2367 //  
       
  2368 //  For conference calls only
       
  2369 // ---------------------------------------------------------------------------
       
  2370 //
       
  2371 EXPORT_C void CBubbleManager::RemoveConference( )
       
  2372     {
       
  2373     __ASSERT_ALWAYS( 
       
  2374         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2375     __ASSERT_ALWAYS( iConfHeader->IsUsed( ), Panic( EBMPanicConferenceNotUsed ) );
       
  2376     
       
  2377     iConfHeader->Reset();
       
  2378     
       
  2379     
       
  2380     // find the active element
       
  2381     TUint8 index = 0;
       
  2382     __ASSERT_ALWAYS( 
       
  2383         iActiveHeaders->Count( ) > 0, Panic( EBMPanicInvalidNumberOfHeaders ) );
       
  2384     while ( iActiveHeaders->At( index )->BubbleId( ) != KBubbleConferenceId )
       
  2385         {
       
  2386         index++;
       
  2387         __ASSERT_ALWAYS( index != iActiveHeaders->Count( ), 
       
  2388             Panic( EBMPanicInvalidNumberOfHeaders ) );
       
  2389         }
       
  2390     
       
  2391     iActiveHeaders->Delete( index );
       
  2392     }
       
  2393 
       
  2394 // ---------------------------------------------------------------------------
       
  2395 //  CBubbleManager::AddRowToConference
       
  2396 //  
       
  2397 //  For conference calls only
       
  2398 // ---------------------------------------------------------------------------
       
  2399 //
       
  2400 EXPORT_C void CBubbleManager::AddRowToConference( const TBubbleId& aBubbleId )
       
  2401     {
       
  2402     __ASSERT_ALWAYS( 
       
  2403         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2404     
       
  2405     // find header
       
  2406     CBubbleHeader* header = NULL;
       
  2407     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2408                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2409     
       
  2410     __ASSERT_ALWAYS( header->IsUsed(), Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2411     __ASSERT_ALWAYS( !header->IsConference(), 
       
  2412                      Panic( EBMPanicReferredHeaderIsConferenceHeader ) );
       
  2413     __ASSERT_ALWAYS( !header->IsInConference(), 
       
  2414                      Panic( EBMPanicReferredCallHeaderIsInConferenceCall ) );
       
  2415     
       
  2416     iConfHeader->AddRow( static_cast<CBubbleCallHeader&>( *header ) ); // type cast downwards
       
  2417     }
       
  2418 
       
  2419 // ---------------------------------------------------------------------------
       
  2420 //  CBubbleManager::RemoveRowFromConference
       
  2421 //  
       
  2422 //  For conference calls only
       
  2423 // ---------------------------------------------------------------------------
       
  2424 //
       
  2425 EXPORT_C void CBubbleManager::RemoveRowFromConference( const TBubbleId& aBubbleId )
       
  2426     {
       
  2427     __ASSERT_ALWAYS( 
       
  2428         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2429     
       
  2430     iConfHeader->RemoveRow( aBubbleId );
       
  2431     }
       
  2432 
       
  2433 // ---------------------------------------------------------------------------
       
  2434 //  CBubbleManager::ConferenceRowCount
       
  2435 //  
       
  2436 //  For conference calls only
       
  2437 // ---------------------------------------------------------------------------
       
  2438 //
       
  2439 EXPORT_C TUint8 CBubbleManager::ConferenceRowCount( ) const
       
  2440     {
       
  2441     return iConfHeader->RowCount();
       
  2442     }
       
  2443 
       
  2444 // ---------------------------------------------------------------------------
       
  2445 //  CBubbleManager::SetExpandedConferenceCallHeader
       
  2446 //  
       
  2447 //  For conference calls only
       
  2448 // ---------------------------------------------------------------------------
       
  2449 //
       
  2450 EXPORT_C void CBubbleManager::SetExpandedConferenceCallHeader( 
       
  2451     const TBool& aIsExpanded )
       
  2452     {
       
  2453     iConfHeader->SetIsExpanded( aIsExpanded );
       
  2454     }
       
  2455 
       
  2456 // ---------------------------------------------------------------------------
       
  2457 //  CBubbleManager::IsConferenceExpanded
       
  2458 //  
       
  2459 //  For conference calls only
       
  2460 // ---------------------------------------------------------------------------
       
  2461 //
       
  2462 EXPORT_C TBool CBubbleManager::IsConferenceExpanded( ) const
       
  2463     {
       
  2464     return iConfHeader->IsExpanded();
       
  2465     }
       
  2466 
       
  2467 // ---------------------------------------------------------------------------
       
  2468 //  CBubbleManager::SetSelectionInConference
       
  2469 //  
       
  2470 //  For conference calls only
       
  2471 // ---------------------------------------------------------------------------
       
  2472 //
       
  2473 EXPORT_C void CBubbleManager::SetSelectionInConference( 
       
  2474     const TRowNumber& aRowNumber )
       
  2475     {
       
  2476     CBubbleManager::TRowNumber oldrow = iConfHeader->Highlight();
       
  2477     iConfHeader->SetHighlight( aRowNumber );
       
  2478     CBubbleManager::TRowNumber newrow = iConfHeader->Highlight();
       
  2479     
       
  2480     UpdateConferenceRows( oldrow , newrow );
       
  2481     }
       
  2482 
       
  2483 // ---------------------------------------------------------------------------
       
  2484 //  CBubbleManager::SetSelectionIdInConference
       
  2485 //  
       
  2486 //  For conference calls only
       
  2487 // ---------------------------------------------------------------------------
       
  2488 //
       
  2489 EXPORT_C void CBubbleManager::SetSelectionIdInConference( 
       
  2490     const TBubbleId& aBubbleId )
       
  2491     {
       
  2492     CBubbleManager::TRowNumber oldrow = iConfHeader->Highlight();
       
  2493     iConfHeader->SetHighlightId( aBubbleId );
       
  2494     CBubbleManager::TRowNumber newrow = iConfHeader->Highlight();
       
  2495     
       
  2496     UpdateConferenceRows( oldrow , newrow );
       
  2497     }
       
  2498 // ---------------------------------------------------------------------------
       
  2499 //  CBubbleManager::SelectionInConference
       
  2500 //  
       
  2501 //  For conference calls only
       
  2502 // ---------------------------------------------------------------------------
       
  2503 //
       
  2504 EXPORT_C CBubbleManager::TRowNumber 
       
  2505     CBubbleManager::SelectionInConference() const
       
  2506     {
       
  2507     return iConfHeader->Highlight();
       
  2508     }
       
  2509 
       
  2510 // ---------------------------------------------------------------------------
       
  2511 //  CBubbleManager::SelectionIdInConference
       
  2512 //  
       
  2513 //  For conference calls only
       
  2514 // ---------------------------------------------------------------------------
       
  2515 //
       
  2516 EXPORT_C CBubbleManager::TBubbleId 
       
  2517     CBubbleManager::SelectionIdInConference() const
       
  2518     {
       
  2519     return iConfHeader->HighlightId();
       
  2520     }
       
  2521 
       
  2522 // ---------------------------------------------------------------------------
       
  2523 //  CBubbleManager::MoveHighlightOneUpInConference
       
  2524 //  
       
  2525 //  For conference calls only
       
  2526 // ---------------------------------------------------------------------------
       
  2527 //
       
  2528 EXPORT_C void CBubbleManager::MoveHighlightOneUpInConference()
       
  2529     {
       
  2530     CBubbleManager::TRowNumber oldrow = iConfHeader->Highlight();
       
  2531     iConfHeader->MoveHighlightOneUp();
       
  2532     CBubbleManager::TRowNumber newrow = iConfHeader->Highlight();
       
  2533     
       
  2534     UpdateConferenceRows( oldrow , newrow );
       
  2535     }
       
  2536 
       
  2537 // ---------------------------------------------------------------------------
       
  2538 //  CBubbleManager::MoveHighlightOneDownInConference
       
  2539 //  
       
  2540 //  For conference calls only
       
  2541 // ---------------------------------------------------------------------------
       
  2542 //
       
  2543 EXPORT_C void CBubbleManager::MoveHighlightOneDownInConference()
       
  2544     {
       
  2545     CBubbleManager::TRowNumber oldrow = iConfHeader->Highlight();
       
  2546     iConfHeader->MoveHighlightOneDown();
       
  2547     CBubbleManager::TRowNumber newrow = iConfHeader->Highlight();
       
  2548     
       
  2549     UpdateConferenceRows( oldrow , newrow );
       
  2550     }
       
  2551 
       
  2552 
       
  2553 
       
  2554 // ---------------------------------------------------------------------------
       
  2555 //  CBubbleManager::CreateNumberEntry
       
  2556 //  
       
  2557 //  For number entry
       
  2558 // ---------------------------------------------------------------------------
       
  2559 //
       
  2560 EXPORT_C void CBubbleManager::CreateNumberEntry()
       
  2561     {
       
  2562     __ASSERT_ALWAYS( 
       
  2563         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2564     __ASSERT_ALWAYS( !iNumberEntry->IsUsed(), Panic( EBMPanicNumberEntryInUse ) );
       
  2565 
       
  2566 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
  2567     if ( !ShownHeaderCount() ) // Only effects in number entry
       
  2568         {
       
  2569         // Capture transition begin state
       
  2570         GfxTransEffect::Begin( iNumberEntry, KGfxControlAppearAction );
       
  2571         // Set reminder that Begin has been called.
       
  2572         CAknTransitionUtils::SetData( (TInt) this, (TAny*) 1 );
       
  2573         }
       
  2574 #endif //NOT_RD_UI_TRANSITION_EFFECTS_PHASE2
       
  2575     
       
  2576     iNumberEntry->SetIsUsed( ETrue );
       
  2577     iNumberEntry->MakeVisible( ETrue );
       
  2578     }
       
  2579 
       
  2580 // ---------------------------------------------------------------------------
       
  2581 //  CBubbleManager::GetNumberEntry
       
  2582 //  
       
  2583 //  For number entry
       
  2584 // ---------------------------------------------------------------------------
       
  2585 //
       
  2586 EXPORT_C CCoeControl* CBubbleManager::GetNumberEntry( ) const
       
  2587     {
       
  2588     return iNumberEntry->GetEditor();
       
  2589     }
       
  2590 
       
  2591 // ---------------------------------------------------------------------------
       
  2592 //  CBubbleManager::IsNumberEntryUsed
       
  2593 //  
       
  2594 //  For number entry
       
  2595 // ---------------------------------------------------------------------------
       
  2596 //
       
  2597 EXPORT_C TBool CBubbleManager::IsNumberEntryUsed( ) const
       
  2598     {
       
  2599     return iNumberEntry->IsUsed();
       
  2600     }
       
  2601 
       
  2602 // ---------------------------------------------------------------------------
       
  2603 //  CBubbleManager::SetNumberEntryVisible
       
  2604 //  
       
  2605 //  For number entry
       
  2606 // ---------------------------------------------------------------------------
       
  2607 //
       
  2608 EXPORT_C void CBubbleManager::SetNumberEntryVisible( const TBool& aVisibility )
       
  2609     {
       
  2610     __ASSERT_ALWAYS( 
       
  2611         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2612 
       
  2613     iNumberEntry->SetPlace( CBubbleOutlookNumberEntry::ENENone );
       
  2614     iNumberEntry->MakeVisible( aVisibility );
       
  2615     CCoeControl* editor = iNumberEntry->GetEditor();
       
  2616     if ( !aVisibility )
       
  2617         {
       
  2618         editor->SetFocus( EFalse );
       
  2619         }
       
  2620     else
       
  2621         {
       
  2622 // Don't set focus now ( wait until the screen is redirected )
       
  2623 // We don't want the cursor to be shown until the transition is finished
       
  2624 #ifndef RD_UI_TRANSITION_EFFECTS_PHASE2
       
  2625         editor->SetFocus( ETrue );
       
  2626 #endif
       
  2627         }
       
  2628     }
       
  2629 
       
  2630 // ---------------------------------------------------------------------------
       
  2631 //  CBubbleManager::SetTextToNumberEntry
       
  2632 //  
       
  2633 //  For number entry
       
  2634 // ---------------------------------------------------------------------------
       
  2635 //
       
  2636 EXPORT_C void CBubbleManager::SetTextToNumberEntry( const TDesC& aDesC )
       
  2637     {
       
  2638     iNumberEntry->SetText( aDesC );
       
  2639     }
       
  2640 
       
  2641 // ---------------------------------------------------------------------------
       
  2642 //  CBubbleManager::GetTextFromNumberEntry
       
  2643 //  
       
  2644 //  For number entry
       
  2645 // ---------------------------------------------------------------------------
       
  2646 //
       
  2647 EXPORT_C void CBubbleManager::GetTextFromNumberEntry( TDes& aDesC )
       
  2648     {
       
  2649     iNumberEntry->GetText( aDesC );
       
  2650     }
       
  2651 
       
  2652 // ---------------------------------------------------------------------------
       
  2653 //  CBubbleManager::RemoveNumberEntry
       
  2654 //  
       
  2655 //  For number entry
       
  2656 // ---------------------------------------------------------------------------
       
  2657 //
       
  2658 EXPORT_C void CBubbleManager::RemoveNumberEntry( )
       
  2659     {
       
  2660     __ASSERT_ALWAYS( 
       
  2661         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2662     __ASSERT_ALWAYS( 
       
  2663         iNumberEntry->IsUsed(), Panic( EBMPanicNumberEntryNotInUse ) );
       
  2664     
       
  2665 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
       
  2666     if ( !ShownHeaderCount() ) // Only effects in number entry
       
  2667         {
       
  2668         // Capture transition begin state
       
  2669         GfxTransEffect::Begin( iNumberEntry, KGfxControlDisappearAction );
       
  2670         // Set reminder that Begin has been called.
       
  2671         CAknTransitionUtils::SetData( (TInt) this, (TAny*) 1 );
       
  2672         }
       
  2673 #endif
       
  2674 
       
  2675     iNumberEntry->Reset();
       
  2676     iNumberEntry->MakeVisible( EFalse );
       
  2677     }
       
  2678 
       
  2679 
       
  2680 // ---------------------------------------------------------------------------
       
  2681 //  CBubbleManager::FindHeader
       
  2682 //  
       
  2683 // 
       
  2684 // ---------------------------------------------------------------------------
       
  2685 //
       
  2686 TBool CBubbleManager::FindHeader( 
       
  2687     const TBubbleId& aBubbleID, 
       
  2688     CBubbleHeader*& aHeader ) const
       
  2689     {
       
  2690     TUint count( TUint8( iCallHeaders->Count() ) );
       
  2691     CBubbleHeader* tempHeader = NULL;
       
  2692     for ( TUint8 i = 0 ; i < count ; i++ )
       
  2693         {
       
  2694         tempHeader = iCallHeaders->At( i );
       
  2695         if ( aBubbleID == tempHeader->BubbleId() )
       
  2696             {
       
  2697             aHeader = tempHeader;
       
  2698             return ETrue;
       
  2699             }
       
  2700         }
       
  2701     aHeader = NULL;
       
  2702     return EFalse;
       
  2703     }
       
  2704 
       
  2705 // ---------------------------------------------------------------------------
       
  2706 //  CBubbleManager::FindActiveHeader
       
  2707 //  
       
  2708 // 
       
  2709 // ---------------------------------------------------------------------------
       
  2710 //
       
  2711 TBool CBubbleManager::FindActiveHeader( 
       
  2712     const TBubbleId& aBubbleID, 
       
  2713     CBubbleHeader*& aHeader ) const
       
  2714     {
       
  2715     TUint count( TUint8( iActiveHeaders->Count() ) );
       
  2716     CBubbleHeader* tempHeader = NULL;
       
  2717     for ( TUint8 i = 0 ; i < count ; i++ )
       
  2718         {
       
  2719         tempHeader = iActiveHeaders->At( i );
       
  2720         if ( aBubbleID == tempHeader->BubbleId() )
       
  2721             {
       
  2722             aHeader = tempHeader;
       
  2723             return ETrue;
       
  2724             }
       
  2725         }
       
  2726     aHeader = NULL;
       
  2727     return EFalse;
       
  2728     }
       
  2729 
       
  2730 // ---------------------------------------------------------------------------
       
  2731 //  CBubbleManager::UpdateConferenceRows
       
  2732 //  
       
  2733 // 
       
  2734 // ---------------------------------------------------------------------------
       
  2735 //
       
  2736 void CBubbleManager::UpdateConferenceRows( CBubbleManager::TRowNumber aRow1, 
       
  2737                                           CBubbleManager::TRowNumber aRow2 )
       
  2738     {
       
  2739     // if the rows are the same or conf is not expanded - nothing to do.
       
  2740     if ( aRow1 == aRow2 || !iConfHeader->IsExpanded() )
       
  2741         {
       
  2742         return;
       
  2743         }
       
  2744     
       
  2745     // if we are surrounded by start-/endchanges, we don't have to
       
  2746     // worry about drawing.
       
  2747     if ( iIsReadyToDraw > 0 )
       
  2748         {
       
  2749         return;
       
  2750         }
       
  2751     
       
  2752     // find current control:
       
  2753     
       
  2754     // There should be only one active place: the expanded conference place
       
  2755     if ( iActivePlaces->Count() != 1 )
       
  2756         {
       
  2757         __ASSERT_DEBUG( EFalse, User::Invariant() );
       
  2758         return;
       
  2759         }
       
  2760     
       
  2761     CBubbleOutlookConference* control = 
       
  2762         static_cast< CBubbleOutlookConference* >
       
  2763             ( &iActivePlaces->At(0)->GetBubbleOutlook() );
       
  2764     
       
  2765     // make sure it's what we want
       
  2766     if ( control == NULL )
       
  2767         {
       
  2768         __ASSERT_DEBUG( EFalse, User::Invariant() );
       
  2769         return;
       
  2770         }
       
  2771     
       
  2772     
       
  2773     // Draw row1 first:
       
  2774     control->DrawRowNow( aRow1 );
       
  2775     
       
  2776     // Then second row:
       
  2777     control->DrawRowNow( aRow2 );
       
  2778     }
       
  2779 
       
  2780 
       
  2781 // ---------------------------------------------------------------------------
       
  2782 //  CBubbleManager::FocusChanged
       
  2783 //  
       
  2784 // 
       
  2785 // ---------------------------------------------------------------------------
       
  2786 //
       
  2787 void CBubbleManager::FocusChanged( TDrawNow aDrawNow )
       
  2788     {
       
  2789     if ( iNumberEntry->IsUsed() && iNumberEntry->IsVisible() )
       
  2790         {
       
  2791         iNumberEntry->SetFocus( IsFocused(), aDrawNow );
       
  2792         }
       
  2793     }
       
  2794 
       
  2795 // ---------------------------------------------------------------------------
       
  2796 //  CBubbleManager::ImageManager
       
  2797 //  
       
  2798 // 
       
  2799 // ---------------------------------------------------------------------------
       
  2800 //
       
  2801 CBubbleImageManager& CBubbleManager::ImageManager()
       
  2802     {
       
  2803     return *iImageManager;
       
  2804     }
       
  2805 
       
  2806 // ---------------------------------------------------------------------------
       
  2807 //  CBubbleManager::ResourceManager
       
  2808 //  
       
  2809 // 
       
  2810 // ---------------------------------------------------------------------------
       
  2811 //
       
  2812 CBubbleResourceManager& CBubbleManager::ResourceManager()
       
  2813     {
       
  2814     return *iResourceManager;
       
  2815     }
       
  2816 
       
  2817 // ---------------------------------------------------------------------------
       
  2818 //  CBubbleManager::CustomManager
       
  2819 //  
       
  2820 // 
       
  2821 // ---------------------------------------------------------------------------
       
  2822 //
       
  2823 CBubbleCustomManager& CBubbleManager::CustomManager()
       
  2824     {
       
  2825     return *iCustomManager;
       
  2826     }
       
  2827     
       
  2828 // ---------------------------------------------------------------------------
       
  2829 //  CBubbleManager::HandleResourceChange
       
  2830 //  
       
  2831 // 
       
  2832 // ---------------------------------------------------------------------------
       
  2833 //
       
  2834 void CBubbleManager::HandleResourceChange(TInt aType)
       
  2835     {
       
  2836     if ( aType ==  KEikMessageUnfadeWindows )
       
  2837         {
       
  2838         if ( iIsReadyToDraw == 0 )
       
  2839             {
       
  2840             if ( iActivePlaces->Count() > 0 )
       
  2841                 {
       
  2842                 iParentControl->DrawNow();
       
  2843                 }
       
  2844             }
       
  2845         }
       
  2846 
       
  2847     if ( aType == KAknsMessageSkinChange || 
       
  2848          aType == KEikDynamicLayoutVariantSwitch )
       
  2849         {
       
  2850         StartChanges();
       
  2851         
       
  2852         if ( aType == KAknsMessageSkinChange )
       
  2853             {
       
  2854             // Remove muted image. It will be reloaded when 
       
  2855             // needed for the next time.
       
  2856             iMutedImage->SetPicture( NULL , NULL );
       
  2857             iMutedImage->MakeVisible( EFalse );
       
  2858 
       
  2859             // Release all bitmaps from the animations
       
  2860             for ( TInt i = 0; i < iBubblePlaces->Count() ; i++ )
       
  2861                 {
       
  2862                 iBubblePlaces->At( i )->GetBubbleOutlook().ReleaseBitmaps();
       
  2863                 }
       
  2864 
       
  2865             // Number entry
       
  2866             iNumberEntry->ReleaseBitmaps();
       
  2867 
       
  2868             // Clear all the skinned images from own cache
       
  2869             iImageManager->ClearSkinsCache();
       
  2870 
       
  2871             // Set the image back if it was there...
       
  2872             SetPhoneMuted( iIsMuted );
       
  2873 
       
  2874             // Recreate all bitmaps from the animations
       
  2875             for ( TInt a = 0; a < iBubblePlaces->Count() ; a++ )
       
  2876                 {
       
  2877                 iBubblePlaces->At( a )->GetBubbleOutlook().RebuildBitmaps();
       
  2878                 }
       
  2879             
       
  2880             // Number entry
       
  2881             iNumberEntry->RebuildBitmaps();
       
  2882             
       
  2883             // Touch pane
       
  2884             if ( iTouchPane )
       
  2885                 {
       
  2886                 iTouchPane->HandleResourceChange( aType );                    
       
  2887                 }
       
  2888             
       
  2889             // Update preloaded theme image
       
  2890             if ( iCallObjectManager && 
       
  2891                  iCallObjectManager->CallThemeImageIcon() )
       
  2892                 {
       
  2893                 iMainPaneControl->Reset();
       
  2894                 
       
  2895                 iCallObjectManager->ReleaseCallThemeImage();
       
  2896                 iCallObjectManager->LoadCallThemeImage( 
       
  2897                         *iImageManager, 
       
  2898                         MainPaneImageRect().Size() );
       
  2899                 }
       
  2900             }
       
  2901         else if ( aType == KEikDynamicLayoutVariantSwitch )
       
  2902             {
       
  2903             iImageManager->PrepareCachedBitmaps();
       
  2904             }            
       
  2905         
       
  2906         // Call object
       
  2907         if ( aType == KEikDynamicLayoutVariantSwitch )
       
  2908             {
       
  2909             if ( iCallObjectManager && 
       
  2910                  iCallObjectManager->CallThemeImageIcon() )
       
  2911                 {
       
  2912                 iCallObjectManager->ResizeCallThemeImage( MainPaneImageRect().Size() );
       
  2913                 }
       
  2914                         
       
  2915             if ( iMainPaneControl &&
       
  2916                  iMainPaneControl->IsUsed() )
       
  2917                 {
       
  2918                 ReloadCallObjectImage();
       
  2919                 }
       
  2920             }
       
  2921         
       
  2922         EndChanges();
       
  2923 
       
  2924         // Relayout video
       
  2925         if ( iVideoFlags & EBMVideoPlayingVideo )
       
  2926             {
       
  2927             iVideoController->HandleLayoutChange();    
       
  2928             }
       
  2929 
       
  2930         return;
       
  2931         }
       
  2932 
       
  2933     CCoeControl::HandleResourceChange(aType);
       
  2934     }
       
  2935 
       
  2936 // ---------------------------------------------------------------------------
       
  2937 //  CBubbleManager::SetCNAP
       
  2938 //  
       
  2939 // 
       
  2940 // ---------------------------------------------------------------------------
       
  2941 //
       
  2942 EXPORT_C void CBubbleManager::SetCNAP( 
       
  2943     const TBubbleId& aBubbleId, 
       
  2944     const TDesC& aCNAPText, 
       
  2945     const TPhoneClippingDirection& aClipDirection )
       
  2946     {
       
  2947     __ASSERT_ALWAYS( 
       
  2948         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  2949 
       
  2950     // find header
       
  2951     CBubbleHeader* header = NULL;
       
  2952     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  2953                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  2954 
       
  2955     if ( aCNAPText.Length() == 0 )
       
  2956         {
       
  2957         return;
       
  2958         }
       
  2959 
       
  2960     // We have a number        
       
  2961     if ( aClipDirection == ELeft )
       
  2962         {
       
  2963         BubbleUtils::AddTextToHeader( 
       
  2964             *header, 
       
  2965             BubbleUtils::EBubbleHeaderCNAP, 
       
  2966             NumberGroup( aCNAPText ), 
       
  2967             KBubbleLabelMaxLength ,
       
  2968             aClipDirection );
       
  2969         }
       
  2970     else
       
  2971         {
       
  2972         BubbleUtils::AddTextToHeader(
       
  2973             *header, 
       
  2974             BubbleUtils::EBubbleHeaderCNAP, 
       
  2975             aCNAPText, 
       
  2976             KBubbleLabelMaxLength ,
       
  2977             aClipDirection );    
       
  2978         }            
       
  2979     }
       
  2980 
       
  2981 // ---------------------------------------------------------------------------
       
  2982 //  CBubbleManager::NumberGroup
       
  2983 //  
       
  2984 // 
       
  2985 // ---------------------------------------------------------------------------
       
  2986 //
       
  2987 const TDesC& CBubbleManager::NumberGroup( const TDesC& aNumber )
       
  2988     {
       
  2989     if ( iNumberGrouping )
       
  2990         {
       
  2991         iNumberGrouping->Set( aNumber );
       
  2992         return iNumberGrouping->FormattedNumber();
       
  2993         }
       
  2994     else
       
  2995         {
       
  2996         return aNumber;
       
  2997         }
       
  2998     }
       
  2999     
       
  3000 // ---------------------------------------------------------------------------
       
  3001 //  CBubbleManager::SetCallObjectImage
       
  3002 //  
       
  3003 // 
       
  3004 // ---------------------------------------------------------------------------
       
  3005 //
       
  3006 EXPORT_C void CBubbleManager::SetCallObjectImage( 
       
  3007     const TBubbleId& aBubbleId,
       
  3008     const TDesC& aImageFileName )
       
  3009     {
       
  3010     __ASSERT_ALWAYS( iCallObjectManager, 
       
  3011                      Panic( EBMPanicFeatureNotSupported ) );
       
  3012         
       
  3013     CBubbleHeader* header = NULL;
       
  3014     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3015                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3016     
       
  3017     if ( !header->CallObjectImage() )
       
  3018         {
       
  3019         if ( !header->IsConference() )        
       
  3020             {
       
  3021             // load image from file
       
  3022             TBool threeLines( header->CNAP().Length() > 0 );
       
  3023             CBubbleCallObjectManager::TImageLoadingParams params;
       
  3024             params.iPreferredSize = MainPaneImageRect().Size();
       
  3025             params.iTinyImageSize = MainPaneImageRect( ETrue, 
       
  3026                                                        threeLines ).Size();
       
  3027             params.iDisplayMode = Window().DisplayMode();
       
  3028             params.iThumbnailSize = CallObjectImageIncallSize( ETrue );
       
  3029             iCallObjectManager->LoadImageFromFile( aBubbleId,
       
  3030                                                    aImageFileName,
       
  3031                                                    params );
       
  3032             }
       
  3033         else // conference
       
  3034             {
       
  3035             TAknLayoutRect bubbleRect;
       
  3036             bubbleRect.LayoutRect( Rect(),
       
  3037                 BubbleLayout2::popup_call2_audio_conf_window(3) );
       
  3038             
       
  3039             TSize imageSize( 
       
  3040                 CallObjectImageIncallSize().iWidth,
       
  3041                 bubbleRect.Rect().Size().iHeight );
       
  3042             
       
  3043             // load image from file
       
  3044             CBubbleCallObjectManager::TImageLoadingParams params;
       
  3045             params.iPreferredSize = imageSize;
       
  3046             params.iDisplayMode = Window().DisplayMode();
       
  3047             params.iTinyImageSize = TSize(0,0);
       
  3048             params.iThumbnailSize = TSize(0,0);
       
  3049             iCallObjectManager->LoadImageFromFile( aBubbleId,
       
  3050                                                    aImageFileName,
       
  3051                                                    params );    
       
  3052             }            
       
  3053 
       
  3054         header->SetCallObjectFileName( aImageFileName.Alloc() );
       
  3055         header->SetCallObjectImageType(
       
  3056            CBubbleHeader::EGalleryImage );
       
  3057         }
       
  3058     
       
  3059     return;            
       
  3060     }
       
  3061 
       
  3062 // ---------------------------------------------------------------------------
       
  3063 //  CBubbleManager::SetCallObjectImage
       
  3064 //  
       
  3065 // 
       
  3066 // ---------------------------------------------------------------------------
       
  3067 //    
       
  3068 EXPORT_C void CBubbleManager::SetCallObjectImage( const TBubbleId& aBubbleId,
       
  3069                                                   CFbsBitmap* aCOBitmap, 
       
  3070                                                   CFbsBitmap* aCOBitmapMask,
       
  3071                                                   TBool aDataOwnershipTrasferred )
       
  3072     {
       
  3073     __ASSERT_ALWAYS( ( iConfigFlags & EBMCallObjectDisplay ), 
       
  3074                      Panic( EBMPanicFeatureNotSupported ) );
       
  3075         
       
  3076     __ASSERT_ALWAYS( 
       
  3077         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  3078     
       
  3079     // find header
       
  3080     CBubbleHeader* header = NULL;
       
  3081     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3082                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3083     
       
  3084     header->SetCallObjectImage( aCOBitmap );
       
  3085     header->SetCallObjectImageMask( aCOBitmapMask );
       
  3086     header->SetCallObjectImageDataOwnership( aDataOwnershipTrasferred );
       
  3087     iCallObjectChanged = ETrue;    
       
  3088     }
       
  3089 
       
  3090 // ---------------------------------------------------------------------------
       
  3091 //  CBubbleManager::SetCallObjectTheme
       
  3092 //  
       
  3093 // 
       
  3094 // ---------------------------------------------------------------------------
       
  3095 //
       
  3096 EXPORT_C void CBubbleManager::SetCallObjectFromTheme( 
       
  3097     const TBubbleId& aBubbleId )
       
  3098     {
       
  3099     CBubbleHeader* header = NULL;
       
  3100     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3101                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3102     
       
  3103     if ( !header->CallObjectImage()  )
       
  3104         {
       
  3105         CEikImage* themeImage = new CEikImage;
       
  3106         if ( themeImage != NULL )
       
  3107             {
       
  3108             iImageManager->SetBitmapToImage( themeImage,
       
  3109                                              EQgn_graf_call_image_1,
       
  3110                                              EQgn_graf_call_image_1_mask );
       
  3111             SetCallObjectImage( 
       
  3112                 aBubbleId,
       
  3113                 const_cast<CFbsBitmap*> ( themeImage->Bitmap() ),
       
  3114                 const_cast<CFbsBitmap*> ( themeImage->Mask() ),
       
  3115                 ETrue );
       
  3116     
       
  3117             themeImage->SetPictureOwnedExternally( ETrue );
       
  3118             delete themeImage;
       
  3119             header->SetCallObjectImageType( CBubbleHeader::EThemeImage );                
       
  3120             }
       
  3121         }
       
  3122     }
       
  3123     
       
  3124 // ---------------------------------------------------------------------------
       
  3125 //  CBubbleManager::SetCallObjectText
       
  3126 //  
       
  3127 // 
       
  3128 // ---------------------------------------------------------------------------
       
  3129 //    
       
  3130 EXPORT_C void CBubbleManager::SetCallObjectText( const TBubbleId& aBubbleId, 
       
  3131                                                  const TDesC& aCOText )
       
  3132     {
       
  3133     __ASSERT_ALWAYS( iCallObjectManager, 
       
  3134                      Panic( EBMPanicFeatureNotSupported ) );
       
  3135         
       
  3136     __ASSERT_ALWAYS( 
       
  3137         iIsReadyToDraw > 0, Panic( EBMPanicErrorInStartAndEndChanges ) );
       
  3138     
       
  3139     // find header
       
  3140     CBubbleHeader* header = NULL;
       
  3141     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3142                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3143     
       
  3144     if ( !header->CallObjectText().Length() &&
       
  3145          !header->IsConference() )
       
  3146         {
       
  3147         HBufC* text = aCOText.Alloc();    
       
  3148         header->SetCallObjectText( text ); // takes ownership
       
  3149         iCallObjectChanged = ETrue;
       
  3150     
       
  3151         CBubbleCallObjectManager::TImageLoadingParams params;
       
  3152         params.iPreferredSize = CallObjectImageIncallSize();
       
  3153         params.iTinyImageSize = TSize(0,0);
       
  3154         params.iThumbnailSize = TSize(0,0);
       
  3155         params.iDisplayMode = Window().DisplayMode();
       
  3156         iCallObjectManager->LoadImageFromText( aBubbleId,
       
  3157                                                aCOText,
       
  3158                                                params );
       
  3159         header->SetCallObjectImageType(
       
  3160            CBubbleHeader::ETextBasedImage );                                               
       
  3161         }
       
  3162     }
       
  3163 
       
  3164 // ---------------------------------------------------------------------------
       
  3165 //  CBubbleManager::ChangeEditorMode
       
  3166 //  
       
  3167 // 
       
  3168 // ---------------------------------------------------------------------------
       
  3169 //
       
  3170 EXPORT_C TInt CBubbleManager::ChangeEditorMode( TBool aDefaultMode )
       
  3171     {
       
  3172     return iNumberEntry->ChangeEditorMode( aDefaultMode );
       
  3173     }
       
  3174     
       
  3175 // ---------------------------------------------------------------------------
       
  3176 //  CBubbleManager::GetEditorMode
       
  3177 //  
       
  3178 // 
       
  3179 // ---------------------------------------------------------------------------
       
  3180 //
       
  3181 EXPORT_C TInt CBubbleManager::GetEditorMode() const
       
  3182     {
       
  3183     return iNumberEntry->GetEditorMode();
       
  3184     }    
       
  3185     
       
  3186 // ---------------------------------------------------------------------------
       
  3187 //  CBubbleManager::ResetEditorToDefaultValues
       
  3188 //  
       
  3189 // 
       
  3190 // ---------------------------------------------------------------------------
       
  3191 //
       
  3192 EXPORT_C void CBubbleManager::ResetEditorToDefaultValues()
       
  3193     {
       
  3194     iNumberEntry->ResetEditorToDefaultValues();
       
  3195     }        
       
  3196                                                    
       
  3197 // ---------------------------------------------------------------------------
       
  3198 //  CBubbleManager::DeactivatepPopupDisplay
       
  3199 //  
       
  3200 // 
       
  3201 // ---------------------------------------------------------------------------
       
  3202 //
       
  3203 TBool CBubbleManager::FindHeader( const TPhoneCallState& aCallState,
       
  3204                                   CBubbleHeader*& aHeader ) const
       
  3205     {
       
  3206     // lookup outgoing and incoming call headers
       
  3207     TInt activeHeaderCount( iActiveHeaders->Count() );
       
  3208     for ( TInt i(0); i < activeHeaderCount; i++ )
       
  3209         {
       
  3210         CBubbleHeader* header = iActiveHeaders->At( i );
       
  3211         TPhoneCallState callState( header->CallState() );    
       
  3212         if ( callState == aCallState )
       
  3213             {
       
  3214             aHeader = header;
       
  3215             return ETrue;
       
  3216             }
       
  3217         }
       
  3218 
       
  3219     return EFalse;
       
  3220     }
       
  3221 
       
  3222 
       
  3223 // ---------------------------------------------------------------------------
       
  3224 //  CBubbleManager::BuildMainPaneCallObjectL
       
  3225 //  
       
  3226 // 
       
  3227 // ---------------------------------------------------------------------------
       
  3228 //     
       
  3229 void CBubbleManager::BuildMainPaneImage()
       
  3230     {
       
  3231     BM_TRACE_( "[BUBBLEMANAGER] CBubbleManager::BuildMainPaneImage" );
       
  3232     
       
  3233     CBubbleHeader* incomingHeader = NULL;
       
  3234     CBubbleHeader* outgoingHeader = NULL;
       
  3235     CBubbleHeader* activeHeader = NULL;
       
  3236     CBubbleHeader* holdHeader = NULL;
       
  3237     CBubbleHeader* activeConfHeader = NULL;
       
  3238     
       
  3239     // get incoming and outgoing call headers
       
  3240     TInt activeHeaderCount( iActiveHeaders->Count() );
       
  3241     for ( TInt i(0); i < activeHeaderCount; i++ )
       
  3242         {
       
  3243         CBubbleHeader* header = iActiveHeaders->At( i );
       
  3244         TPhoneCallState callState( header->CallState() );    
       
  3245         if ( callState == EIncoming || callState == EWaiting )
       
  3246             {
       
  3247             incomingHeader = header;
       
  3248             activeHeader = NULL;
       
  3249             holdHeader = NULL;
       
  3250             activeConfHeader = NULL;
       
  3251             break;
       
  3252             }
       
  3253         else if ( callState == EOutgoing || callState == EAlerting )
       
  3254             {
       
  3255             outgoingHeader = header;
       
  3256             activeHeader = NULL;
       
  3257             holdHeader = NULL;
       
  3258             activeConfHeader = NULL;
       
  3259             break;
       
  3260             }
       
  3261         else if ( callState == EActive )
       
  3262             {
       
  3263             holdHeader = NULL;
       
  3264             if( header->IsConference() )
       
  3265                 {
       
  3266                 // active conference founded, no image to show
       
  3267                 activeConfHeader = header;
       
  3268                 activeHeader = NULL;
       
  3269                 }
       
  3270             else if ( !activeConfHeader )
       
  3271                 {
       
  3272                 // no conference, single active
       
  3273                 activeHeader = header;
       
  3274                 }
       
  3275             }
       
  3276         else if ( callState == EOnHold )
       
  3277             {
       
  3278             if( !activeHeader && !activeConfHeader )
       
  3279                 {                
       
  3280                 // none active headers, hold need to handle
       
  3281                 holdHeader = header;
       
  3282                 }
       
  3283             }
       
  3284         BM_TRACE_1( "[BUBBLEMANAGER] CBubbleManager::BuildMainPaneImage - callState = %d", callState );
       
  3285         }
       
  3286     
       
  3287    if ( holdHeader && iMainPaneControl->IsUsed() )
       
  3288         {
       
  3289         // Keep image in mainpane displayed
       
  3290         return;
       
  3291         }
       
  3292     else if ( activeConfHeader || ( !incomingHeader && !outgoingHeader && !activeHeader && !holdHeader ) )
       
  3293         {
       
  3294         // there are conference call or no incoming, outgoing, active, hold calls , no image
       
  3295         // in mainpane is displayed
       
  3296         iMainPaneControl->Reset();
       
  3297         return;
       
  3298         }
       
  3299     
       
  3300     CBubbleHeader* header = incomingHeader;
       
  3301     if ( outgoingHeader )
       
  3302         {
       
  3303         header = outgoingHeader;
       
  3304         }
       
  3305     else if ( activeHeader )
       
  3306         {
       
  3307         // single active
       
  3308         header = activeHeader;
       
  3309         iCallObjectChanged = ETrue;
       
  3310         }
       
  3311     else if ( holdHeader )
       
  3312         {
       
  3313         // single hold and no image yet
       
  3314         header = holdHeader;
       
  3315         iCallObjectChanged = ETrue;
       
  3316         }
       
  3317                 
       
  3318     if ( header->IsInConference() || header->CallObjectText().Length() )
       
  3319         {
       
  3320         // Conference item or Text is not shown in mainpane.
       
  3321         return;            
       
  3322         }
       
  3323 
       
  3324     if ( !iMainPaneControl->IsUsed() || iCallObjectChanged )
       
  3325         {
       
  3326         iMainPaneControl->Reset();
       
  3327         iMainPaneControl->ReadBubbleHeader( *header );
       
  3328         iCallObjectChanged = EFalse;    
       
  3329         }
       
  3330     }
       
  3331 
       
  3332 // ---------------------------------------------------------------------------
       
  3333 //  CBubbleManager::ReloadCallObjectImage
       
  3334 //  
       
  3335 // 
       
  3336 // ---------------------------------------------------------------------------
       
  3337 //
       
  3338 void CBubbleManager::ReloadCallObjectImage()
       
  3339     {
       
  3340     const TBubbleId bubble = iMainPaneControl->BubbleId();
       
  3341 
       
  3342     iMainPaneControl->Reset();
       
  3343     
       
  3344     CBubbleHeader* header = NULL;
       
  3345     FindActiveHeader( bubble , header );
       
  3346 
       
  3347     if ( header && header->CallObjectFileName().Length() )        
       
  3348         {
       
  3349         TBool threeLines( header->CNAP().Length() > 0 );
       
  3350         
       
  3351         CBubbleCallObjectManager::TImageLoadingParams params;
       
  3352         params.iPreferredSize = MainPaneImageRect().Size();
       
  3353         params.iTinyImageSize = MainPaneImageRect( ETrue, threeLines ).Size();
       
  3354         params.iThumbnailSize = CallObjectImageIncallSize( ETrue );
       
  3355         params.iDisplayMode = Window().DisplayMode();    
       
  3356 
       
  3357         iCallObjectManager->CancelCallObjectLoading( bubble );
       
  3358         
       
  3359         iCallObjectManager->LoadImageFromFile( 
       
  3360             bubble,
       
  3361             header->CallObjectFileName(),
       
  3362             params );
       
  3363         
       
  3364         header->SetCallObjectImage( NULL );
       
  3365         }
       
  3366     }
       
  3367 
       
  3368 // ---------------------------------------------------------------------------
       
  3369 //  CBubbleManager::CallIsDroppedByEndKey
       
  3370 //  
       
  3371 // 
       
  3372 // ---------------------------------------------------------------------------
       
  3373 //
       
  3374 TBool CBubbleManager::IsCallDroppedByEndKey( 
       
  3375     const TPhoneCallState& aState ) const
       
  3376     {
       
  3377     TUint activeCallCount( iActiveHeaders->Count() );
       
  3378     
       
  3379     if ( activeCallCount == 1 )
       
  3380         {
       
  3381         // just one call, it is always dropped by end key
       
  3382         return ETrue;            
       
  3383         }
       
  3384         
       
  3385     // Dropping order in multicall state
       
  3386     // 1. Disconnected call
       
  3387     // 2. Initialising or alerting call
       
  3388     // 3. Active call
       
  3389     // 4. Held call
       
  3390     // 5. Waiting call
       
  3391     
       
  3392     if ( aState == EWaiting )
       
  3393         {
       
  3394         // never dropped by end key
       
  3395         return EFalse;                
       
  3396         }
       
  3397     
       
  3398     // go through ongoing calls and check if there is a call with
       
  3399     // higher dropping priority
       
  3400     TBool dropped( ETrue );
       
  3401     for ( TInt i(0); i < activeCallCount; i++ )
       
  3402         {
       
  3403         TPhoneCallState callState = iActiveHeaders->At( i )->CallState();
       
  3404         
       
  3405         if ( aState == EOnHold && ( callState == EDisconnected ||
       
  3406              callState == EOutgoing || callState == EAlerting ||
       
  3407              callState == EActive ) )
       
  3408             {
       
  3409             dropped = EFalse;
       
  3410             break;    
       
  3411             }
       
  3412         else if ( aState == EActive && ( callState == EDisconnected ||
       
  3413              callState == EOutgoing || callState == EAlerting ) )
       
  3414             {
       
  3415             dropped = EFalse;
       
  3416             break;        
       
  3417             }
       
  3418         else if ( ( aState == EOutgoing || aState == EAlerting ) &&
       
  3419             ( callState == EDisconnected ) )
       
  3420             {
       
  3421             dropped = EFalse;
       
  3422             break;            
       
  3423             }
       
  3424         else
       
  3425             {
       
  3426             // do nothing    
       
  3427             }
       
  3428         } // for
       
  3429     
       
  3430     return dropped;       
       
  3431     }    
       
  3432 
       
  3433 // ---------------------------------------------------------------------------
       
  3434 //  CBubbleManager::ActiveCallCount
       
  3435 //  
       
  3436 // 
       
  3437 // ---------------------------------------------------------------------------
       
  3438 //    
       
  3439 TUint8 CBubbleManager::ActiveCallCount() const
       
  3440     {
       
  3441     return iActiveHeaders->Count();    
       
  3442     }
       
  3443 
       
  3444 // ---------------------------------------------------------------------------
       
  3445 //  CBubbleManager::MainPaneImageRect
       
  3446 //  
       
  3447 // 
       
  3448 // ---------------------------------------------------------------------------
       
  3449 //
       
  3450 const TRect CBubbleManager::MainPaneImageRect( 
       
  3451     TBool aTinyImage,
       
  3452     TBool aThreeLinesShown ) const
       
  3453     {
       
  3454     TRect imageRect; // whole main
       
  3455     
       
  3456     if ( aTinyImage )
       
  3457         {
       
  3458         TInt variety = aThreeLinesShown ? 1 : 0;
       
  3459         
       
  3460         if ( iConfigFlags & EBMTouchCallhandling )
       
  3461             {
       
  3462             // requires call2_image_placing_area to LAF data.
       
  3463             TAknLayoutRect callPane;
       
  3464             callPane.LayoutRect(
       
  3465                 Rect(), 
       
  3466                 BubbleLayout4::call4_windows_pane(2) );    
       
  3467             
       
  3468             TAknLayoutRect image;
       
  3469             image.LayoutRect(
       
  3470                 callPane.Rect(), 
       
  3471                 BubbleLayout2::call2_image_placing_area( variety ) );                
       
  3472             imageRect = image.Rect();                
       
  3473             }
       
  3474         else
       
  3475             {
       
  3476             TAknLayoutRect image;
       
  3477             image.LayoutRect(
       
  3478                 Rect(), 
       
  3479                 BubbleLayout2::call2_image_placing_area( variety ) );    
       
  3480             imageRect = image.Rect();    
       
  3481             }
       
  3482         }
       
  3483     else
       
  3484         {
       
  3485         if ( iConfigFlags & EBMTouchCallhandling )
       
  3486             {
       
  3487             TAknLayoutRect image;
       
  3488             image.LayoutRect(
       
  3489                 Rect(), 
       
  3490                 BubbleLayout4::call4_image_pane( 2 ) );    
       
  3491             imageRect = image.Rect();                
       
  3492             }
       
  3493         else
       
  3494             {
       
  3495             // mainpane
       
  3496             imageRect = Rect();    
       
  3497             }            
       
  3498         }        
       
  3499     
       
  3500     return imageRect;
       
  3501     }
       
  3502 
       
  3503 // ---------------------------------------------------------------------------
       
  3504 //  CBubbleManager::PrepareIcons
       
  3505 //  
       
  3506 // 
       
  3507 // ---------------------------------------------------------------------------
       
  3508 //    
       
  3509 EXPORT_C void CBubbleManager::PrepareIcons()
       
  3510     {
       
  3511     iImageManager->PrepareCachedBitmaps();
       
  3512     }
       
  3513 
       
  3514 // ---------------------------------------------------------------------------
       
  3515 //  CBubbleManager::PreloadCallThemeImage
       
  3516 //  
       
  3517 // 
       
  3518 // ---------------------------------------------------------------------------
       
  3519 //
       
  3520 EXPORT_C void CBubbleManager::PreloadCallThemeImage( TBool aPreload )
       
  3521     {
       
  3522     __ASSERT_ALWAYS( ( iConfigFlags & EBMCallObjectDisplay ), 
       
  3523                        Panic( EBMPanicFeatureNotSupported ) );
       
  3524     if ( aPreload )
       
  3525         {
       
  3526         iCallObjectManager->LoadCallThemeImage( 
       
  3527                 *iImageManager,
       
  3528                 MainPaneImageRect().Size() ); 
       
  3529         }
       
  3530     else
       
  3531         {
       
  3532         iCallObjectManager->ReleaseCallThemeImage();
       
  3533         }        
       
  3534     }
       
  3535 
       
  3536 // ---------------------------------------------------------------------------
       
  3537 //  CBubbleManager::StartAnimations
       
  3538 //  
       
  3539 // 
       
  3540 // ---------------------------------------------------------------------------
       
  3541 //    
       
  3542 void CBubbleManager::StartAnimations()
       
  3543     {
       
  3544     if ( !IsVisible() )
       
  3545         {
       
  3546         // Animation will be started when this control becomes visible.
       
  3547         return;            
       
  3548         }
       
  3549     
       
  3550     for ( TInt i = 0 ; i < iActivePlaces->Count() ; i++ )
       
  3551         {
       
  3552         TRAP_IGNORE( 
       
  3553             iActivePlaces->At(i)->GetBubbleOutlook().HandleAnimationStartL() );
       
  3554         }    
       
  3555     }
       
  3556 
       
  3557 // ---------------------------------------------------------------------------
       
  3558 //  CBubbleManager::HandleBackgroundImageChange
       
  3559 //  
       
  3560 // 
       
  3561 // ---------------------------------------------------------------------------
       
  3562 //    
       
  3563 EXPORT_C void CBubbleManager::HandleBackgroundImageChange()
       
  3564     {
       
  3565     // Restart animations to update background frames.
       
  3566     StartAnimations();    
       
  3567     }
       
  3568 
       
  3569 // ---------------------------------------------------------------------------
       
  3570 //  CBubbleManager::SetVideoRingTone
       
  3571 //  
       
  3572 // 
       
  3573 // ---------------------------------------------------------------------------
       
  3574 // 
       
  3575 EXPORT_C void CBubbleManager::SetVideoRingTone(
       
  3576     const TDesC& aFileName,
       
  3577     TBubbleVideoPlayMode aPlayMode,
       
  3578     TInt aVolumeLevel,
       
  3579     TBool aUseArbitraryScaling,
       
  3580     MBubbleVideoPlaybackObserver* aObserver )
       
  3581     {
       
  3582     iVideoController->StopAndDeletePlayer();
       
  3583     iVideoController->PrepareToPlayVideo( aFileName,
       
  3584                                           aPlayMode,
       
  3585                                           aVolumeLevel,
       
  3586                                           aUseArbitraryScaling,
       
  3587                                           aObserver );
       
  3588     
       
  3589     iVideoFlags |=  EBMVideoSetAsRingTone;
       
  3590     
       
  3591     if ( iCallObjectManager )
       
  3592         {
       
  3593         iCallObjectManager->Suspend();            
       
  3594         }    
       
  3595     }
       
  3596 
       
  3597 // ---------------------------------------------------------------------------
       
  3598 //  CBubbleManager::StopVideoRingTone
       
  3599 //  
       
  3600 // 
       
  3601 // ---------------------------------------------------------------------------
       
  3602 //
       
  3603 EXPORT_C void CBubbleManager::StopVideoRingTone()
       
  3604     {
       
  3605     iVideoController->StopPlaying();                
       
  3606     }
       
  3607 
       
  3608 // ---------------------------------------------------------------------------
       
  3609 //  CBubbleManager::MuteVideoRingTone
       
  3610 //  
       
  3611 // 
       
  3612 // ---------------------------------------------------------------------------
       
  3613 //        
       
  3614 EXPORT_C void CBubbleManager::MuteVideoRingTone()
       
  3615     {
       
  3616     iVideoController->MutePlaying();                
       
  3617     }
       
  3618 
       
  3619 // ---------------------------------------------------------------------------
       
  3620 //  CBubbleManager::StopVideoRingTone
       
  3621 //  
       
  3622 // 
       
  3623 // ---------------------------------------------------------------------------
       
  3624 //        
       
  3625 EXPORT_C void CBubbleManager::CancelVideoRingTone()
       
  3626     {
       
  3627     StopAndDeleteVideoPlayer();
       
  3628     }
       
  3629     
       
  3630 // ---------------------------------------------------------------------------
       
  3631 //  CBubbleManager::CreateVideoPlayerAndPlay
       
  3632 //  
       
  3633 // 
       
  3634 // ---------------------------------------------------------------------------
       
  3635 //
       
  3636 void CBubbleManager::CreateVideoPlayerAndPlay()
       
  3637     { 
       
  3638     iVideoController->CreatePlayerAndPlay();
       
  3639     iVideoFlags |= EBMVideoPlayingVideo;
       
  3640     }
       
  3641     
       
  3642 // ---------------------------------------------------------------------------
       
  3643 //  CBubbleManager::StopAndDeleteVideoPlayer
       
  3644 //  
       
  3645 // 
       
  3646 // ---------------------------------------------------------------------------
       
  3647 //
       
  3648 void CBubbleManager::StopAndDeleteVideoPlayer()
       
  3649     {
       
  3650     iVideoController->StopAndDeletePlayer();
       
  3651     iVideoFlags &= ~EBMVideoPlayingVideo;
       
  3652     iVideoFlags &= ~EBMVideoSetAsRingTone;
       
  3653     if ( iCallObjectManager )
       
  3654         {
       
  3655         iCallObjectManager->Resume();            
       
  3656         }
       
  3657     }
       
  3658     
       
  3659 // ---------------------------------------------------------------------------
       
  3660 //  CBubbleManager::VideoController
       
  3661 //  
       
  3662 // 
       
  3663 // ---------------------------------------------------------------------------
       
  3664 //
       
  3665 CBubbleVideoController& CBubbleManager::VideoController() const
       
  3666     {
       
  3667     return *iVideoController;    
       
  3668     }
       
  3669 
       
  3670 // ---------------------------------------------------------------------------
       
  3671 //  CBubbleManager::CallState
       
  3672 //  
       
  3673 // 
       
  3674 // ---------------------------------------------------------------------------
       
  3675 //
       
  3676 CBubbleManager::TPhoneCallState CBubbleManager::CallState( 
       
  3677     const TBubbleId& aBubbleId )
       
  3678     {
       
  3679     CBubbleHeader* header = NULL;
       
  3680     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3681                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3682     return header->CallState();                         
       
  3683     }
       
  3684     
       
  3685 
       
  3686 // ---------------------------------------------------------------------------
       
  3687 //  CBubbleManager::CallObjectImageIncallSize
       
  3688 //  
       
  3689 // 
       
  3690 // ---------------------------------------------------------------------------
       
  3691 //
       
  3692 TSize CBubbleManager::CallObjectImageIncallSize( TBool aBigBubble )
       
  3693     {
       
  3694     TAknLayoutRect bubbleRect;
       
  3695 
       
  3696     if ( iConfigFlags & EBMTouchCallhandling )
       
  3697         {
       
  3698         TInt variety = aBigBubble ? 4 : 0;
       
  3699         
       
  3700         bubbleRect.LayoutRect( Rect(),
       
  3701             BubbleLayout4::popup_call4_audio_first_window(variety) );
       
  3702         }
       
  3703     else
       
  3704         {
       
  3705         if ( aBigBubble )    
       
  3706             {
       
  3707             bubbleRect.LayoutRect( Rect(),
       
  3708                 BubbleLayout2::popup_call2_audio_first_window(0) );
       
  3709             }
       
  3710         else
       
  3711             {
       
  3712             bubbleRect.LayoutRect( Rect(),
       
  3713                BubbleLayout2::popup_call2_audio_in_window(0) );    
       
  3714             }
       
  3715         }
       
  3716             
       
  3717     // image size is half from bubble size
       
  3718     TSize imageSize( bubbleRect.Rect().Size() );
       
  3719     // Opaque part in bubble approx. 45%.
       
  3720     imageSize.iWidth -= (45 * imageSize.iWidth) / 100;
       
  3721     return imageSize;  
       
  3722     }
       
  3723 
       
  3724 // ---------------------------------------------------------------------------
       
  3725 //  CBubbleManager::SetParticipantListCLI
       
  3726 //  
       
  3727 // 
       
  3728 // ---------------------------------------------------------------------------
       
  3729 //    
       
  3730 EXPORT_C void CBubbleManager::SetParticipantListCLI(
       
  3731     const TBubbleId& aBubbleId,
       
  3732     TBubbleParticipantListCLI aParticipantCLI )
       
  3733     {
       
  3734     CBubbleHeader* header = NULL;
       
  3735     __ASSERT_ALWAYS( FindActiveHeader( aBubbleId , header ) ,  
       
  3736                      Panic( EBMPanicBubbleIdIsNotInUse ) );
       
  3737     header->SetParticipantListCLI( aParticipantCLI );
       
  3738     }
       
  3739 
       
  3740 // ---------------------------------------------------------------------------
       
  3741 //  CBubbleManager::TouchPane
       
  3742 //  
       
  3743 // 
       
  3744 // ---------------------------------------------------------------------------
       
  3745 //
       
  3746 EXPORT_C MBubbleTouchPaneInterface* CBubbleManager::TouchPane()
       
  3747     {
       
  3748     return iTouchPane;    
       
  3749     }
       
  3750 
       
  3751 // ---------------------------------------------------------------------------
       
  3752 //  CBubbleManager::SetTouchPaneVisible
       
  3753 //  
       
  3754 // 
       
  3755 // ---------------------------------------------------------------------------
       
  3756 //    
       
  3757 EXPORT_C void CBubbleManager::SetTouchPaneVisible( TBool aVisible )
       
  3758     {
       
  3759     iTouchPaneSetVisible = aVisible;   
       
  3760     }
       
  3761 
       
  3762 // ---------------------------------------------------------------------------
       
  3763 //  CBubbleManager::InitializingCall
       
  3764 //  
       
  3765 // 
       
  3766 // ---------------------------------------------------------------------------
       
  3767 //    
       
  3768 TBool CBubbleManager::InitializingCall() const
       
  3769     {
       
  3770     TBool initializingCall = EFalse;
       
  3771     
       
  3772     TInt activeHeaderCount( iActiveHeaders->Count() );
       
  3773     for ( TInt i(0); i < activeHeaderCount; i++ )
       
  3774         {
       
  3775         CBubbleHeader* header = iActiveHeaders->At( i );
       
  3776         TPhoneCallState callState( header->CallState() );    
       
  3777         if ( callState == EIncoming || callState == EWaiting ||
       
  3778              callState == EAlerting || callState == EOutgoing ||
       
  3779              callState == EAlertToDisconnected )
       
  3780             {
       
  3781             initializingCall = ETrue;
       
  3782             break;
       
  3783             }
       
  3784         }
       
  3785         
       
  3786     return initializingCall;
       
  3787     }
       
  3788 
       
  3789 // ---------------------------------------------------------------------------
       
  3790 //  CBubbleManager::IsTouchCallHandling
       
  3791 //  
       
  3792 // 
       
  3793 // ---------------------------------------------------------------------------
       
  3794 //    
       
  3795 TBool CBubbleManager::IsTouchCallHandling() const
       
  3796     {
       
  3797     return (iConfigFlags & EBMTouchCallhandling);    
       
  3798     }
       
  3799 
       
  3800 // ---------------------------------------------------------------------------
       
  3801 //  CBubbleManager::AddCustomElement
       
  3802 //  
       
  3803 // 
       
  3804 // ---------------------------------------------------------------------------
       
  3805 //
       
  3806 EXPORT_C void CBubbleManager::AddCustomElement( 
       
  3807     const TBubbleId& aBubbleId,
       
  3808     CTelBubbleCustomElement* aElement,
       
  3809     TInt aPriority )
       
  3810     {
       
  3811     if ( aElement->ElementType() == CTelBubbleCustomElement::ECallImage &&
       
  3812          aBubbleId == iMainPaneControl->BubbleId() )
       
  3813         {
       
  3814         // reset control to get it replaced with this custom element
       
  3815         iMainPaneControl->Reset();
       
  3816         }
       
  3817     
       
  3818     iCustomManager->AddCustomElement( aBubbleId, aElement, aPriority );
       
  3819     }
       
  3820         
       
  3821 // ---------------------------------------------------------------------------
       
  3822 //  CBubbleManager::RemoveCustomElement
       
  3823 //  
       
  3824 // 
       
  3825 // ---------------------------------------------------------------------------
       
  3826 //
       
  3827 EXPORT_C void CBubbleManager::RemoveCustomElement( 
       
  3828     const TBubbleId& aBubbleId,
       
  3829     CTelBubbleCustomElement* aElement )
       
  3830     {
       
  3831     if ( aElement->ElementType() == CTelBubbleCustomElement::ECallImage &&
       
  3832          aBubbleId == iMainPaneControl->BubbleId() )
       
  3833         {
       
  3834         // aElement is being used; release it, before removing
       
  3835         // it from custom manager.
       
  3836         iMainPaneControl->Reset();
       
  3837         }
       
  3838     
       
  3839     iCustomManager->RemoveCustomElement( aBubbleId, aElement );
       
  3840     }
       
  3841 
       
  3842 // End of File