phoneuis/BubbleManager/Src/BMBubbleImageManager.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Image Manager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "BMBubbleImageManager.h"
       
    21 #include    "BMBubbleSkinBitmap.h"
       
    22 #include    "BubbleManagerPaths.h"
       
    23 #include    "BMPanic.h"
       
    24 #include    "BMUtils.h"
       
    25 #include    "BMLayout.h"
       
    26 #include    "BMBubbleIconIndex.h"
       
    27 
       
    28 #include    <eikimage.h> 
       
    29 #include    <AknsUtils.h>
       
    30 #include    <aknconsts.h>
       
    31 #include    <AknIconUtils.h>
       
    32 
       
    33 // CONSTANTS
       
    34 // 1-piece backgrounds
       
    35 const TInt KBMLastCachedBitmap1 = EQgn_graf_call_first_one_disconn_mask;
       
    36 // 9-piece backgrounds
       
    37 const TInt KBMLastCachedBitmap2 = EQgn_indi_call_voip_disconn_mask; 
       
    38 const TInt KBMLastAvkonBitmap = EQgn_prop_nrtyp_assistant_mask; 
       
    39 
       
    40 // ========================= MEMBER FUNCTIONS ================================
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CBubbleImageManager::CBubbleImageManager()
       
    44 // Default constructor
       
    45 // 
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CBubbleImageManager::CBubbleImageManager( TBool aFrameIcons ) : 
       
    49     iOrder( CompareSkinnedData ), iFrameIcons( aFrameIcons )
       
    50     {    
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CBubbleImageManager::NewL
       
    55 // Symbian OS two phased constructor
       
    56 // 
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CBubbleImageManager* CBubbleImageManager::NewL( TBool aFrameIcons )
       
    60     {
       
    61     CBubbleImageManager* self = new( ELeave ) CBubbleImageManager( 
       
    62         aFrameIcons );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop();    // self
       
    66     return self;
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CBubbleImageManager::ConstructL
       
    72 // Symbian OS two phased constructor
       
    73 // 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void CBubbleImageManager::ConstructL()
       
    77     {
       
    78     LoadCachedBitmapsL();
       
    79     
       
    80     iBitmapInitializer = CIdle::NewL( CActive::EPriorityIdle );
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CBubbleImageManager::~CBubbleImageManager()
       
    85 // Destructor
       
    86 // 
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CBubbleImageManager::~CBubbleImageManager()
       
    90     {
       
    91     iSkinnedBitmaps.ResetAndDestroy();
       
    92     
       
    93     if ( iBitmapInitializer ) 
       
    94         {
       
    95         iBitmapInitializer->Cancel();                
       
    96         }
       
    97     delete iBitmapInitializer;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CBubbleImageManager::SetBitmapToImage
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CBubbleImageManager::SetBitmapToImage( CEikImage*& aImage , 
       
   105                                             const TBMIcons& aPicture )
       
   106     {
       
   107     // Check the paramater is valid.
       
   108     if ( aImage == NULL )
       
   109         {
       
   110         return;
       
   111         }
       
   112     SetBitmapToImage( *aImage , aPicture, (TBMIcons) KErrNotFound );
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CBubbleImageManager::SetBitmapToImage
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CBubbleImageManager::SetBitmapToImage( CEikImage*& aImage , 
       
   120                                             const TBMIcons& aPicture, 
       
   121                                             const TBMIcons& aPictureMask 
       
   122                                            )
       
   123     {
       
   124     // Check that paramaters are valid and bitmaps exist.
       
   125     if ( aImage == NULL )
       
   126         {
       
   127         return;
       
   128         }
       
   129     SetBitmapToImage( *aImage , aPicture, aPictureMask );
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CBubbleImageManager::SetBitmapToImage
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CBubbleImageManager::SetBitmapToImage( CEikImage& aImage , 
       
   137                                             const TBMIcons& aPicture, 
       
   138                                             const TBMIcons& aPictureMask 
       
   139                                            ) 
       
   140     {
       
   141     // Check parameter range and load the bitmaps.
       
   142     if ( !GetSkin( aImage, aPicture, aPictureMask ) )
       
   143         {
       
   144         // Failed, make image not visible
       
   145         aImage.SetPicture( NULL , NULL );
       
   146         aImage.MakeVisible( EFalse );
       
   147         return;
       
   148         }    
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // CBubbleImageManager::MapEnumToMbmFile
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CBubbleImageManager::MapEnumToMbmFile( const TBMIcons aBmIcon,
       
   156                                             TInt& aMbm,
       
   157                                             TDes& aFileName ) const
       
   158     {   
       
   159     aMbm = KBMIconIndex[aBmIcon].iconIndex;
       
   160     switch ( KBMIconIndex[aBmIcon].fileIndex )
       
   161         {
       
   162         case ECallstatusIconfile:
       
   163             aFileName = KBMMbmZDrive;
       
   164             aFileName.Append( KDC_APP_BITMAP_DIR );
       
   165             aFileName.Append( KBMCallStatusBitmapFile );
       
   166             aFileName.ZeroTerminate();
       
   167             break;
       
   168         case EBubblemanagerIconfile:
       
   169             BubbleUtils::BubbleIconFileName( aFileName );
       
   170             break;
       
   171         case EAvkonIconfile:
       
   172             aFileName = AknIconUtils::AvkonIconFileName();
       
   173             break;
       
   174         default:
       
   175             Panic( EBMPanicImages );
       
   176         }
       
   177     }
       
   178 
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CBubbleImageManager::MapEnumToSkin
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CBubbleImageManager::MapEnumToSkin( const TBMIcons aBmIcon, 
       
   185                                          TAknsItemID& aItemId, 
       
   186                                          TInt& aColorTableIndex ) const
       
   187     {    
       
   188     switch ( aBmIcon )
       
   189         {
       
   190         case EQgn_indi_call_active:
       
   191             aItemId = KAknsIIDQgnIndiCallActive;
       
   192             break;
       
   193         case EQgn_indi_call_active_cyph_off:
       
   194             aItemId = KAknsIIDQgnIndiCallActiveCyphOff;
       
   195             break;
       
   196         case EQgn_indi_call_disconn:
       
   197             aItemId = KAknsIIDQgnIndiCallDisconn;
       
   198             break;
       
   199         case EQgn_indi_call_disconn_cyph_off:
       
   200             aItemId = KAknsIIDQgnIndiCallDisconnCyphOff;
       
   201             break;
       
   202         case EQgn_indi_call_held:
       
   203             aItemId = KAknsIIDQgnIndiCallHeld;
       
   204             break;
       
   205         case EQgn_indi_call_held_cyph_off:
       
   206             aItemId = KAknsIIDQgnIndiCallHeldCyphOff;
       
   207             break;
       
   208         case EQgn_indi_call_active_2:
       
   209             aItemId = KAknsIIDQgnIndiCallActive2;
       
   210             break;    
       
   211         case EQgn_indi_call_video_1:
       
   212             aItemId = KAknsIIDQgnIndiCallVideo1;
       
   213             break;
       
   214         case EQgn_indi_call_video_callsta_1:
       
   215             aItemId = KAknsIIDQgnIndiCallVideoCallsta1;
       
   216             break;
       
   217         case EQgn_indi_call_video_disconn:
       
   218             aItemId = KAknsIIDQgnIndiCallVideoDisconn;
       
   219             break;
       
   220         case EQgn_indi_call_active_emergency:
       
   221             aItemId = KAknsIIDQgnIndiCallActiveEmergency;
       
   222             break;
       
   223         case EQgn_graf_call_first_one_active:
       
   224             aItemId = KAknsIIDQgnGrafCallFirstOneActive;
       
   225             break;
       
   226         case EQgn_graf_call_first_one_disconn:
       
   227             aItemId = KAknsIIDQgnGrafCallFirstOneDisconn;
       
   228             break;
       
   229         case EQgn_graf_call_first_one_held:
       
   230             aItemId = KAknsIIDQgnGrafCallFirstOneHeld;
       
   231             break;
       
   232         case EQgn_graf_call_rec_big:
       
   233             aItemId = KAknsIIDQgnGrafCallRecBig;
       
   234             break;
       
   235         case EQgn_graf_call_rec_big_disconn:
       
   236             aItemId = KAknsIIDQgnGrafCallRecBigDisconn;
       
   237             break;
       
   238         case EQgn_graf_call_rec_big_right:
       
   239             aItemId = KAknsIIDQgnGrafCallRecBigRight;
       
   240             break;
       
   241         case EQgn_graf_call_rec_big_right_disconn:
       
   242             aItemId = KAknsIIDQgnGrafCallRecBigRightDisconn;
       
   243             break;
       
   244         case EQgn_indi_call_waiting_1:
       
   245             aItemId = KAknsIIDQgnIndiCallWaiting1;
       
   246             break;
       
   247         case EQgn_indi_call_waiting_cyph_off_1:
       
   248             aItemId = KAknsIIDQgnIndiCallWaitingCyphOff;
       
   249             break;
       
   250         case EQgn_indi_call_waiting_disconn:
       
   251             aItemId = KAknsIIDQgnIndiCallWaitingDisconn;
       
   252             break;
       
   253         case EQgn_indi_call_waiting_disconn_cyph_off:
       
   254             aItemId = KAknsIIDQgnIndiCallWaitingDisconnCyphOff;
       
   255             break;
       
   256         case EQgn_graf_call_first_one_active_emergency:
       
   257             aItemId = KAknsIIDQgnGrafCallFirstOneActiveEmergency;
       
   258             break;  
       
   259         case EQgn_graf_call_two_active_emergency:
       
   260             aItemId = KAknsIIDQgnGrafCallTwoActiveEmergency;
       
   261             break;
       
   262         case EQgn_graf_call_conf_five:
       
   263             aItemId = KAknsIIDQgnGrafCallConfFive;
       
   264             break;
       
   265         case EQgn_graf_call_conf_four:
       
   266             aItemId = KAknsIIDQgnGrafCallConfFour;
       
   267             break;
       
   268         case EQgn_graf_call_conf_three:
       
   269             aItemId = KAknsIIDQgnGrafCallConfThree;
       
   270             break;
       
   271         case EQgn_graf_call_conf_two:
       
   272             aItemId = KAknsIIDQgnGrafCallConfTwo;
       
   273             break;
       
   274         case EQgn_graf_call_first_three_active:
       
   275             aItemId = KAknsIIDQgnGrafCallFirstThreeActive;
       
   276             break;
       
   277         case EQgn_graf_call_first_three_disconn:
       
   278             aItemId = KAknsIIDQgnGrafCallFirstThreeDisconn;
       
   279             break;
       
   280         case EQgn_graf_call_first_three_held:
       
   281             aItemId = KAknsIIDQgnGrafCallFirstThreeHeld;
       
   282             break;
       
   283         case EQgn_graf_call_first_two_active:
       
   284             aItemId = KAknsIIDQgnGrafCallFirstTwoActive;
       
   285             break;
       
   286         case EQgn_graf_call_first_two_disconn:
       
   287             aItemId = KAknsIIDQgnGrafCallFirstTwoDisconn;
       
   288             break;
       
   289         case EQgn_graf_call_first_two_held:
       
   290             aItemId = KAknsIIDQgnGrafCallFirstTwoHeld;
       
   291             break;
       
   292         case EQgn_graf_call_first_wait_active:
       
   293             aItemId = KAknsIIDQgnGrafCallFirstWaitActive;
       
   294             break;
       
   295         case EQgn_graf_call_first_wait_disconn:
       
   296             aItemId = KAknsIIDQgnGrafCallFirstWaitDisconn;
       
   297             break;
       
   298         case EQgn_graf_call_hidden_held:
       
   299             aItemId = KAknsIIDQgnGrafCallHiddenHeld;
       
   300             break;
       
   301         case EQgn_graf_call_rec_big_left:
       
   302             aItemId = KAknsIIDQgnGrafCallRecBigLeft;
       
   303             break;
       
   304         case EQgn_graf_call_rec_big_left_disconn:
       
   305             aItemId = KAknsIIDQgnGrafCallRecBigLeftDisconn;
       
   306             break;
       
   307         case EQgn_graf_call_rec_small_left:
       
   308             aItemId = KAknsIIDQgnGrafCallRecSmallLeft;
       
   309             break;
       
   310         case EQgn_graf_call_rec_small_right:
       
   311             aItemId = KAknsIIDQgnGrafCallRecSmallRight;
       
   312             break;
       
   313         case EQgn_graf_call_rec_small_right_disconn:
       
   314             aItemId = KAknsIIDQgnGrafCallRecSmallRightDisconn;
       
   315             break;
       
   316         case EQgn_graf_call_rec_bigger:
       
   317             aItemId = KAknsIIDQgnGrafCallRecBigger;
       
   318             break;
       
   319         case EQgn_graf_call_second_three_active:
       
   320             aItemId = KAknsIIDQgnGrafCallSecondThreeActive;
       
   321             break;
       
   322         case EQgn_graf_call_second_three_disconn:
       
   323             aItemId = KAknsIIDQgnGrafCallSecondThreeDisconn;
       
   324             break;
       
   325         case EQgn_graf_call_second_three_held:
       
   326             aItemId = KAknsIIDQgnGrafCallSecondThreeHeld;
       
   327             break;
       
   328         case EQgn_graf_call_second_two_active:
       
   329             aItemId = KAknsIIDQgnGrafCallSecondTwoActive;
       
   330             break;
       
   331         case EQgn_graf_call_second_two_disconn:
       
   332             aItemId = KAknsIIDQgnGrafCallSecondTwoDisconn;
       
   333             break;
       
   334         case EQgn_graf_call_second_two_held:
       
   335             aItemId = KAknsIIDQgnGrafCallSecondTwoHeld;
       
   336             break;
       
   337         case EQgn_indi_call_active_conf:
       
   338             aItemId = KAknsIIDQgnIndiCallActiveConf;
       
   339             break;
       
   340         case EQgn_indi_call_active_conf_cyph_off:
       
   341             aItemId = KAknsIIDQgnIndiCallActiveConfCyphOff;
       
   342             break;
       
   343         case EQgn_indi_call_active_cyph_off_2:
       
   344             aItemId = KAknsIIDQgnIndiCallActiveCyphOff2;
       
   345             break;
       
   346         case EQgn_indi_call_disconn_conf:
       
   347             aItemId = KAknsIIDQgnIndiCallDisconnConf;
       
   348             break;
       
   349         case EQgn_indi_call_disconn_conf_cyph_off:
       
   350             aItemId = KAknsIIDQgnIndiCallDisconnConfCyphOff;
       
   351             break;
       
   352         case EQgn_indi_call_held_conf:
       
   353             aItemId = KAknsIIDQgnIndiCallHeldConf;
       
   354             break;
       
   355         case EQgn_indi_call_held_conf_cyph_off:
       
   356             aItemId = KAknsIIDQgnIndiCallHeldConfCyphOff;
       
   357             break;
       
   358         case EQgn_indi_call_muted:
       
   359             aItemId = KAknsIIDQgnIndiCallMuted;
       
   360             break;
       
   361         case EQgn_indi_call_waiting_2:
       
   362             aItemId = KAknsIIDQgnIndiCallWaiting2;
       
   363             break;
       
   364         case EQgn_indi_call_waiting_cyph_off_2:
       
   365             aItemId = KAknsIIDQgnIndiCallWaitingCyphOff2;
       
   366             break;
       
   367         case EQgn_indi_call_video_2:
       
   368             aItemId = KAknsIIDQgnIndiCallVideo2;
       
   369             break;
       
   370         case EQgn_indi_call_video_callsta_2:
       
   371             aItemId = KAknsIIDQgnIndiCallVideoCallsta2;
       
   372             break;            
       
   373         case EQgn_indi_call_video_callsta_disconn:
       
   374             aItemId = KAknsIIDQgnIndiCallVideoCallstaDisconn; 
       
   375             break;
       
   376         case EQgn_indi_call_voip_active:
       
   377             aItemId = KAknsIIDQgnIndiCallVoipActive;
       
   378             break;
       
   379         case EQgn_indi_call_voip_active_2:
       
   380             aItemId = KAknsIIDQgnIndiCallVoipActive2;
       
   381             break;    
       
   382         case EQgn_indi_call_voip_disconn:
       
   383             aItemId = KAknsIIDQgnIndiCallVoipDisconn;
       
   384             break;
       
   385         case EQgn_indi_call_voip_held:
       
   386             aItemId = KAknsIIDQgnIndiCallVoipHeld;
       
   387             break;
       
   388         case EQgn_indi_call_voip_waiting_1:
       
   389             aItemId = KAknsIIDQgnIndiCallVoipWaiting1;
       
   390             break;
       
   391         case EQgn_indi_call_voip_waiting_2:
       
   392             aItemId = KAknsIIDQgnIndiCallVoipWaiting2;
       
   393             break;
       
   394         case EQgn_indi_call_voip_callsta_disconn:
       
   395             aItemId = KAknsIIDQgnIndiCallVoipCallstaDisconn;
       
   396             break; 
       
   397         case EQgn_graf_call_image_1:
       
   398             aItemId = KAknsIIDQgnGrafCallImage1;
       
   399             break;
       
   400         case EQgn_indi_call4_image_mask_prt:
       
   401             aItemId = KAknsIIDNone;
       
   402             break;
       
   403         case EQgn_indi_call4_image_mask_lsc:
       
   404             aItemId = KAknsIIDNone;
       
   405             break;
       
   406 
       
   407 // Colour changes
       
   408         case EQgn_indi_call_line2:
       
   409             aItemId = KAknsIIDQgnIndiCallLine2;
       
   410             aColorTableIndex = EAknsCIQsnIconColorsCG11;
       
   411             break;
       
   412         case EQgn_indi_call_cyphering_off:
       
   413             aItemId = KAknsIIDQgnIndiCallCypheringOff;
       
   414             aColorTableIndex = EAknsCIQsnIconColorsCG11;
       
   415             break;
       
   416         case EQgn_indi_call_diverted:
       
   417             aItemId = KAknsIIDQgnIndiCallDiverted;
       
   418             aColorTableIndex = EAknsCIQsnIconColorsCG11;
       
   419             break;
       
   420 
       
   421         // Not skinned
       
   422         case EQgn_prop_nrtyp_home_div:
       
   423             aItemId = KAknsIIDQgnPropNrtypHomeDiv;
       
   424             break;
       
   425         case EQgn_prop_nrtyp_mobile_div:
       
   426             aItemId = KAknsIIDQgnPropNrtypMobileDiv;
       
   427             break;
       
   428         case EQgn_prop_nrtyp_phone_div:
       
   429             aItemId = KAknsIIDQgnPropNrtypPhoneDiv;
       
   430             break;
       
   431         case EQgn_prop_nrtyp_work_div:
       
   432             aItemId = KAknsIIDQgnPropNrtypWorkDiv;
       
   433             break;
       
   434 
       
   435             // From avkon.mbm
       
   436         case EQgn_prop_nrtyp_fax:
       
   437             aItemId = KAknsIIDQgnPropNrtypFax;
       
   438             break;
       
   439         case EQgn_prop_nrtyp_home:
       
   440             aItemId = KAknsIIDQgnPropNrtypPhone;
       
   441             break;
       
   442         case EQgn_prop_nrtyp_mobile:
       
   443             aItemId = KAknsIIDQgnPropNrtypMobile;
       
   444             break;
       
   445         case EQgn_prop_nrtyp_pager:
       
   446             aItemId = KAknsIIDQgnPropNrtypPager;
       
   447             break;
       
   448         case EQgn_prop_nrtyp_phone:
       
   449             aItemId = KAknsIIDQgnPropNrtypPhone;
       
   450             break;
       
   451         case EQgn_prop_nrtyp_work:
       
   452             aItemId = KAknsIIDQgnPropNrtypPhone;
       
   453             break;
       
   454         case EQgn_prop_nrtyp_voip:
       
   455             aItemId = KAknsIIDQgnPropNrtypVoip;
       
   456             break;
       
   457         case EQgn_prop_nrtyp_car:
       
   458             aItemId = KAknsIIDQgnPropNrtypCar;
       
   459             break;            
       
   460         case EQgn_prop_nrtyp_assistant:
       
   461             aItemId = KAknsIIDQgnPropNrtypAssistant;
       
   462             break;            
       
   463         default:
       
   464             break;
       
   465         }
       
   466     }
       
   467 
       
   468 // ---------------------------------------------------------------------------
       
   469 // CBubbleImageManager::ClearSkinsCache
       
   470 // 
       
   471 // ---------------------------------------------------------------------------
       
   472 //
       
   473 void CBubbleImageManager::ClearSkinsCache()
       
   474     {
       
   475     iSkinnedBitmaps.ResetAndDestroy();
       
   476     
       
   477     TRAP_IGNORE( LoadCachedBitmapsL() );
       
   478     
       
   479     PrepareCachedBitmaps();
       
   480     }
       
   481     
       
   482 
       
   483 // ---------------------------------------------------------------------------
       
   484 // CBubbleImageManager::CompareSkinnedData
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 TInt CBubbleImageManager::CompareSkinnedData( 
       
   488     const CBubbleSkinBitmap& aSkinnedBitmap1, 
       
   489     const CBubbleSkinBitmap& aSkinnedBitmap2 )
       
   490     {
       
   491     if ( aSkinnedBitmap1.BitmapIndex() > aSkinnedBitmap2.BitmapIndex() )
       
   492         {
       
   493         return 1;
       
   494         }
       
   495     if ( aSkinnedBitmap1.BitmapIndex() < aSkinnedBitmap2.BitmapIndex() )
       
   496         {
       
   497         return -1;
       
   498         }
       
   499     return 0;    
       
   500     }
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // CBubbleImageManager::GetSkin
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 TBool CBubbleImageManager::GetSkin( CEikImage&      aImage, 
       
   507                                     const TBMIcons  aBmIcon, 
       
   508                                     const TBMIcons  aBmIconMask )
       
   509     {
       
   510     if ( aBmIcon < 0 || aBmIcon > KBMLastAvkonBitmap )
       
   511         {        
       
   512         return EFalse;
       
   513         }
       
   514 
       
   515     CBubbleSkinBitmap skinnedBitmap;
       
   516     skinnedBitmap.SetBitmapIndex( aBmIcon );
       
   517     skinnedBitmap.SetSkinnedBitmap( NULL );
       
   518     skinnedBitmap.SetSkinnedMask( NULL );
       
   519     TInt index = iSkinnedBitmaps.FindInOrder( &skinnedBitmap, iOrder );
       
   520     
       
   521     CFbsBitmap* bitmap = NULL;
       
   522     CFbsBitmap* mask = NULL;
       
   523     if ( index != KErrNotFound )
       
   524         {
       
   525         bitmap = iSkinnedBitmaps[ index ]->SkinnedBitmap();
       
   526         mask = iSkinnedBitmaps[ index ]->SkinnedMask();
       
   527         }
       
   528                                                      
       
   529     if ( bitmap == NULL )
       
   530         {
       
   531         TRAP_IGNORE(
       
   532             LoadAndAppendSkinL( aBmIcon, aBmIconMask, bitmap, mask ) );
       
   533         }
       
   534 
       
   535     if ( bitmap )
       
   536         {
       
   537         aImage.SetPicture( bitmap, mask ); // Mask might be NULL
       
   538         aImage.SetPictureOwnedExternally( ( aBmIcon <= LastCachedIcon() ) ); // cached bitmaps are owned here
       
   539         return ETrue;
       
   540         }
       
   541     
       
   542     return EFalse;
       
   543     }
       
   544 
       
   545 // ---------------------------------------------------------------------------
       
   546 // CBubbleImageManager::LoadAndAppendSkinL
       
   547 // ---------------------------------------------------------------------------
       
   548 //
       
   549 void CBubbleImageManager::LoadAndAppendSkinL( const TBMIcons aBmIcon,
       
   550                                               const TBMIcons aBmIconMask,
       
   551                                               CFbsBitmap*&   aBitmap, 
       
   552                                               CFbsBitmap*&   aMask )
       
   553 
       
   554     {
       
   555     TInt mbmBitmapIndex = 0;
       
   556     TInt mbmMaskIndex = KErrNotFound;
       
   557     TInt colorTableIndex( 0 );
       
   558     TAknsItemID skinItemId( KAknsIIDNone );    
       
   559     MapEnumToMbmFile( aBmIcon , mbmBitmapIndex , iMbmFileBuffer );    
       
   560     
       
   561     if ( mbmBitmapIndex == KErrNotFound )
       
   562         {        
       
   563         User::Leave( KErrNotFound );
       
   564         }
       
   565     
       
   566     if ( aBmIconMask >= 0 && aBmIconMask <= KBMLastAvkonBitmap )
       
   567         {        
       
   568         MapEnumToMbmFile( aBmIconMask , mbmMaskIndex , iMbmFileBuffer );
       
   569         }
       
   570     MapEnumToSkin( aBmIcon, skinItemId, colorTableIndex );    
       
   571     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   572 
       
   573     if( colorTableIndex != 0 )
       
   574         {
       
   575         AknsUtils::CreateColorIconLC( skin, skinItemId, 
       
   576                                       KAknsIIDQsnIconColors, 
       
   577                                       colorTableIndex, 
       
   578                                       aBitmap, aMask, 
       
   579                                       iMbmFileBuffer, 
       
   580                                       mbmBitmapIndex, mbmMaskIndex, 
       
   581                                       KRgbBlack );
       
   582         }
       
   583     else
       
   584         {
       
   585         if ( mbmMaskIndex != KErrNotFound )
       
   586             {
       
   587             AknsUtils::CreateIconLC( skin, skinItemId, 
       
   588                                  aBitmap, aMask, iMbmFileBuffer, 
       
   589                                  mbmBitmapIndex, mbmMaskIndex );
       
   590             }
       
   591         else
       
   592             {
       
   593             AknsUtils::CreateIconLC( skin, skinItemId, 
       
   594                                  aBitmap, iMbmFileBuffer, mbmBitmapIndex );
       
   595             }
       
   596         }
       
   597 
       
   598     
       
   599     if ( aBmIcon <= LastCachedIcon() )
       
   600         {
       
   601         CBubbleSkinBitmap* skinnedBitmap = new (ELeave) CBubbleSkinBitmap();
       
   602         CleanupStack::PushL( skinnedBitmap );
       
   603         skinnedBitmap->SetBitmapIndex( aBmIcon );
       
   604         //skinnedBitmap->SetBitmapSkinItemID( skinItemId );
       
   605         skinnedBitmap->SetSkinnedBitmap( aBitmap );
       
   606         skinnedBitmap->SetSkinnedMask( aMask );
       
   607         User::LeaveIfError( 
       
   608             iSkinnedBitmaps.InsertInOrder( skinnedBitmap, iOrder ) );                
       
   609         CleanupStack::Pop( skinnedBitmap ); // Ownership was given to iSkinnedBitmaps
       
   610         }
       
   611 
       
   612 
       
   613     if ( colorTableIndex != 0 )
       
   614         {
       
   615         CleanupStack::Pop( 2 ); // aBitmap, aMask
       
   616         }
       
   617     else
       
   618         {        
       
   619         if ( mbmMaskIndex != KErrNotFound )
       
   620             {
       
   621             CleanupStack::Pop(); // aMask
       
   622             }
       
   623         CleanupStack::Pop(); // aBitmap
       
   624         }    
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------------------------
       
   628 // CBubbleImageManager::DoInitializeBitmaps
       
   629 // ---------------------------------------------------------------------------
       
   630 //    
       
   631 TBool CBubbleImageManager::DoInitializeBitmaps()
       
   632     {
       
   633     // Bubble rect for single call or number entry
       
   634     TAknWindowLineLayout bottomBubble = 
       
   635     BubbleLayout::popup_call_audio_in_window( 1 );
       
   636     TAknLayoutRect bottomBubbleRect;
       
   637     bottomBubbleRect.LayoutRect( BubbleLayout::MainPaneRect(), 
       
   638                                  bottomBubble );
       
   639     
       
   640     TInt iconCount = iSkinnedBitmaps.Count();
       
   641     if ( iBitmapInitIndex < iconCount )
       
   642         {
       
   643         CBubbleSkinBitmap* skinnedBitmap = iSkinnedBitmaps[ iBitmapInitIndex ];    
       
   644         
       
   645         switch ( skinnedBitmap->BitmapIndex() )
       
   646             {
       
   647             // Small call status icon
       
   648             case EQgn_indi_call_active:
       
   649             case EQgn_indi_call_active_2:
       
   650             case EQgn_indi_call_disconn:
       
   651             case EQgn_indi_call_held:
       
   652             case EQgn_indi_call_video_callsta_1:
       
   653             case EQgn_indi_call_video_callsta_2:
       
   654             case EQgn_indi_call_video_callsta_disconn:
       
   655             case EQgn_indi_call_voip_active:
       
   656             case EQgn_indi_call_voip_active_2:
       
   657             case EQgn_indi_call_voip_held:
       
   658             case EQgn_indi_call_voip_callsta_disconn:
       
   659                 {
       
   660                 TAknWindowLineLayout smallCallStatusIcon = 
       
   661                     BubbleLayout::popup_call_audio_first_window_1_elements_1();
       
   662                 TAknLayoutRect smallCallStatusIconRect;
       
   663                 smallCallStatusIconRect.LayoutRect( bottomBubbleRect.Rect(),
       
   664                                                     smallCallStatusIcon );                                        
       
   665                                              
       
   666                 AknIconUtils::SetSize( skinnedBitmap->SkinnedBitmap(), 
       
   667                                        smallCallStatusIconRect.Rect().Size() );                                             
       
   668                 break;    
       
   669                 }
       
   670             
       
   671             // Big call status icon
       
   672             case EQgn_indi_call_waiting_1:
       
   673             case EQgn_indi_call_waiting_2:
       
   674             case EQgn_indi_call_waiting_disconn:
       
   675             case EQgn_indi_call_video_1:
       
   676             case EQgn_indi_call_video_2:
       
   677             case EQgn_indi_call_video_disconn:
       
   678             case EQgn_indi_call_voip_waiting_1:
       
   679             case EQgn_indi_call_voip_waiting_2:
       
   680             case EQgn_indi_call_voip_disconn:
       
   681                 {
       
   682                 TAknWindowLineLayout bigCallStatusIcon = 
       
   683                     BubbleLayout::popup_call_audio_in_window_1_elements_1();
       
   684                 TAknLayoutRect bigCallStatusIconRect;
       
   685                 bigCallStatusIconRect.LayoutRect( bottomBubbleRect.Rect(),
       
   686                                                   bigCallStatusIcon );                                        
       
   687                                              
       
   688                 AknIconUtils::SetSize( skinnedBitmap->SkinnedBitmap(), 
       
   689                                        bigCallStatusIconRect.Rect().Size() ); 
       
   690                 break;    
       
   691                 }
       
   692             
       
   693             // Bubble graphics
       
   694             case EQgn_graf_call_rec_big: 
       
   695             case EQgn_graf_call_rec_big_disconn:
       
   696             case EQgn_graf_call_first_one_active:
       
   697             case EQgn_graf_call_first_one_disconn:
       
   698             case EQgn_graf_call_first_one_held:
       
   699                 {
       
   700                 AknIconUtils::SetSize( skinnedBitmap->SkinnedBitmap(), 
       
   701                                        bottomBubbleRect.Rect().Size(),
       
   702                                        EAspectRatioNotPreserved );  
       
   703                 break;    
       
   704                 }
       
   705             default:
       
   706                 // do nothing
       
   707                 break;
       
   708             }
       
   709         
       
   710         iBitmapInitIndex++;
       
   711         return ETrue;
       
   712         }
       
   713     else
       
   714         {
       
   715         return EFalse;    
       
   716         }        
       
   717     }
       
   718 
       
   719 // ---------------------------------------------------------------------------
       
   720 // CBubbleImageManager::InitializeBitmap
       
   721 // ---------------------------------------------------------------------------
       
   722 // 
       
   723 TInt CBubbleImageManager::InitializeBitmaps( TAny* aThis )
       
   724     {
       
   725     return static_cast<CBubbleImageManager*>( aThis )->DoInitializeBitmaps();
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // CBubbleImageManager::PrepareCachedBitmaps
       
   730 // ---------------------------------------------------------------------------
       
   731 //    
       
   732 void CBubbleImageManager::PrepareCachedBitmaps()
       
   733     {
       
   734     iBitmapInitIndex = 0;
       
   735     iBitmapInitializer->Cancel();
       
   736     iBitmapInitializer->Start( TCallBack( InitializeBitmaps, this ) );            
       
   737     }
       
   738 
       
   739 // ---------------------------------------------------------------------------
       
   740 // CBubbleImageManager::LoadCachedBitmapsL
       
   741 // ---------------------------------------------------------------------------
       
   742 //
       
   743 void CBubbleImageManager::LoadCachedBitmapsL()
       
   744     {
       
   745     // Load essential bitmaps right away
       
   746     CFbsBitmap* newBitmap = NULL;
       
   747     CFbsBitmap* newMask = NULL;
       
   748     TInt lastIcon = LastCachedIcon();
       
   749     for ( TInt i = 0 ; i < lastIcon ; i++ )
       
   750         {
       
   751         LoadAndAppendSkinL( (TBMIcons) i, // icon
       
   752                             (TBMIcons) (i+1), // mask
       
   753                             newBitmap, 
       
   754                             newMask );
       
   755         newBitmap = NULL;
       
   756         newMask = NULL;
       
   757         }    
       
   758     }
       
   759 
       
   760 // ---------------------------------------------------------------------------
       
   761 // CBubbleImageManager::LastCachedIcon
       
   762 // ---------------------------------------------------------------------------
       
   763 //    
       
   764 TInt CBubbleImageManager::LastCachedIcon()
       
   765     {
       
   766     if ( iFrameIcons )    
       
   767         {
       
   768         return KBMLastCachedBitmap2;    
       
   769         }
       
   770     else
       
   771         {
       
   772         return KBMLastCachedBitmap1;    
       
   773         }        
       
   774     }
       
   775 
       
   776 // End of File